Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753464AbcFQOiE (ORCPT ); Fri, 17 Jun 2016 10:38:04 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:57927 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbcFQOiB (ORCPT ); Fri, 17 Jun 2016 10:38:01 -0400 From: Arnd Bergmann To: "David S . Miller" , Andrew Morton Cc: Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH] crc32: use ktime_get_ns for measurement Date: Fri, 17 Jun 2016 16:39:18 +0200 Message-Id: <20160617143932.3289626-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:ryZPDY2jYLvH2JtzZGXqNbX1y3Km3AvOpbiPUZ8EH0WfGByjNyv I1nLgHQgrqlYK+sj66I9z/bdr21fdUv0usiD5kGHjqgqNk0yZbFXueYK7R8ldooVVSueAwZ +BtboaL4pS322dOmsjcCV1neoK/XMpaGbn+4/G4i/ysplj2dHkJuVg06jeYOCPs39tHZ9nR 6K6Nh1TlGIJC+u8GYLCGg== X-UI-Out-Filterresults: notjunk:1;V01:K0:NUVonK81jXk=:EzPoT36h5NsQyzmTLMHS21 cAB8gDCSnUQTw91/0PHIJcBOM+Djt9rsFK7NPlBM6Tm7bTpB015NE45QY773/3XQFKALe0dxy bl2le1yRVgRFoOPT13pzFtyW+jZ7MVISR70XMBn1VOM0AaqMLDWdzUsaPzp74jo9Iy36OngdO ggSp6DxjzgZFt0klLqkm5mAsOxxiO1yJyudg5scIXNcezX5vQlEm5iIH2ShrU68+XuANX/Nkx dTo1qD8dTC7ojOZsuA3dvVkEhxaZiu8hgqjP1gtlITbLCKnZ8OcaHxPmP13isxga/Tda1cMAV Wfs0rxSJ/VwiJ8oGGDtbYygjsU6cIDgkLzNq7Ztv83B/kJqPkWPAQiUcVDQwZJrf1ZcOMf4ip bbIZatPymqpYOkBRpqgKfgipy22R9bWW5TkYqU3i4CovkS4z8KFEwdObr4ueZG8VjLPDMtqjO bjCmlHrJYXERByMrguHj+fEK4AXsbBoyXLRfWc1yYz90w+QmswsT9cNexj5eKkwNH7eaZ1VHr AOZatfENkMXyR+BXbxDZSNBDbQ4gEuuwJWanq/ewXC+WGJ99qvD15JpTkF2hbttBEuQcendD3 6kfUE1TAv9ky+GizmJzvA2mjpWtUnibcIdEgtb6XWO6p1TzIVGP/PK/WEXESKKxx0KXfCazYP Q8nnsXvut5ozBz9/VfK+0r90asBM8c7D5x4LtIVzgZMOwmoz0u+zAItu7ZUmsFG6bUu4= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The crc32 test function measures the elapsed time in nanoseconds, but uses 'struct timespec' for that. We want to remove timespec from the kernel for y2038 compatibility, and ktime_get_ns() also helps make the code simpler here. It is also slightly better to use monontonic time, as we are only interested in the time difference. Signed-off-by: Arnd Bergmann --- lib/crc32.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) Not sure who'd pick up this patch, both David Miller and Andrew Morton have taken patches for this file in the past, but nobody is listed in the maintainers file. diff --git a/lib/crc32.c b/lib/crc32.c index 9a907d489d95..7fbd1a112b9d 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -979,7 +979,6 @@ static int __init crc32c_test(void) int i; int errors = 0; int bytes = 0; - struct timespec start, stop; u64 nsec; unsigned long flags; @@ -999,20 +998,17 @@ static int __init crc32c_test(void) local_irq_save(flags); local_irq_disable(); - getnstimeofday(&start); + nsec = ktime_get_ns(); for (i = 0; i < 100; i++) { if (test[i].crc32c_le != __crc32c_le(test[i].crc, test_buf + test[i].start, test[i].length)) errors++; } - getnstimeofday(&stop); + nsec = ktime_get_ns() - nsec; local_irq_restore(flags); local_irq_enable(); - nsec = stop.tv_nsec - start.tv_nsec + - 1000000000 * (stop.tv_sec - start.tv_sec); - pr_info("crc32c: CRC_LE_BITS = %d\n", CRC_LE_BITS); if (errors) @@ -1065,7 +1061,6 @@ static int __init crc32_test(void) int i; int errors = 0; int bytes = 0; - struct timespec start, stop; u64 nsec; unsigned long flags; @@ -1088,7 +1083,7 @@ static int __init crc32_test(void) local_irq_save(flags); local_irq_disable(); - getnstimeofday(&start); + nsec = ktime_get_ns(); for (i = 0; i < 100; i++) { if (test[i].crc_le != crc32_le(test[i].crc, test_buf + test[i].start, test[i].length)) @@ -1098,14 +1093,11 @@ static int __init crc32_test(void) test[i].start, test[i].length)) errors++; } - getnstimeofday(&stop); + nsec = ktime_get_ns() - nsec; local_irq_restore(flags); local_irq_enable(); - nsec = stop.tv_nsec - start.tv_nsec + - 1000000000 * (stop.tv_sec - start.tv_sec); - pr_info("crc32: CRC_LE_BITS = %d, CRC_BE BITS = %d\n", CRC_LE_BITS, CRC_BE_BITS); -- 2.9.0