From patchwork Fri Sep 6 07:36:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13793535 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94E5DCE7AE0 for ; Fri, 6 Sep 2024 07:43:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DA926B009C; Fri, 6 Sep 2024 03:43:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 411836B009D; Fri, 6 Sep 2024 03:43:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28B636B009E; Fri, 6 Sep 2024 03:43:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 085216B009C for ; Fri, 6 Sep 2024 03:43:06 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B4BD441005 for ; Fri, 6 Sep 2024 07:43:05 +0000 (UTC) X-FDA: 82533522330.07.86E05AC Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf30.hostedemail.com (Postfix) with ESMTP id 4654E80016 for ; Fri, 6 Sep 2024 07:43:02 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725608504; a=rsa-sha256; cv=none; b=qnPLA7Ww3+cco9CcTDOztD/Gm7CzHHxfy7AJcPq6IPUbQoTkuZY+k5hiyT5Tyj05MNyYWV Is1LZCzBbDKXBhE7cgr7fh/Gwo7eIawhb02WbjNDFKlpM6PbqOipQ5TcpYJurB2eAG1aGG 2uBfgWzUYfL5kDP112ijhGe8KJrzYx4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725608504; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dPXY15X/d6Jk2gv8dJgifbFkwOJQaGu5Vqiv5kv7lTM=; b=FYeP7DPFlCqBOoHXFcy79owK3aPRgNCUIj9CTmYL6uHYOq/qjIxMQzJNBXTkdZQJssi1Lx Z/W+n9++QRoaFqW6ETzhHu0J+X9e45yLEeeb/YYp5RcG57n44DGWpgO6jTpMgylrmyQU6m XzKdTwgMSTlHISa2/ii1a95mxqpTny8= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4X0SqD2R1kz1P9HM; Fri, 6 Sep 2024 15:42:00 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id 344891800FE; Fri, 6 Sep 2024 15:43:00 +0800 (CST) Received: from localhost.localdomain (10.90.30.45) by dggpemf200006.china.huawei.com (7.185.36.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 6 Sep 2024 15:42:59 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Andrew Morton , Shuah Khan , , Subject: [PATCH net-next v18 11/14] mm: page_frag: add testing for the newly added prepare API Date: Fri, 6 Sep 2024 15:36:43 +0800 Message-ID: <20240906073646.2930809-12-linyunsheng@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240906073646.2930809-1-linyunsheng@huawei.com> References: <20240906073646.2930809-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.30.45] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemf200006.china.huawei.com (7.185.36.61) X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4654E80016 X-Stat-Signature: 4prpxhbu5ehya7dsb8aesf6anqeaif75 X-Rspam-User: X-HE-Tag: 1725608582-991736 X-HE-Meta: U2FsdGVkX19uRgp3G2HZ6tYgC5mpF+hhlE53+/1B3LmP8r8UelVeEGNIfehoWhDv9QHmJiQ0TKCsE725GQf0/9ocz87D8cf7Nc4B0zZY5uwYZHQ7iw9VCYD9lHyJKyD9bllXGBw4bCpwfwDf2z4hVs8VijYsYTRFMg1RhOQ4DQOQBpUJsX+Zixjy8Okv1M16USWgtGWtYA+1QRvjdEcB1m+mmj2PoQ8C8UEgHkBEuIQCJANABwwMGd8/cbDk0FeU+UPpSu1Aw6Uk3u1iISRPygEpQSUnvOl0yVf5hzgNtDDAMPUD2cd9Pfn2UvC7Z8bUuuBA3NSUNGEkuAS+j0RFUviAKB8AMosnoxBRAJr1BDgBDVZtMEgwXUekyaqPLJQPMvV6D50j1lht41AnQnLQgEQOPL5eJwro+qCQ7/i051HbGT3x4LLvaa54uHBJOa6WwaDbJKprPMYaExKgkAgXwfwhJV20R9X0Ht5a4oCdSBwBc29bX0cScqp3ADCY4eUoBaG9SC1VhJPKfWdgTh4s0gZ6ScjcNMpMyEpnDm/oHjbc5dOzhzrD/m+rnPOHAkHttmZTZb6UO/m1Ggp520bd/iii5w8Ym9R0ljAsRdowiqN8sm/qBWg8X/KS4sV9zMGto5PpDbATlrlNCsyX4BcScNoK8TFkan/B36T0wvxzVH1fV5gOFVg8TxQEA8RypLRrz1UXvjDaBVCNJrh/6r6sVN7lAkBeNDP10pB5JEQMfyY/IBGKX5pve8tshElJezVuV2t3xvKr4z/BxAaIk8HLr81EkDEC/W7e9XHtbPanPwAOTc+fUvZ8VLedEHpJ8C0lq0Y9pBoohctkn4lrjXJ6hlJFO808QFQvwNg9MzmFQjJDPQSY3y8KwX59eAwERnj7M91QYdk76Fu7EfkKx43tWq6rxEGwnBoPtILGc3Li41CdmDM9clt4+bYA7p2vxZY2bRa4rqgSIF7G2Q6UUKz zBitzdQS WcirzYcrZ11mQwz77VVqShUGRIRLjvLb43MJr6cxLEkjAVM8NjQm3KVPRbJzzITc2O9yO8ps0VnlXihvFfeX5hY90SDI+aH1bXvC1rdYPa3kkmhCEjOw9I11ZLv8wliItk711yPt1HfqMK366P6c0II504CPetJ2iC+Lu3qmRFkH6fVocAFpcaj8PhUaiv6FyTbIxaGq/8nV+8OIRJE4LlUQAO2DheMQz2ykTBXniQfyrRLSODOlzYDS6IXtgSg1km0kuG1PDj74VV863t1kpYCjXG6W4AFDZpOlJ 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: List-Subscribe: List-Unsubscribe: Add testing for the newly added prepare API, for both aligned and non-aligned API, also probe API is also tested along with prepare API. CC: Alexander Duyck Signed-off-by: Yunsheng Lin --- .../selftests/mm/page_frag/page_frag_test.c | 66 +++++++++++++++++-- tools/testing/selftests/mm/run_vmtests.sh | 4 ++ tools/testing/selftests/mm/test_page_frag.sh | 31 +++++++++ 3 files changed, 96 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/mm/page_frag/page_frag_test.c b/tools/testing/selftests/mm/page_frag/page_frag_test.c index a4bd543d6950..7cfa896f69cb 100644 --- a/tools/testing/selftests/mm/page_frag/page_frag_test.c +++ b/tools/testing/selftests/mm/page_frag/page_frag_test.c @@ -27,6 +27,10 @@ static bool test_align; module_param(test_align, bool, 0); MODULE_PARM_DESC(test_align, "use align API for testing"); +static bool test_prepare; +module_param(test_prepare, bool, 0); +MODULE_PARM_DESC(test_prepare, "use prepare API for testing"); + static int test_alloc_len = 2048; module_param(test_alloc_len, int, 0); MODULE_PARM_DESC(test_alloc_len, "alloc len for testing"); @@ -67,6 +71,18 @@ static int page_frag_pop_thread(void *arg) return 0; } +static void frag_frag_test_commit(struct page_frag_cache *nc, + struct page_frag *prepare_pfrag, + struct page_frag *probe_pfrag, + unsigned int used_sz) +{ + WARN_ON_ONCE(prepare_pfrag->page != probe_pfrag->page || + prepare_pfrag->offset != probe_pfrag->offset || + prepare_pfrag->size != probe_pfrag->size); + + page_frag_commit(nc, prepare_pfrag, used_sz); +} + static int page_frag_push_thread(void *arg) { struct ptr_ring *ring = arg; @@ -80,13 +96,52 @@ static int page_frag_push_thread(void *arg) int ret; if (test_align) { - va = page_frag_alloc_align(&test_nc, test_alloc_len, - GFP_KERNEL, SMP_CACHE_BYTES); + if (test_prepare) { + struct page_frag prepare_frag, probe_frag; + void *probe_va; + + va = page_frag_alloc_refill_prepare_align(&test_nc, + test_alloc_len, + &prepare_frag, + GFP_KERNEL, + SMP_CACHE_BYTES); + + probe_va = __page_frag_alloc_refill_probe_align(&test_nc, + test_alloc_len, + &probe_frag, + -SMP_CACHE_BYTES); + WARN_ON_ONCE(va != probe_va); + + if (likely(va)) + frag_frag_test_commit(&test_nc, &prepare_frag, + &probe_frag, test_alloc_len); + } else { + va = page_frag_alloc_align(&test_nc, + test_alloc_len, + GFP_KERNEL, + SMP_CACHE_BYTES); + } WARN_ONCE((unsigned long)va & (SMP_CACHE_BYTES - 1), "unaligned va returned\n"); } else { - va = page_frag_alloc(&test_nc, test_alloc_len, GFP_KERNEL); + if (test_prepare) { + struct page_frag prepare_frag, probe_frag; + void *probe_va; + + va = page_frag_alloc_refill_prepare(&test_nc, test_alloc_len, + &prepare_frag, GFP_KERNEL); + + probe_va = page_frag_alloc_refill_probe(&test_nc, test_alloc_len, + &probe_frag); + + WARN_ON_ONCE(va != probe_va); + if (likely(va)) + frag_frag_test_commit(&test_nc, &prepare_frag, + &probe_frag, test_alloc_len); + } else { + va = page_frag_alloc(&test_nc, test_alloc_len, GFP_KERNEL); + } } if (!va) @@ -149,8 +204,9 @@ static int __init page_frag_test_init(void) wait_for_completion(&wait); duration = (u64)ktime_us_delta(ktime_get(), start); - pr_info("%d of iterations for %s testing took: %lluus\n", nr_test, - test_align ? "aligned" : "non-aligned", duration); + pr_info("%d of iterations for %s %s API testing took: %lluus\n", nr_test, + test_align ? "aligned" : "non-aligned", + test_prepare ? "prepare" : "alloc", duration); ptr_ring_cleanup(&ptr_ring, NULL); page_frag_cache_drain(&test_nc); diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 96fd470b9f51..e4a36231bbea 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -464,6 +464,10 @@ CATEGORY="page_frag" run_test ./test_page_frag.sh aligned CATEGORY="page_frag" run_test ./test_page_frag.sh nonaligned +CATEGORY="page_frag" run_test ./test_page_frag.sh aligned_prepare + +CATEGORY="page_frag" run_test ./test_page_frag.sh nonaligned_prepare + echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}" | tap_prefix echo "1..${count_total}" | tap_output diff --git a/tools/testing/selftests/mm/test_page_frag.sh b/tools/testing/selftests/mm/test_page_frag.sh index d750d910c899..71c3531fa38e 100755 --- a/tools/testing/selftests/mm/test_page_frag.sh +++ b/tools/testing/selftests/mm/test_page_frag.sh @@ -36,6 +36,8 @@ ksft_skip=4 SMOKE_PARAM="test_push_cpu=$TEST_CPU_0 test_pop_cpu=$TEST_CPU_1" NONALIGNED_PARAM="$SMOKE_PARAM test_alloc_len=75 nr_test=$NR_TEST" ALIGNED_PARAM="$NONALIGNED_PARAM test_align=1" +NONALIGNED_PREPARE_PARAM="$NONALIGNED_PARAM test_prepare=1" +ALIGNED_PREPARE_PARAM="$ALIGNED_PARAM test_prepare=1" check_test_requirements() { @@ -74,6 +76,24 @@ run_aligned_check() echo "Check the kernel ring buffer to see the summary." } +run_nonaligned_prepare_check() +{ + echo "Run performance tests to evaluate how fast nonaligned prepare API is." + + insmod $DRIVER $NONALIGNED_PREPARE_PARAM > /dev/null 2>&1 + echo "Done." + echo "Ccheck the kernel ring buffer to see the summary." +} + +run_aligned_prepare_check() +{ + echo "Run performance tests to evaluate how fast aligned prepare API is." + + insmod $DRIVER $ALIGNED_PREPARE_PARAM > /dev/null 2>&1 + echo "Done." + echo "Check the kernel ring buffer to see the summary." +} + run_smoke_check() { echo "Run smoke test." @@ -86,6 +106,7 @@ run_smoke_check() usage() { echo -n "Usage: $0 [ aligned ] | [ nonaligned ] | | [ smoke ] | " + echo "[ aligned_prepare ] | [ nonaligned_prepare ] | " echo "manual parameters" echo echo "Valid tests and parameters:" @@ -106,6 +127,12 @@ usage() echo "# Performance testing for aligned alloc API" echo "$0 aligned" echo + echo "# Performance testing for nonaligned prepare API" + echo "$0 nonaligned_prepare" + echo + echo "# Performance testing for aligned prepare API" + echo "$0 aligned_prepare" + echo exit 0 } @@ -159,6 +186,10 @@ function run_test() run_nonaligned_check elif [[ "$1" = "aligned" ]]; then run_aligned_check + elif [[ "$1" = "nonaligned_prepare" ]]; then + run_nonaligned_prepare_check + elif [[ "$1" = "aligned_prepare" ]]; then + run_aligned_prepare_check else run_manual_check $@ fi