Received: by 10.223.164.202 with SMTP id h10csp2145629wrb; Fri, 24 Nov 2017 06:33:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMaW+4Uj9ldzqOjX0DdzImAiZ5ir2ywh1DzKXLJ6P8A3uM2AL2ngYLf8EuJnbDB2HMKT9K7u X-Received: by 10.98.13.8 with SMTP id v8mr27395698pfi.180.1511533989189; Fri, 24 Nov 2017 06:33:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511533989; cv=none; d=google.com; s=arc-20160816; b=H+xOclq5LANAvCJt9IZFGJrq7Tz9zU21MXk1OwwC6tK4HGOS09h6coQRjRZKOeLA/b b3SyUvEj2kzE/2nWhH2q5gqECVikotoqtfYhUzhDfxE5GZMf8go2TwM5N+dre1sRX4CU JC5EprFPvjplHzV8HrgeSPlxv6+AEZkFUs8HCFwSDTgjlDZXj6haGFoB1WpUATz/O0cf njIkCvHe0NK+7F4HYISWAUgdXiu+ap8XWn9g/cFUsB+P9kiZmE3x4O9XpTz5oIwbhHHL R4B2l7l3CwOk1UciE/p2/0wj4Lkl1icYuwyU3OA18GoPAsfCUOLAd+sdWP2UbpNmjUgR NzYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=Sx4A4t1wb8SRBeDV0tlQNkYBhc1Vx6O/OY6tuXIs/68=; b=sADDrjDAfB0E4zk12V2ZGplB9wZbu4P8Si/oWg3/+L4JjhKOPpRnamdJ9lOR/CzVSL S3xNivL7soFGgUXuajfLKtwn5B4HSzqA1DcjUq16Lb7vLulfaAnPkEBjgXNqzq9bHdhn UAGjUbZB02tliUGdnawT5BAqJy1PAD/I98AuA0ng5+44z2w4eGSnm93KYnNkXU2KK3w1 EiAz+fTWxEg499hlmTnvyBC/jwJdPtnHmsNPiNGTlf9xQqALcYnmw/FNuHdTW6AWdYEk TeA6b0t4FdHshrGMZe2REFrLAzzQMS14YV6uXiHzyZ4o0xEV/F5MnUVgUitn0m4PgzmW D39w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=lF9Bse0I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si2054179plc.342.2017.11.24.06.32.56; Fri, 24 Nov 2017 06:33:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=lF9Bse0I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753304AbdKXObA (ORCPT + 77 others); Fri, 24 Nov 2017 09:31:00 -0500 Received: from mail-co1nam03on0041.outbound.protection.outlook.com ([104.47.40.41]:2912 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752654AbdKXOa6 (ORCPT ); Fri, 24 Nov 2017 09:30:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Sx4A4t1wb8SRBeDV0tlQNkYBhc1Vx6O/OY6tuXIs/68=; b=lF9Bse0IsFsSnI5vlyt2iuDfXz71+yYg/3aQFpRWY4FioYK9Ed7+Ai2CXg0WzTs+8Ulueu2vz61yxAH/tmFO7JaATtHGRvEYJOtPXJ96XUHD6HwDQKZHVFBIouehwNAHbwS6DjPVHQPtfNinCpN9iZHEbb9XsanHUwx0ByKoSF0= Received: from localhost (42.107.64.116) by MWHPR0701MB3833.namprd07.prod.outlook.com (2603:10b6:301:7f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.260.4; Fri, 24 Nov 2017 14:30:55 +0000 Date: Fri, 24 Nov 2017 17:30:40 +0300 From: Yury Norov To: Geert Uytterhoeven Cc: "linux-kernel@vger.kernel.org" , Alexey Dobriyan , Andrew Morton , Clement Courbet , Matthew Wilcox , Rasmus Villemoes Subject: Re: [PATCH] lib: test module for find_*_bit() functions Message-ID: <20171124143040.a44jvhmnaiyedg2i@yury-thinkpad> References: <20171109140714.13168-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [42.107.64.116] X-ClientProxiedBy: VI1P189CA0011.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::24) To MWHPR0701MB3833.namprd07.prod.outlook.com (2603:10b6:301:7f::26) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199);SRVR:MWHPR0701MB3833; X-Microsoft-Exchange-Diagnostics: 1;MWHPR0701MB3833;3:4OMlxLX/F+/6xFzA9grYM44PRsaEALmHwD4pOow68/huAH2tgPVGapQ2/C/9mMWKzyC1IdMBdXOtYxExDJH4XK8/asr7agktLp3V3mrHsUzleTDpWjqLf5skIxOJiANtH/bGfBrxbaky9QVPUE3TBujzgKLDRgGGkTD7A5H9ijLBFaCyFiPzEGuM5QudWrz+61PqRyAWkid7vEYxcqcnjKRNa03MUztjErdBP90b5WTDiK/FEkeL/B/U541iYCy0;25:VNN3SKqF8cwXnxugrq1tIu4TC69RkeQq23Ozc+vKN2SwRtFGWf1ON8HM9vTNLtF6AP2kCdxn8DNdLjGCf2BbvdCpI9ByEm8LvUZT5D0HRY8AapfrG9YZ52AY0A9fJn0GEOKizchAcaBv6j7NqVLYWJo/vzQc/UU1/futSYye3bK8maqW/Q6tAHHkMtk1Cou0m8IRbWWxEMtWxpt4xeQ5aHPmz6BERAkzfMHFi5I4yg4nx24sxNP+YST5WGiLpWUvW46v4t1vfL7USdC6WBEkSd2p7R338orNPNQGJ5pIdBsdPk+ESVfbZsPcfLMTq7Ck2yUEfLeRMZqBfaaOvV5/cQ==;31:6lH5grWoIlLV/i8t13MCts4xWAyOKPw+0Rxl47araJchsDDVK8+MroXQXz8Qjq+sXw+mVgOw0/3DObvSaZcMvwNbRZgEDK2NbAxScc/S+HrhBuXMS5zrStfxPYcw3d5gzq4eC2GsyeeWxBWKUEj3jopjJ8wwOgvGyIvUFAMhhoYSnbUKJF3yJVBUSEpO5IEphk/yp9XFknsTNEb3uXdx1z2dM9u31ZIZNKSyKfVtYH0= X-MS-TrafficTypeDiagnostic: MWHPR0701MB3833: X-MS-Office365-Filtering-Correlation-Id: a7ef8ba8-8a67-4d91-cb08-08d53347f940 X-Microsoft-Exchange-Diagnostics: 1;MWHPR0701MB3833;20:D1DPpR6poIGAV6MmAnHgG+VnEFY01Xu6yH3YKcINkQeVHGLn2LIXCkHEw3pGbTp4ghT5bhKMXcVLThojEZx/AjX5ldaAjVuJiMo74NcN/VGxvyS0OGQlUzqqVLma7Tx84pAncy//tHuRhRzyINU40jNTmcQnxCi/sXmb2zrgtjh12J1inIY1m3QnHk0Y8klWBbRn5GdeUnTy861mnxo6/wZlmeu2Lql7GMVIVs/wnmth75SHuIrtSfo2l/Uycx+GsJEx4JMd6ieD52dUzJ1jRKCmPw5qGxdym2Nj/n7s3CYqWyPMZ1jHU0ct3hpLqHIS0ui0acwjj4NroARcmwIYNd+/yIuCWTcXoXugb47nDYZL8AR91jAldtzDvwkQfZ7BxleHIJUE57xa2ngGOtSfg8go/oKes+dvMcEZuThdY2dA2ZFIK46iEu5i2bZyJ66l5JDP/XtUowzD/6PJp1iZdbZGvV1k+5hcrr7iRa2NoxzNHd2h6RQK+kFzu+ro04LRGYJ6x2qE7eQrSrrUosRrLUX4+YURTmPBqHMhfAey4ymxjLbv99eu2aX/vf4IGglCfLVwRnmmalOf6lU+E0VwUOtQoreL4XIUcp/AcEUif3E=;4:ynT3WGN8iCvIzCNOsGGbQoV0KXrX3Bks49urGO5fFB61BWtd4Nr+ADi28ng8ZvOHhnJXUE0YYKfGP7FBlj1L2guNtZCxkrWIOgtjS7Zxm7izz3igAJDeNH/lRXbk+jvbuJZcEW+XaHyTMIM1NcutaC/E7K7mj+qhkjMXgVIXpPP2OXtXclFixYU5W8VNILM4sGQ9GexW8SPMo/oFx5x9VFmygmCfleQw3yfyyQ00yLePulArjk9mUxNBHXbujegTdV7/7LB9q9HlXKoA0Due2A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231022)(93006095)(6041248)(20161123558100)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(6072148)(201708071742011);SRVR:MWHPR0701MB3833;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:MWHPR0701MB3833; X-Forefront-PRVS: 05015EB482 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(7916004)(366004)(346002)(376002)(189002)(199003)(52116002)(53546010)(8936002)(5660300001)(2906002)(50466002)(16526018)(58126008)(316002)(16586007)(33716001)(83506002)(1076002)(23726003)(9686003)(3846002)(6116002)(54906003)(6496006)(25786009)(53936002)(478600001)(42882006)(6916009)(229853002)(5009440100003)(8666007)(6486002)(189998001)(72206003)(4326008)(6666003)(2950100002)(50986999)(76176999)(81166006)(54356999)(76506005)(81156014)(305945005)(6246003)(7736002)(97736004)(47776003)(33646002)(101416001)(106356001)(39060400002)(66066001)(68736007)(105586002)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR0701MB3833;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR0701MB3833;23:ZoCkiB/Jb6buPsDilRiNRhCF1ayGIrVKk43jVJg?= =?us-ascii?Q?EnHUnMz7vEZ5rvEOpHHF2V04+bkw61r8/hZ8WUAPTRbjo4/7pbFrpe3l0Guj?= =?us-ascii?Q?J1ShYwidbmVf9pWnuEG5RqXFkzjv2muU0xOYKr5IOA39GozedBswL4a3iBXI?= =?us-ascii?Q?cKhqRS6lC5T2/QepI7ZRa9qj8ldC0Roy0I9NqaEeECYnFbzMgbEur5wOzTuU?= =?us-ascii?Q?rzddG0x4K8njLIYeAAhmb7+rH4aocDu+S11hYQsdfuc7ot/1cY4ePLn5hZQA?= =?us-ascii?Q?bRXr4UnWYUF1hzf0wLrF9Z/bJWuaaGdfr8+JSzCD+t6LTNhEe6GmtRqcIC8S?= =?us-ascii?Q?BuV8q9SzZumO3lfobHI8m+DkLugWUhLlxihYzlMYIkneLfOlboYmJX1dwEHY?= =?us-ascii?Q?gXg3w1e5Z152CvSH+UFgKvAILjsgiM5TKvrD48qYy5ThuJmKW4XvC9dwCMc1?= =?us-ascii?Q?AkWXR8OEryVa35q2G0osbAyHSkUkxWaK2633DrJweTy8dFhuGKVrTsX8O9+S?= =?us-ascii?Q?vFz23x7c8uMi20JBqMuJwkN5ZuyeR6cNCd4uOs+C03ux7Z++DYz6o4FjXBQc?= =?us-ascii?Q?ULSEO+N+/c7dnV665bkNPIJN2gQfOS9b7HOVgYZK23y+4XZJsnHMsIYYdYcy?= =?us-ascii?Q?K0RBD0ocSMNnWHOfS+eMe0i8v91H22cjllvDn0Equ70Frtqz6V1XTiMRRymB?= =?us-ascii?Q?Qsaz+Vwkt9RNpombVQyH64jUy6H9r8DG2AwLQ3ed0DSCondJx4ud45nudrdC?= =?us-ascii?Q?OVruJSG0duY7m7rPvXL5jTjkDWpFyvKj24x8umyq7tMPDfti7VpLRagDHDUS?= =?us-ascii?Q?PJwfE3jSEnLOdOx6qL3/S6lw9ZvNyuFeASEGvQCTuKuTBEkTOMdkX5fPqJ9h?= =?us-ascii?Q?f13mSrsuZXcXuysUzvheQxqMTQ7Lm9gWdj5SQRAJ/Pm1zlfVPMi8IWyqEjLg?= =?us-ascii?Q?nbEH6BEyeJb/61uWuf4Nziux0YsQXoQTbyvZGfuk+vZ3qOhm2nCCdI6YKrWx?= =?us-ascii?Q?2C3cPtkwR1tOHEpJtrGc13oCMhZViiU8UKy79dE9jTspAZWffbfQWyd6MpXa?= =?us-ascii?Q?JDDdTR1lzDP7o6zGGAaGodSrkVS/NZRkPS5RV/WBEiv6MBPLcQjeVeqOnei+?= =?us-ascii?Q?wgXI9ANpysRY5yvDjetDZGsag/yvNoSAwZVVhHunVZhpbvbt5jolRlPJLgCX?= =?us-ascii?Q?i8o/Le9aSU7DL5nn2M8PgeTJukKV4IbXsddpvCecKeJm5F4NVGmd+jK6rMou?= =?us-ascii?Q?Dt0NVIi/wZDt+hVUTD4/glrwb/g/D/bBCXNCwKl/Q3l6MBFq6PGETZGhuD1R?= =?us-ascii?Q?7jwpypXzryLL/Gy4fROY8b2fD0Qh9CzzqoDHGRdJ0rXvnx9bPW1h0XUb7Rgt?= =?us-ascii?Q?KE/fKSh5CCBCyaZBThNpKDjfLNuY=3D?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR0701MB3833;6:u3p3SUDcIFBxViN05WjZoBn63HmmU0AaB77v80Aj2E2WkFEgl4+raM+Fe8EyDXRWr9oc+M4Am3kPDdkNRV9VCBp6+kyD/TtJsBhjdiPZ9ReH29LgOVn/iunWi+ALRCdg89tLFw/cgo1AUJSTuvWT7vqKee521D4YTmEQvAMIHOL2VTfUFKoLZpTuAbNJqTkVRTxtKVPMcXW+00eUyH+qUoigyvDCvaQp8ia3B1hXWWZZMYBl6n//+ZJ8Vlr3J1R6ma7sizcf7oyKi8AsjQAMc0nyZDMDOrdgu/DAYvf4IUegdq+y6SVMi+7nhy7VoBGRUkU3H8iKdhoqMl99VEeJ3Wj9Bx4RKhz2ZesrNx7Ub4M=;5:GkIDipSB2/027nR/rvaBrzatDJTcOe498ksgUs71+Dgq3S1UdcOh0Igb6Pt8HQoSnySeUmpVG33OZTbcumSUUnbuIZNFz8dSXC/963yjynHHxwJF0ru1hADILhE2UiS1cEUet19tOfxjWDUM8bLJDpIK2x3kfmHwBPIiGQuV4YU=;24:3+3fPGTRVxRSex8O8gfYZeoFJAcZI8ZMYS7KvVlOy8Ub8rz0mJG5qDIQNXkyFPnMVshZN4p+r+d0gJnmtahM5WVyTVpm1JNv0MtT9StPtyY=;7:tOktYH+/1agIOMKpoAqco7Qwlt5FY2usNvxnoQFO7Te1frVHccUqU81Ix5xR8KAsiV4k+DW+I1HhQqLybSO7j5m8n86x0KJ1F/9dgEFKdWG9R1RhKQQW6BVxQrxVqBJX8sSoYoSuTAQl57oZZy7UidDAQovBV0zS2PdzSQddoTE1ElffxOIgG61/0p0OiKJaus+h+/EHu6aPF4Qi1lo9XCmV8GBP+psPOUQtTC/lCA5U6QpuMdOVZDw374eRlkgJ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2017 14:30:55.2760 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7ef8ba8-8a67-4d91-cb08-08d53347f940 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0701MB3833 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Geert, all Below the updates proposed in this thread. Yury >From 959700bd7e7f586171c15a4130a9888acac02daf Mon Sep 17 00:00:00 2001 From: Yury Norov Date: Wed, 22 Nov 2017 17:21:40 +0300 Subject: [PATCH] improve lib/test_find_bit As suggested in review comments: * printk: align numbers using whitespaces instead of tabs; * return error value from init() to avoid calling rmmod if testing again; * use ktime_get instead of get_cycles as some arches don't support it; * rename test_find_bit.c to find_bit_benchmark.c. The output in dmesg (on QEMU arm64): [ 38.823430] Start testing find_bit() with random-filled bitmap [ 38.845358] find_next_bit: 20138448 ns, 163968 iterations [ 38.856217] find_next_zero_bit: 10615328 ns, 163713 iterations [ 38.863564] find_last_bit: 7111888 ns, 163967 iterations [ 40.944796] find_first_bit: 2081007216 ns, 163968 iterations [ 40.944975] [ 40.944975] Start testing find_bit() with sparse bitmap [ 40.945268] find_next_bit: 73216 ns, 656 iterations [ 40.967858] find_next_zero_bit: 22461008 ns, 327025 iterations [ 40.968047] find_last_bit: 62320 ns, 656 iterations [ 40.978060] find_first_bit: 9889360 ns, 656 iterations Signed-off-by: Yury Norov --- lib/Kconfig.debug | 2 +- lib/Makefile | 2 +- lib/{test_find_bit.c => find_bit_benchmark.c} | 47 ++++++++++++--------------- 3 files changed, 23 insertions(+), 28 deletions(-) rename lib/{test_find_bit.c => find_bit_benchmark.c} (79%) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 138034cc68a3..1c57c36ad79a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1838,7 +1838,7 @@ config TEST_BPF If unsure, say N. -config TEST_FIND_BIT +config FIND_BIT_BENCHMARK tristate "Test find_bit functions" default n help diff --git a/lib/Makefile b/lib/Makefile index 97ec69d843f2..1688cc84536e 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -45,8 +45,8 @@ obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o obj-y += hexdump.o obj-$(CONFIG_TEST_HEXDUMP) += test_hexdump.o obj-y += kstrtox.o +obj-$(CONFIG_FIND_BIT_BENCHMARK) += find_bit_benchmark.o obj-$(CONFIG_TEST_BPF) += test_bpf.o -obj-$(CONFIG_TEST_FIND_BIT) += test_find_bit.o obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o obj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o obj-$(CONFIG_TEST_HASH) += test_hash.o test_siphash.o diff --git a/lib/test_find_bit.c b/lib/find_bit_benchmark.c similarity index 79% rename from lib/test_find_bit.c rename to lib/find_bit_benchmark.c index f4394a36f9aa..67b19233c28f 100644 --- a/lib/test_find_bit.c +++ b/lib/find_bit_benchmark.c @@ -43,16 +43,15 @@ static DECLARE_BITMAP(bitmap, BITMAP_LEN) __initdata; static int __init test_find_first_bit(void *bitmap, unsigned long len) { unsigned long i, cnt; - cycles_t cycles; + ktime_t time; - cycles = get_cycles(); + time = ktime_get(); for (cnt = i = 0; i < len; cnt++) { i = find_first_bit(bitmap, len); __clear_bit(i, bitmap); } - cycles = get_cycles() - cycles; - pr_err("find_first_bit:\t\t%llu cycles,\t%ld iterations\n", - (u64)cycles, cnt); + time = ktime_get() - time; + pr_err("find_first_bit: %18llu ns, %6ld iterations\n", time, cnt); return 0; } @@ -60,14 +59,13 @@ static int __init test_find_first_bit(void *bitmap, unsigned long len) static int __init test_find_next_bit(const void *bitmap, unsigned long len) { unsigned long i, cnt; - cycles_t cycles; + ktime_t time; - cycles = get_cycles(); + time = ktime_get(); for (cnt = i = 0; i < BITMAP_LEN; cnt++) i = find_next_bit(bitmap, BITMAP_LEN, i) + 1; - cycles = get_cycles() - cycles; - pr_err("find_next_bit:\t\t%llu cycles,\t%ld iterations\n", - (u64)cycles, cnt); + time = ktime_get() - time; + pr_err("find_next_bit: %18llu ns, %6ld iterations\n", time, cnt); return 0; } @@ -75,14 +73,13 @@ static int __init test_find_next_bit(const void *bitmap, unsigned long len) static int __init test_find_next_zero_bit(const void *bitmap, unsigned long len) { unsigned long i, cnt; - cycles_t cycles; + ktime_t time; - cycles = get_cycles(); + time = ktime_get(); for (cnt = i = 0; i < BITMAP_LEN; cnt++) i = find_next_zero_bit(bitmap, len, i) + 1; - cycles = get_cycles() - cycles; - pr_err("find_next_zero_bit:\t%llu cycles,\t%ld iterations\n", - (u64)cycles, cnt); + time = ktime_get() - time; + pr_err("find_next_zero_bit: %18llu ns, %6ld iterations\n", time, cnt); return 0; } @@ -90,9 +87,9 @@ static int __init test_find_next_zero_bit(const void *bitmap, unsigned long len) static int __init test_find_last_bit(const void *bitmap, unsigned long len) { unsigned long l, cnt = 0; - cycles_t cycles; + ktime_t time; - cycles = get_cycles(); + time = ktime_get(); do { cnt++; l = find_last_bit(bitmap, len); @@ -100,9 +97,8 @@ static int __init test_find_last_bit(const void *bitmap, unsigned long len) break; len = l; } while (len); - cycles = get_cycles() - cycles; - pr_err("find_last_bit:\t\t%llu cycles,\t%ld iterations\n", - (u64)cycles, cnt); + time = ktime_get() - time; + pr_err("find_last_bit: %18llu ns, %6ld iterations\n", time, cnt); return 0; } @@ -132,13 +128,12 @@ static int __init find_bit_test(void) test_find_last_bit(bitmap, BITMAP_LEN); test_find_first_bit(bitmap, BITMAP_LEN); - return 0; + /* + * Everything is OK. Return error just to let user run benchmark + * again without annoying rmmod. + */ + return -EINVAL; } module_init(find_bit_test); -static void __exit test_find_bit_cleanup(void) -{ -} -module_exit(test_find_bit_cleanup); - MODULE_LICENSE("GPL"); -- 2.11.0 From 1584664216319012584@xxx Tue Nov 21 08:39:23 +0000 2017 X-GM-THRID: 1583597789320519869 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread