From patchwork Tue Mar 5 12:34:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 1051719 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44DGYf4lrBz9s6w for ; Tue, 5 Mar 2019 23:34:43 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 36EBF3EA35F for ; Tue, 5 Mar 2019 13:34:38 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 20B053EA2B8 for ; Tue, 5 Mar 2019 13:34:36 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id CD6761A0113B for ; Tue, 5 Mar 2019 13:34:34 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFA388110E; Tue, 5 Mar 2019 12:34:31 +0000 (UTC) Received: from dustball.brq.redhat.com (unknown [10.43.17.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09AD860139; Tue, 5 Mar 2019 12:34:30 +0000 (UTC) From: Jan Stancek To: ltp@lists.linux.it Date: Tue, 5 Mar 2019 13:34:26 +0100 Message-Id: <69e171efb14ec9078a4b70838f45ff5a550388d8.1551789098.git.jstancek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 05 Mar 2019 12:34:32 +0000 (UTC) X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH/RFC] syscalls/readahead02: don't use cache size X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Using system-wide "Cached" size is not accurate. The test is sporadically failing with warning on ppc64le 4.18 and 5.0 kernels. Problem is that test over-estimates max readahead size, which then leads to fewer readhead calls and kernel can silently trims length in each of them: ... readahead02.c:244: INFO: Test #2: POSIX_FADV_WILLNEED on file readahead02.c:134: INFO: creating test file of size: 67108864 readahead02.c:263: INFO: read_testfile(0) readahead02.c:274: INFO: read_testfile(1) readahead02.c:189: INFO: max ra estimate: 12320768 readahead02.c:198: INFO: readahead calls made: 6 readahead02.c:204: PASS: offset is still at 0 as expected readahead02.c:308: INFO: read_testfile(0) took: 492486 usec readahead02.c:309: INFO: read_testfile(1) took: 430627 usec readahead02.c:311: INFO: read_testfile(0) read: 67108864 bytes readahead02.c:313: INFO: read_testfile(1) read: 59244544 bytes readahead02.c:316: PASS: readahead saved some I/O readahead02.c:324: INFO: cache can hold at least: 264192 kB readahead02.c:325: INFO: read_testfile(0) used cache: 124992 kB readahead02.c:326: INFO: read_testfile(1) used cache: 12032 kB readahead02.c:338: WARN: using less cache than expected Stop relying on used cache size, and use minimal sane readahead length, that should work across all systems. Signed-off-by: Jan Stancek --- testcases/kernel/syscalls/readahead/readahead02.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c index 293c839e169e..2f4d7f05a550 100644 --- a/testcases/kernel/syscalls/readahead/readahead02.c +++ b/testcases/kernel/syscalls/readahead/readahead02.c @@ -165,13 +165,11 @@ static int read_testfile(struct tcase *tc, int do_readahead, size_t i = 0; long read_bytes_start; unsigned char *p, tmp; - unsigned long cached_start, max_ra_estimate = 0; off_t offset = 0; fd = SAFE_OPEN(fname, O_RDONLY); if (do_readahead) { - cached_start = get_cached_size(); do { TEST(tc->readahead(fd, offset, fsize - offset)); if (TST_RET != 0) { @@ -179,21 +177,8 @@ static int read_testfile(struct tcase *tc, int do_readahead, return TST_ERR; } - /* estimate max readahead size based on first call */ - if (!max_ra_estimate) { - *cached = get_cached_size(); - if (*cached > cached_start) { - max_ra_estimate = (1024 * - (*cached - cached_start)); - tst_res(TINFO, "max ra estimate: %lu", - max_ra_estimate); - } - max_ra_estimate = MAX(max_ra_estimate, - MIN_SANE_READAHEAD); - } - i++; - offset += max_ra_estimate; + offset += MIN_SANE_READAHEAD; } while ((size_t)offset < fsize); tst_res(TINFO, "readahead calls made: %zu", i); *cached = get_cached_size(); @@ -334,8 +319,6 @@ static void test_readahead(unsigned int n) tst_res(TPASS, "using cache as expected"); else if (!cached_ra) tst_res(TFAIL, "readahead failed to use any cache"); - else - tst_res(TWARN, "using less cache than expected"); } else { tst_res(TCONF, "Page cache on your system is too small " "to hold whole testfile.");