From patchwork Fri Oct 1 18:12:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12531501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 113F4C4167E for ; Fri, 1 Oct 2021 18:13:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B6EF061263 for ; Fri, 1 Oct 2021 18:13:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B6EF061263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 62A44940137; Fri, 1 Oct 2021 14:13:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DABF940121; Fri, 1 Oct 2021 14:13:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42F20940137; Fri, 1 Oct 2021 14:13:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 2F1D7940121 for ; Fri, 1 Oct 2021 14:13:35 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E195D39F32 for ; Fri, 1 Oct 2021 18:13:34 +0000 (UTC) X-FDA: 78648666348.03.A898B7D Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf14.hostedemail.com (Postfix) with ESMTP id A20C560020B2 for ; Fri, 1 Oct 2021 18:13:34 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id m26so8675723pff.3 for ; Fri, 01 Oct 2021 11:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nVIr7fAkmnLGTRIKArO4HwVYW8hhJ6BbGtxi7VDtm5A=; b=lXUp+9Od6M9S7RMSuyxanM1yWQdtqC/AAe7iCxUfxH5DloVmZDQvD82Sabbs/qyw9R ynsF5bWEKRhOTucr2rTKbZQrWUa+3zXZGEfJb04wFCvSuanSqEjvaPL/x7NgydXf1w4D sqJr/YEIMA/aki34Oa0SUg5p0Ppo4iyBjEu3WDOlO82iqwIWsHk8Ap8yIrvubxOcX7wG kVOYysbel/UUwGrE+M4YEq5uOdfdgJ6QTNnUvKjK5v+HsuNyABf6I92g/BF8HSMRUmib eh9kWw/GQs710NIV4/g6xgE2F0P8nXTEjlIZKT14nXMSgLJi/nmaaw3V4UFsHw42zK70 hFBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nVIr7fAkmnLGTRIKArO4HwVYW8hhJ6BbGtxi7VDtm5A=; b=A/rsHRIKqGYnjf3UNtyDy+kObALiROfBBSqEus88yP9OSklaFFIgWYfDPxr6qOnEFT CdqcR67MS9Tf1Iowy1YmR4v0aXd58E9WZSnebRJ2ahRrGiSUrdRjCoGxtRH32AngxM8e 5MNi767JwDCPrPXDqukwhCWFEhB3PQvkgZ5HTwuhOdmbafVqusp2973jN8Lf8YuwCWHa HqG7+r+30XU8/Ge7cnS2fnJNdnvf6lIxINJ7dbxzwqB4fzielGM1/WfBPrMx5UDi3fBJ wuRk9KK+FH8MRZBc6VeJtBgderkoZ3jP63JOIIbkbNSM6XXlaJ3lCHSH0zuzi5nHCgz1 T6jQ== X-Gm-Message-State: AOAM530G5uNjdVpcabkbluGuvQjC6FqMshEFp8i1Pi6gKDEVQYUTi1v2 iuZviFqHXpm+2734I5kVyOs= X-Google-Smtp-Source: ABdhPJzWkripl8R4xiRIMids26DEF1LJPZrHGTjf4Zs5yvcfXJTwuCiC6dmRuUe/1X1O9TG0db8Q6g== X-Received: by 2002:a62:3383:0:b0:438:4b0d:e50e with SMTP id z125-20020a623383000000b004384b0de50emr11501138pfz.9.1633112013623; Fri, 01 Oct 2021 11:13:33 -0700 (PDT) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id 23sm8562335pjc.37.2021.10.01.11.13.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 11:13:33 -0700 (PDT) From: Yury Norov To: Stephen Rothwell Cc: Yury Norov , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mmc@vger.kernel.org, linux-perf-users@vger.kernel.org, kvm@vger.kernel.org, "James E.J. Bottomley" , Alexander Lobakin , Alexander Shishkin , Alexey Klimov , Andrea Merello , Andy Shevchenko , Arnaldo Carvalho de Melo , Arnd Bergmann , Ben Gardon , Benjamin Herrenschmidt , Brian Cain , Catalin Marinas , Christoph Lameter , Daniel Bristot de Oliveira , David Hildenbrand , Dennis Zhou , Geert Uytterhoeven , Heiko Carstens , Ian Rogers , Ingo Molnar , Jaegeuk Kim , Jakub Kicinski , Jiri Olsa , Joe Perches , Jonas Bonn , Leo Yan , Mark Rutland , Namhyung Kim , Palmer Dabbelt , Paolo Bonzini , Peter Xu , Peter Zijlstra , Petr Mladek , Rasmus Villemoes , Rich Felker , Samuel Mendoza-Jonas , Sean Christopherson , Sergey Senozhatsky , Shuah Khan , Stefan Kristiansson , Steven Rostedt , Tejun Heo , Thomas Bogendoerfer , Ulf Hansson , Will Deacon , Wolfram Sang , Yoshinori Sato Subject: [PATCH 15/16] lib: bitmap: add performance test for bitmap_print_to_pagebuf Date: Fri, 1 Oct 2021 11:12:44 -0700 Message-Id: <20211001181245.228419-16-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001181245.228419-1-yury.norov@gmail.com> References: <20211001181245.228419-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A20C560020B2 X-Stat-Signature: zuprw7g5cx6dims9f6ptjppe4bg6yhjo Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lXUp+9Od; spf=pass (imf14.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1633112014-478512 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Functional tests for bitmap_print_to_pagebuf() are provided in lib/test_printf.c. This patch adds performance test for a case of fully set bitmap. Signed-off-by: Yury Norov Tested-by: Wolfram Sang --- lib/test_bitmap.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index d33fa5a61b95..0c82f07f74fc 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -446,6 +446,42 @@ static void __init test_bitmap_parselist(void) } } +static void __init test_bitmap_printlist(void) +{ + unsigned long *bmap = kmalloc(PAGE_SIZE, GFP_KERNEL); + char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); + char expected[256]; + int ret, slen; + ktime_t time; + + if (!buf || !bmap) + goto out; + + memset(bmap, -1, PAGE_SIZE); + slen = snprintf(expected, 256, "0-%ld", PAGE_SIZE * 8 - 1); + if (slen < 0) + goto out; + + time = ktime_get(); + ret = bitmap_print_to_pagebuf(true, buf, bmap, PAGE_SIZE * 8); + time = ktime_get() - time; + + if (ret != slen + 1) { + pr_err("bitmap_print_to_pagebuf: result is %d, expected %d\n", ret, slen); + goto out; + } + + if (strncmp(buf, expected, slen)) { + pr_err("bitmap_print_to_pagebuf: result is %s, expected %s\n", buf, expected); + goto out; + } + + pr_err("bitmap_print_to_pagebuf: input is '%s', Time: %llu\n", buf, time); +out: + kfree(buf); + kfree(bmap); +} + static const unsigned long parse_test[] __initconst = { BITMAP_FROM_U64(0), BITMAP_FROM_U64(1), @@ -818,6 +854,7 @@ static void __init selftest(void) test_bitmap_arr32(); test_bitmap_parse(); test_bitmap_parselist(); + test_bitmap_printlist(); test_mem_optimisations(); test_for_each_set_clump8(); test_bitmap_cut();