From patchwork Wed Nov 28 16:46:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 1004656 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=2001:1418:10:5::2; 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HE5ZjI+B"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 434mlp1s92z9s2P for ; Thu, 29 Nov 2018 03:47:18 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8A27C3E797D for ; Wed, 28 Nov 2018 17:47:15 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 522F43E79A2 for ; Wed, 28 Nov 2018 17:46:58 +0100 (CET) Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 004FD2011F0 for ; Wed, 28 Nov 2018 17:46:57 +0100 (CET) Received: by mail-wr1-x442.google.com with SMTP id j10so27004987wru.4 for ; Wed, 28 Nov 2018 08:46:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4L5jjk47+D0wKI1Wfr/w9sABisSFflxjk3io4PjSLFk=; b=HE5ZjI+BYwP+ScqqHENsd7jQSoPUgP5tFEqrgDZIlcoh9sT/3QSAXWhMhQF6AJCjJl CBGSphmQhFMZ3BH9McmP8JbcOjxglRpffg9EJu+GQlmQJT6Jbe7qUK7ngio8j4fO1TWZ ms0fRce3JrqyIa5lOGrfXTXWqt7noCGrs2lWNjJZ/vEx3KnxyvkeLm3XtWxb2wiGXuZ1 cdQuhxKMg83IsvztMHbbilSlXZMdVw0iuC3cBBGuIPBnYMS7whHYEu1HtsoGs7PHNKIs mxtLnGjav9DJdDjahIjLNUMlfDhIXCfAA3qILQK3EExeeCOqXvCbPJrNQok5TEJWXRgv ay4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4L5jjk47+D0wKI1Wfr/w9sABisSFflxjk3io4PjSLFk=; b=IkJ1zQUYA38ny5xPcjCGFUrMVQdPFu8vj831zqhRpIIdMrQuBuVgaA5oEPSjg+k+4B o1QzXagGtcreDfzTymudWXAviSo1bGj6INstr6q5sF8HfnPDyNg5oInnECg+naigVOnP Em/3wfBvADHPG83vdl8CkDXHIXunuqWs6tV/+/m6bDSMpmSEVP1rWc1X9+FlTw8WQunU PzurRQlKXp2l/zxgY0yGPoNmkpxXEc4zQq7mMuXnBVFZRPRGwaCWC6bX8lRqAbqZYAqX 5A60KPHehdEyhYdnda6m0s4mqZHn61KDNJAT9zEv2S+P3dm1fm0uRMKT72dba3TGeHKb TCxA== X-Gm-Message-State: AA+aEWZNf1dyYEZC/GL9+APgEZ/CQ/krbiNlKbMTpsZ7fjj/DxPruE3Q EhaujzTbTWPAoysEwz0CsMg= X-Google-Smtp-Source: AFSGD/XWaU2zVqT0uw1TlzgroXgwOlzEOTZTVAuS6kSKy2c/ozAkcTz+Qf8vQNbzgb/u88zG1rziug== X-Received: by 2002:adf:e18d:: with SMTP id k13mr32547450wri.36.1543423617529; Wed, 28 Nov 2018 08:46:57 -0800 (PST) Received: from localhost.localdomain ([37.46.46.74]) by smtp.gmail.com with ESMTPSA id 126-v6sm2732945wme.48.2018.11.28.08.46.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 08:46:56 -0800 (PST) From: Amir Goldstein To: Cyril Hrubis Date: Wed, 28 Nov 2018 18:46:43 +0200 Message-Id: <20181128164645.783-5-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181128164645.783-1-amir73il@gmail.com> References: <20181128164645.783-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Cc: linux-unionfs@vger.kernel.org, ltp@lists.linux.it, Miklos Szeredi Subject: [LTP] [PATCH v4 4/6] syscalls/readahead02: Convert to tst_timer helpers 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" To avoid usinf wall clock and get rid of gettimeofday boiler plate code. Signed-off-by: Amir Goldstein --- .../kernel/syscalls/readahead/readahead02.c | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c index 0acdad482..24f045900 100644 --- a/testcases/kernel/syscalls/readahead/readahead02.c +++ b/testcases/kernel/syscalls/readahead/readahead02.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include #include "config.h" #include "tst_test.h" +#include "tst_timer.h" #include "lapi/syscalls.h" static char testfile[PATH_MAX] = "testfile"; @@ -130,17 +130,15 @@ static void create_testfile(void) * @cached: returns cached kB from /proc/meminfo */ static void read_testfile(int do_readahead, const char *fname, size_t fsize, - unsigned long *read_bytes, long *usec, + unsigned long *read_bytes, long long *usec, unsigned long *cached) { int fd; size_t i = 0; long read_bytes_start; unsigned char *p, tmp; - unsigned long time_start_usec, time_end_usec; unsigned long cached_start, max_ra_estimate = 0; off_t offset = 0; - struct timeval now; fd = SAFE_OPEN(fname, O_RDONLY); @@ -180,9 +178,7 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, tst_res(TFAIL, "offset has changed to: %lu", offset); } - if (gettimeofday(&now, NULL) == -1) - tst_brk(TBROK | TERRNO, "gettimeofday failed"); - time_start_usec = now.tv_sec * 1000000 + now.tv_usec; + tst_timer_start(CLOCK_MONOTONIC); read_bytes_start = get_bytes_read(); p = SAFE_MMAP(NULL, fsize, PROT_READ, MAP_SHARED | MAP_POPULATE, fd, 0); @@ -201,10 +197,8 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, SAFE_MUNMAP(p, fsize); *read_bytes = get_bytes_read() - read_bytes_start; - if (gettimeofday(&now, NULL) == -1) - tst_brk(TBROK | TERRNO, "gettimeofday failed"); - time_end_usec = now.tv_sec * 1000000 + now.tv_usec; - *usec = time_end_usec - time_start_usec; + tst_timer_stop(); + *usec = tst_timer_elapsed_us(); SAFE_CLOSE(fd); } @@ -212,7 +206,7 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, static void test_readahead(void) { unsigned long read_bytes, read_bytes_ra; - long usec, usec_ra; + long long usec, usec_ra; unsigned long cached_max, cached_low, cached, cached_ra; char proc_io_fname[128]; sprintf(proc_io_fname, "/proc/%u/io", getpid()); @@ -253,8 +247,8 @@ static void test_readahead(void) else cached_ra = 0; - tst_res(TINFO, "read_testfile(0) took: %ld usec", usec); - tst_res(TINFO, "read_testfile(1) took: %ld usec", usec_ra); + tst_res(TINFO, "read_testfile(0) took: %lli usec", usec); + tst_res(TINFO, "read_testfile(1) took: %lli usec", usec_ra); if (has_file(proc_io_fname, 0)) { tst_res(TINFO, "read_testfile(0) read: %ld bytes", read_bytes); tst_res(TINFO, "read_testfile(1) read: %ld bytes",