From patchwork Fri Jun 16 16:11:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 9792181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0FAA060325 for ; Fri, 16 Jun 2017 16:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0429A28590 for ; Fri, 16 Jun 2017 16:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED3D728614; Fri, 16 Jun 2017 16:11:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0BA128590 for ; Fri, 16 Jun 2017 16:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751815AbdFPQLf (ORCPT ); Fri, 16 Jun 2017 12:11:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43458 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbdFPQLf (ORCPT ); Fri, 16 Jun 2017 12:11:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93F7FC04B943 for ; Fri, 16 Jun 2017 16:11:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 93F7FC04B943 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=zlang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 93F7FC04B943 Received: from localhost.localdomain.com (ovpn-12-139.pek2.redhat.com [10.72.12.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B8E682E2E for ; Fri, 16 Jun 2017 16:11:33 +0000 (UTC) From: Zorro Lang To: fstests@vger.kernel.org Subject: [PATCH 3/4] fsstress: do memset randomly before write operations Date: Sat, 17 Jun 2017 00:11:05 +0800 Message-Id: <1497629466-22647-3-git-send-email-zlang@redhat.com> In-Reply-To: <1497629466-22647-1-git-send-email-zlang@redhat.com> References: <1497629466-22647-1-git-send-email-zlang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 16 Jun 2017 16:11:34 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Recently we found a bug by trigger a page fault when io-vector of writev is in processing. If do memset between malloc() and write operations, memset will init the pages. So do memset randomly maybe help to cover above situation. Signed-off-by: Zorro Lang --- ltp/fsstress.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 4ff90d5..e1b73e4 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -1924,7 +1924,8 @@ do_aio_rw(int opno, long r, int flags) off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE)); off -= (off % align); off %= maxfsize; - memset(buf, nameseq & 0xff, len); + /* randomly memset maybe trigger page fault at write time */ + if (random() / 2) memset(buf, nameseq & 0xff, len); io_prep_pwrite(&iocb, fd, buf, len, off); } else { off = (off64_t)(lr % stb.st_size); @@ -2455,7 +2456,8 @@ dwrite_f(int opno, long r) buf = memalign(diob.d_mem, len); off %= maxfsize; lseek64(fd, off, SEEK_SET); - memset(buf, nameseq & 0xff, len); + /* randomly memset maybe trigger page fault at write time */ + if (random() / 2) memset(buf, nameseq & 0xff, len); e = write(fd, buf, len) < 0 ? errno : 0; free(buf); if (v) @@ -3672,7 +3674,8 @@ write_f(int opno, long r) lseek64(fd, off, SEEK_SET); len = (random() % FILELEN_MAX) + 1; buf = malloc(len); - memset(buf, nameseq & 0xff, len); + /* randomly memset maybe trigger page fault at write time */ + if (random() / 2) memset(buf, nameseq & 0xff, len); e = write(fd, buf, len) < 0 ? errno : 0; free(buf); if (v) @@ -3733,7 +3736,8 @@ writev_f(int opno, long r) lseek64(fd, off, SEEK_SET); len = (random() % FILELEN_MAX) + 1; buf = malloc(len); - memset(buf, nameseq & 0xff, len); + /* randomly memset maybe trigger page fault at write time */ + if (random() / 2) memset(buf, nameseq & 0xff, len); iovcnt = (random() % MIN(len, IOV_MAX)) + 1; iov = malloc(sizeof(struct iovec) * iovcnt);