From patchwork Tue Aug 11 16:16:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhilash Jindal X-Patchwork-Id: 506151 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A1C951402BC for ; Wed, 12 Aug 2015 02:19:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=QuC9Va0Y; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZPCEC-0005fR-5X; Tue, 11 Aug 2015 16:16:40 +0000 Received: from mail-io0-x231.google.com ([2607:f8b0:4001:c06::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZPCEA-0005aW-49 for linux-mtd@lists.infradead.org; Tue, 11 Aug 2015 16:16:38 +0000 Received: by iods203 with SMTP id s203so10409211iod.0 for ; Tue, 11 Aug 2015 09:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=1e8/qmK+kO+sP+6v1rcTh89r1oW9WvzSsJZbJKSmACU=; b=QuC9Va0YwdrqnH07udKLsiMChdumCO8S2OZebI5CvGpneJOXtruv/Mwt4bNhE3fEvi L6v/2f6haMOhh5fITiCAVJ6uKaW6MQDxPngBZDdwwHLmTCVTw9ak2wCbZ2TETqexldBT zQdUrXwjwruKzIL9jaXK4a5BgSKXryKC33vjVFb0120lCUx3S2kLM7OKIXwEF8bWR1bn tNqSFSma4pC6tepRPOy6cst1+WLtTqCOMvD83oraGqoe2PpZaVeFTqA5Qr7RMY8vJgYC iJvoomTTaz2Rnp9rln2DSZR5ba++c+PUWf040BmkriIjVqELyzJEaNhv91NczDkmVxlo o8hQ== X-Received: by 10.107.16.33 with SMTP id y33mr16181335ioi.183.1439309776939; Tue, 11 Aug 2015 09:16:16 -0700 (PDT) Received: from sp12.ecn.purdue.edu.ecn.purdue.edu (eprof.ecn.purdue.edu. [128.46.101.56]) by smtp.gmail.com with ESMTPSA id h33sm1812923iod.23.2015.08.11.09.16.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Aug 2015 09:16:16 -0700 (PDT) From: Abhilash Jindal To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: tests: Use boottime Date: Tue, 11 Aug 2015 12:16:14 -0400 Message-Id: <1439309774-12539-1-git-send-email-klock.android@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150811_091638_214680_4CF0040A X-CRM114-Status: GOOD ( 11.65 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4001:c06:0:0:0:231 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (klock.android[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Abhilash Jindal , computersforpeace@gmail.com, dwmw2@infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Wall time obtained from do_gettimeofday is susceptible to sudden jumps due to user setting the time or due to NTP. Boot time is constantly increasing time better suited for comparing two timestamps. Signed-off-by: Abhilash Jindal --- drivers/mtd/tests/speedtest.c | 9 ++++----- drivers/mtd/tests/torturetest.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c index 5a6f31a..854b707 100644 --- a/drivers/mtd/tests/speedtest.c +++ b/drivers/mtd/tests/speedtest.c @@ -49,7 +49,7 @@ static int pgsize; static int ebcnt; static int pgcnt; static int goodebcnt; -static struct timeval start, finish; +static ktime_t start, finish; static int multiblock_erase(int ebnum, int blocks) { @@ -168,12 +168,12 @@ static int read_eraseblock_by_2pages(int ebnum) static inline void start_timing(void) { - do_gettimeofday(&start); + start = ktime_get_boottime(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get_boottime(); } static long calc_speed(void) @@ -181,8 +181,7 @@ static long calc_speed(void) uint64_t k; long ms; - ms = (finish.tv_sec - start.tv_sec) * 1000 + - (finish.tv_usec - start.tv_usec) / 1000; + ms = ktime_to_ms(ktime_sub(finish, start)); if (ms == 0) return 0; k = (uint64_t)goodebcnt * (mtd->erasesize / 1024) * 1000; diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c index e5d6e6d..228023a 100644 --- a/drivers/mtd/tests/torturetest.c +++ b/drivers/mtd/tests/torturetest.c @@ -79,18 +79,18 @@ static unsigned char *check_buf; static unsigned int erase_cycles; static int pgsize; -static struct timeval start, finish; +static ktime_t start, finish; static void report_corrupt(unsigned char *read, unsigned char *written); static inline void start_timing(void) { - do_gettimeofday(&start); + start = ktime_get_boottime(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get_boottime(); } /* @@ -333,8 +333,7 @@ static int __init tort_init(void) long ms; stop_timing(); - ms = (finish.tv_sec - start.tv_sec) * 1000 + - (finish.tv_usec - start.tv_usec) / 1000; + ms = ktime_to_ms(ktime_sub(finish, start)); pr_info("%08u erase cycles done, took %lu " "milliseconds (%lu seconds)\n", erase_cycles, ms, ms / 1000);