From patchwork Thu Dec 18 03:23:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 42402 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2E2FB26C8B for ; Thu, 18 Dec 2014 03:24:15 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id q1sf178793lam.6 for ; Wed, 17 Dec 2014 19:24:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=fVuBUXJqzrszLor5c8dc9LkAPLu4+g5dXuYiY/G/Bhg=; b=S5G9jNWWe1YGeAP91DXO6w5NDrLiGtD91MT8ZpZoLqcFMc951CQHlyw7IpiqD76Esr JYZ2FKzIAiS30yQI7AII7inadUuwbqVctr6i4fP9+ACPj3/LR1oJty8HZ+a2GTJJ8r3u WNxhobijbtui6tpxHVPbUxEEQh7AW4HwCJU6u5+DC27IPUPEsXqykwxoUhJX2xVM9BLS ZAbUlR77hFP5B+IPRwI9exc7JcxBtJjTeZYVmf8RIEwzZN71QLO1lDgGrVevCDEfL8BE H1o74u5vNR/gEaBz005gL7vqtgH5YtpaWRekTA6GVuZrBUGmvkK+okgJlCAaSbNSMhv9 +iGA== X-Gm-Message-State: ALoCoQlo68yOA8GZzPEWHqo3yAZO+cp4BJHjFgan/tkBcjjV3hU1aZFoNESFJDrKduau4Vq6+1/A X-Received: by 10.152.37.193 with SMTP id a1mr2673454lak.3.1418873054144; Wed, 17 Dec 2014 19:24:14 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.169 with SMTP id x9ls746610lad.109.gmail; Wed, 17 Dec 2014 19:24:13 -0800 (PST) X-Received: by 10.112.16.129 with SMTP id g1mr39762634lbd.30.1418873053801; Wed, 17 Dec 2014 19:24:13 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id q13si5598048laa.27.2014.12.17.19.24.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Dec 2014 19:24:13 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so276434lab.36 for ; Wed, 17 Dec 2014 19:24:13 -0800 (PST) X-Received: by 10.152.25.129 with SMTP id c1mr45046323lag.9.1418873053634; Wed, 17 Dec 2014 19:24:13 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp1569758lbb; Wed, 17 Dec 2014 19:24:12 -0800 (PST) X-Received: by 10.67.24.66 with SMTP id ig2mr60803055pad.87.1418873051415; Wed, 17 Dec 2014 19:24:11 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ib3si8245611pad.102.2014.12.17.19.24.10; Wed, 17 Dec 2014 19:24:11 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751895AbaLRDYI (ORCPT + 27 others); Wed, 17 Dec 2014 22:24:08 -0500 Received: from mail-pd0-f182.google.com ([209.85.192.182]:38326 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751372AbaLRDYG (ORCPT ); Wed, 17 Dec 2014 22:24:06 -0500 Received: by mail-pd0-f182.google.com with SMTP id p10so453649pdj.41 for ; Wed, 17 Dec 2014 19:24:05 -0800 (PST) X-Received: by 10.68.172.1 with SMTP id ay1mr69239175pbc.100.1418873045567; Wed, 17 Dec 2014 19:24:05 -0800 (PST) Received: from chunyanzhangubtpc.spreadtrum.com ([203.160.240.81]) by mx.google.com with ESMTPSA id ut7sm5279251pbc.8.2014.12.17.19.24.00 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Dec 2014 19:24:04 -0800 (PST) From: Chunyan Zhang To: dwmw2@infradead.org, computersforpeace@gmail.com Cc: arnd@linaro.org, john.stultz@linaro.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, zhang.lyra@gmail.com Subject: [PATCH v3] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c Date: Thu, 18 Dec 2014 11:23:31 +0800 Message-Id: <1418873011-4974-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhang.chunyan@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch changes the 32-bit time type (timeval) to the 64-bit one (ktime_t), since 32-bit time types will break in the year 2038. I use ktime_t instead of timeval to define 'start' and 'finish' which are used to get the time for tow points. This patch also changes do_gettimeofday() to ktime_get() accordingly, since ktime_get returns a ktime_t, but do_gettimeofday returns a struct timeval, and the other reason is that ktime_get() uses the monotonic clock. This patch is based on another patch which privides a millisecond time difference function 'ktime_ms_delta' in ktime.h http://lkml.iu.edu//hypermail/linux/kernel/1412.2/00625.html Signed-off-by: Chunyan Zhang Reviewed-by: Arnd Bergmann --- Changes since v2: - Use the new function ktime_ms_delta which is added in another patch listed up. Changes since v1: - Add including in torturetest.c --- drivers/mtd/tests/speedtest.c | 10 +++++----- drivers/mtd/tests/torturetest.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c index 5ee9f70..87a6e25 100644 --- a/drivers/mtd/tests/speedtest.c +++ b/drivers/mtd/tests/speedtest.c @@ -22,6 +22,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -49,7 +50,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 +169,12 @@ static int read_eraseblock_by_2pages(int ebnum) static inline void start_timing(void) { - do_gettimeofday(&start); + start = ktime_get(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get(); } static long calc_speed(void) @@ -181,8 +182,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_ms_delta(finish, start); if (ms == 0) return 0; k = goodebcnt * (mtd->erasesize / 1024) * 1000; diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c index eeab969..7e77ed4 100644 --- a/drivers/mtd/tests/torturetest.c +++ b/drivers/mtd/tests/torturetest.c @@ -26,6 +26,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -79,18 +80,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(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get(); } /* @@ -322,8 +323,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_ms_delta(finish, start); pr_info("%08u erase cycles done, took %lu " "milliseconds (%lu seconds)\n", erase_cycles, ms, ms / 1000);