From patchwork Mon Sep 2 12:03:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13787185 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 61F37CD342A for ; Mon, 2 Sep 2024 12:09:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 403A78D00D2; Mon, 2 Sep 2024 08:09:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B1C88D0098; Mon, 2 Sep 2024 08:09:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DD3C8D00D2; Mon, 2 Sep 2024 08:09:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F08778D0098 for ; Mon, 2 Sep 2024 08:09:32 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6A2C9141C55 for ; Mon, 2 Sep 2024 12:09:32 +0000 (UTC) X-FDA: 82519678584.26.DCB7DF7 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf11.hostedemail.com (Postfix) with ESMTP id AA15A40030 for ; Mon, 2 Sep 2024 12:09:28 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725278876; 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=T169nkNQbzuZGR5vDqjpXKeow7hAUCwxsGyRKWzZT98=; b=iIDqLfm+vyxyuF0fALYbCmX1+Qat4RWcDgZAvqE8XFZq27fbOkx6mL2I4DhbYg9As7X/s4 WBkecaBOoS1H4x3GPCelkBGrm461F5zwfsNeYBc8nShXLIwfZRhLI1MfCNAa2YHppw7C+i SEZhQG6UbkHnx3nW64DJZ9mJRcNbFAo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725278876; a=rsa-sha256; cv=none; b=8NmjOY2lheaisjOUtLk0FD1KGhx/ieIwPjDShI5o6vq/+v/6RDNyYcDoJVNQsQ8aQFUjJy OmWqJAbMaXMux60qoWMYRPExYB6A8kRQUrlyLOZLBz26t0KtvVKJdNWXzcX5WmcCcmo5Eb GMBPoU/D7EiIMXLWOQxpN7uK588pYvQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Wy6qy54QNz20nLc; Mon, 2 Sep 2024 20:04:30 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id A3AAD18001B; Mon, 2 Sep 2024 20:09:25 +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; Mon, 2 Sep 2024 20:09:25 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Andrew Morton , Shuah Khan , , Subject: [PATCH net-next v17 11/14] mm: page_frag: add testing for the newly added prepare API Date: Mon, 2 Sep 2024 20:03:10 +0800 Message-ID: <20240902120314.508180-12-linyunsheng@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240902120314.508180-1-linyunsheng@huawei.com> References: <20240902120314.508180-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.30.45] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf200006.china.huawei.com (7.185.36.61) X-Stat-Signature: 394gkbkhf9xhmuapcxkh96zjnst35ypn X-Rspamd-Queue-Id: AA15A40030 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725278968-642737 X-HE-Meta: U2FsdGVkX1+MLdZMkT+AnoyxG7GyIN1d21GrJPkUpVXrC1Om+sDYslHougEHAUT9hDm6UZRmcFsJVw+0u2nZTrWLkJFhazcT/xJEx6YfvaYDydf/fXNXJn/XXgP0wATSroNCNffEEb8TtULJsQExS3OOqTw1oKs5AeynaEpxDiE4QetGdvUiJMzLQZJhT1ZHJL+hENdSpZ0pAo3LNr3ZjMmJDtuTOK1PXCucI7r/tVUxhkEovjU//s0AkE3w59Rli9NSONIbAGHrAlMtenmhk37UlplRuapmqw3V3/AAO/2OuFampnWAHGZWmern29pYNLV5GT9FAedwFFgHZhu1cMaf73S5XUuD4ay2Q9lC7aeHg4ytOaKPBlG9bJSaZuhrIphp/hPCmoM4N7D80iUNIW5qdfXFtNIvXeU7l1COAFL2RgjxPHOoWpVNE2iN+LyJO6vVzDbiTBXHh70wbgeR87bBlpGEWDBXMAnlFvEkTw8i82/IM1glafc+rDZgXVYLcY5Pm0J3LlvkENcfLIIQOIynmS4EGGcdiJvxUygboTePIqK+4LsFJMG9L/yyh8p2babUiHAqYpRi8/Hx21Zur2uTrsPGXuY0LKJ9ZRZ6Sy0+3ffKRAcaG/0O1mkmyZBERPF3m/1+okWrqjNVYKR1h1yP62BQEyw/L+WPJIdngaJFHqhOl+S1yi59d+ZleKYEABI3W2RJudCj/Gy/nNiwx0p9iD6S2sIjAm54Zp4KjmineNcVjRk+AyZ2Q4gi3y2Gu0QpZ6jHk2CyLIY0khGo+xp5TAibXG+ZLdePYJqAJ1zojMrC/YvjOMuIDzcMjApE1LOV6FFYA5M5TCnrEhNjVSvGe800rfTmMJrpCgxlxeYehecDHfxTKBywKTqQoZkwfvdSek+1eDG61S0n5wCyaQmB5h/VJ+fzXbvgBiOMD4ZP6lvp2iDwK2XjOvZYyeiBcPyB7k/Pzj8BElmidD0 vpTE5DzY Ajh2QHxKtnmyTIiREVvG2+iZ92q5pOSvfpEc9/jr9hIlzfU1TS6LfP8gQGe4BTCPosngXuX1Z3Zfe1Z/RGrnlDcYe8guh+NH2OaOUrJEEZSS2PAn6ywu31RjylE7jWWT7ksC0+woQvd87jV12Cl4S13mQYPNs9X1MwurYOAllSJ0INVFWfHjaBpibl4t/i3MVxdAUGo7q06bvMVvoE/KR5zQdJp3EeqCrTUKWkqAzmbhi9XtPBA1xh1talQBBZyUzZgk9tHITKkBvbdWw1kwHA+aGwfmAmUwxTfdS 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 d2b0734a90b5..3bc40a895d0d 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