From patchwork Mon Jul 19 02:17:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12384591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6CE8C636CE for ; Mon, 19 Jul 2021 02:18:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8A98361168 for ; Mon, 19 Jul 2021 02:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A98361168 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 32C1B6B012F; Sun, 18 Jul 2021 22:18:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BC1B6B0130; Sun, 18 Jul 2021 22:18:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F16C36B0131; Sun, 18 Jul 2021 22:18:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id CFA006B012F for ; Sun, 18 Jul 2021 22:18:12 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7E10E180882AF for ; Mon, 19 Jul 2021 02:18:11 +0000 (UTC) X-FDA: 78377727582.26.33667DE Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) by imf22.hostedemail.com (Postfix) with ESMTP id 2F41B1924 for ; Mon, 19 Jul 2021 02:18:11 +0000 (UTC) Received: by mail-qv1-f45.google.com with SMTP id w2so7629799qvh.13 for ; Sun, 18 Jul 2021 19:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F05MjF1EjPo9ALm7Ep9kFMbBo/dzAk/z9NhYdhgbLQU=; b=c2JnXWJDh86iqNrQ6XAfurPn8Ie54j98BTn8TjxSUeD7s2VhqxnTAPDTOaWsh/Jc8N OFH55XkPpYC2ZkF3rR0Mue2csD7bqk5bdHV/IqKmyPtq2iHFKOcRe5MysqBwR6ekRbm4 skimyqWhoJWEVo0FU1E8ofgjIghmwyuDm+aF9W5TN4Vg8izknB8DLlPJ9WVAl308AGgB XskN6a3h24i5tPll4sDkRqkESVOEgyJxW1+IqjqTfLgn2X5ljk7QTxnAisLlnwD9clyN /Lmd8rWgVe8ypGcdM4ubs6cuEYrkAC9rIJTL4U7zJVKPCH6LYe5OsRbL/BJ+X4evGqSU lHng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F05MjF1EjPo9ALm7Ep9kFMbBo/dzAk/z9NhYdhgbLQU=; b=Nb4zrUHb/Ss2H3akgn2L+UFPXZ20LZ3CLgYN61EE/kcEzx9MjEwKMMXCUBgb2H2uNq GDh0wm+g21jsD2BL9vAABgAm22KHfnqPs4D0mzjnoZSYHHdcAzMXbI+56h+oFiFSZ9LM UIVA3/QxBYSCPvVsvVUp044W9Hmlk8hC7afVnTTzZeWvMX/UHtL0/FoXSB9A9Xj0ldVA U5cGMymaSRJAG7jg1F+0so3lwbKEs8C8AxuhwvYU+FCSwm4SP2Ryqq43zTtp+Qr0H+cU flC+6N0jfF57RPkV8CLGBB4+XFezZx8uqRK4oa2fk2MoCaZ6AoDRTlf+jRRBJXwlkhnB O3Tw== X-Gm-Message-State: AOAM530/W6acOhVDBJ3JxDLeq4jjDHZplZKdeA4M75hDiVBy+im7OWC7 wQNyktckLye1/n9OlLcYEWM= X-Google-Smtp-Source: ABdhPJw5IaXLvY4GY3gixUsEQH1zgiCmVLiM4jB+jFuk8uQo1DBCTKt27AdmcwKgHMmo4ADCH4O/UQ== X-Received: by 2002:ad4:5c49:: with SMTP id a9mr13679048qva.27.1626661090504; Sun, 18 Jul 2021 19:18:10 -0700 (PDT) Received: from localhost ([207.98.216.60]) by smtp.gmail.com with ESMTPSA id k10sm54870qtp.76.2021.07.18.19.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jul 2021 19:18:10 -0700 (PDT) From: Yury Norov To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-mmc@vger.kernel.org Cc: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Petr Mladek , Sergey Senozhatsky , Tejun Heo , Steven Rostedt , Wolfram Sang , Ulf Hansson , Dennis Zhou , Christoph Lameter , Andrew Morton Subject: [PATCH 3/4] lib: bitmap: add performance test for bitmap_print_to_pagebuf Date: Sun, 18 Jul 2021 19:17:54 -0700 Message-Id: <20210719021755.883182-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210719021755.883182-1-yury.norov@gmail.com> References: <20210719021755.883182-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2F41B1924 X-Stat-Signature: ntixbsnogdye7d8js64e57nczua3m3ft Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=c2JnXWJD; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of yurynorov@gmail.com designates 209.85.219.45 as permitted sender) smtp.mailfrom=yurynorov@gmail.com X-HE-Tag: 1626661091-428538 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 --- lib/test_bitmap.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 4ea73f5aed41..452d525007da 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -430,6 +430,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), @@ -669,6 +705,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();