From patchwork Fri Dec 6 12:25:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13897126 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 99C54E77173 for ; Fri, 6 Dec 2024 12:32:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EF456B0270; Fri, 6 Dec 2024 07:32:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0784A6B0273; Fri, 6 Dec 2024 07:32:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5CC16B0274; Fri, 6 Dec 2024 07:32:52 -0500 (EST) 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 BBB416B0270 for ; Fri, 6 Dec 2024 07:32:52 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 85B17C1CD7 for ; Fri, 6 Dec 2024 12:32:41 +0000 (UTC) X-FDA: 82864472544.05.CB5170D Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf12.hostedemail.com (Postfix) with ESMTP id 9C9CD4001C for ; Fri, 6 Dec 2024 12:32:31 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.32 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=1733488342; 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=/9OZdqlxYJzkVqU1SL/72e3Ps4s0GFerlOiAbHSTQfs=; b=6oj4OlE7fTWCbnpJh3OYoSx2Ol37NrEMfIO/tCnSguqO0g5CY/A7TcW/pu+YJCN15z3p6q +8+QwzmhzeBd7Ah9Qu9H98XZvSfMp8/NbhO5pttpx29AA5o1f4r56M0yWEhAEIjf7Rsvpc D3oq4foMAV4aCWSac85EUwC8p4ApsqY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733488342; a=rsa-sha256; cv=none; b=yKSKqc/1Oo5/AD717xaHaeYuTrVZBuhxM7M7Ahvclnas0rhleWE9yEXdxTM9gud33Wx9Ck 9bZ+1gnw9lPbMZkxRF04KP9x4Uz9bvtwzOD4v+8dtd+3MiC+XSKD4zuiNko8ZfK4toIeGQ /CxqstfattjXx/N0ng901HWqj85yxm4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Y4Vyq5PNvz1yr42; Fri, 6 Dec 2024 20:32:51 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id B8586140136; Fri, 6 Dec 2024 20:32:35 +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 Dec 2024 20:32:35 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Andrew Morton , Linux-MM , Shuah Khan , Subject: [PATCH net-next v2 08/10] mm: page_frag: add testing for the newly added API Date: Fri, 6 Dec 2024 20:25:31 +0800 Message-ID: <20241206122533.3589947-9-linyunsheng@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20241206122533.3589947-1-linyunsheng@huawei.com> References: <20241206122533.3589947-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.30.45] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemf200006.china.huawei.com (7.185.36.61) X-Rspamd-Queue-Id: 9C9CD4001C X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 39j56qrkbr5skpjcaxjamyks7itpiuws X-HE-Tag: 1733488351-837915 X-HE-Meta: U2FsdGVkX1/l9pCAa6RXVF5UllA8s5d/KqGYz4r2QXI2hJy9trq0ZLW3+Dnu6bXLatLOxHWvG8yMz2rQCl2MFpDs4sNqXtCqrHj7ZmUKF8R3eg9D115Kh6Gkz88R4JBAe8VhihEuUtof9ImPA7e05wxWtTp7C6Ymph0/ZZYPIEGxdc8NURvBvzaelKa6OgX9QrnFyWjHnre/Ya8IOaZU0HKAlGXorT9VVUDioYNJg1Jasi/BsB7y8hRvcuKcRxkQbKbwv4VZAc4NarpcWmt8oCsUDT8npcgplJDFQY/SvBFSiPk/gVOTKos8t4wZ9siB3U3vrkR5l+sSYoZw05D8ve0aZLR/vicmRABEfQNTGmjKRFXEObcIUAeHngKG6aww3Dehw9uBR/xsatJ9YT2BEoLtcyiTcKkflZ+kkfM3r1WrqmVttFo2Uj4x0JF66Nn/1Z4APp6waMna6TsH9+DmUHu/DdNsgk1TzefTC3IsAtpStC48hw/0ysodesnbXj2TWDIdlLpeSYXwJUlI6gjCklm+i1fvZ83p8ZDSRsGNfe1Z/1xkzqHOFnrmyg/Wg0xIBrRCcRDimqP9l1lN8FXQekSBpC+CGEm8VM900d+FG2ntmXITRY0y00Wyroj7FxX1DfhLrohESkr4Iab8al/PGYDobaH8An8nQWqf7VpKDg73fnQKe1Ea7HbcR0BEm04XH6k6BduWeHEQ1X+yYz4N2pEJf+q0v5+ufBlFLqdrRlmiw8NRupUVszdEjmFcr9uXZ25dbbfilYcfZVK628VBcFqBrhmRAj0QYA+yvcglBkyAqumjvnfN9+UqrYZjkS8ZutKpG0mAlLtVfcbxTyfKu8zb5pgiGh7Hf/b7n0IAqZ8iWF8CaSEJ3deAXGBX/RVicu2eMulzvZxBWHpcC9OGfnCPiT/QFFbLcURLhJ+8KyhAL9874A/08B86MV7ir8JBcrJRu7bKvRnp7hfai7s /jQe7+qv JDlIEbbapaPtVNYhmvbLwuk75pRsMiyonVBrstoKAFl3x2W9zE1EHKEpBBvbKTzL3r2vmWRI67thJTrJacR0+2J9zmQUbhzF5fZx6kHsHqv388U25ZNjUrK0qjGK4AIUgLe5tFV/sW6cM2I735yxitwzKWHosFUVVk34Mh1UPWX/AIqEFHv/r8Fdq7zuUbK0T2+Y5rXZqNMYrL4O8lxK9ZmmvNViPoiHp5qrgmNjDZfM67D53g65sWpWvO4k9Kr32trO7VQFV4CwnDfHBZzfQ//GYNjWguMI4ijVWXXRu5E/fjYhz6yrx+WoOicMA6Rd9oqHeAfGA/j/LapZ8x56B5Kr1neWxvGyF4KbcqfmppzMLQvYkKqy9iErtE2poAL7vrrD+9zY0ab3HVBQ11j3tw7GRvg== 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 CC: Andrew Morton CC: Linux-MM Signed-off-by: Yunsheng Lin --- .../selftests/mm/page_frag/page_frag_test.c | 76 +++++++++++++++++-- tools/testing/selftests/mm/run_vmtests.sh | 4 + tools/testing/selftests/mm/test_page_frag.sh | 27 +++++++ 3 files changed, 102 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 e806c1866e36..3b3c32389def 100644 --- a/tools/testing/selftests/mm/page_frag/page_frag_test.c +++ b/tools/testing/selftests/mm/page_frag/page_frag_test.c @@ -32,6 +32,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"); @@ -74,6 +78,21 @@ 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) +{ + if (prepare_pfrag->page != probe_pfrag->page || + prepare_pfrag->offset != probe_pfrag->offset || + prepare_pfrag->size != probe_pfrag->size) { + force_exit = true; + WARN_ONCE(true, TEST_FAILED_PREFIX "wrong probed info\n"); + } + + page_frag_refill_commit(nc, prepare_pfrag, used_sz); +} + static int page_frag_push_thread(void *arg) { struct ptr_ring *ring = arg; @@ -86,15 +105,61 @@ 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); + if (va != probe_va) { + force_exit = true; + WARN_ONCE(true, TEST_FAILED_PREFIX "wrong va\n"); + } + + 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); + } if ((unsigned long)va & (SMP_CACHE_BYTES - 1)) { force_exit = true; WARN_ONCE(true, TEST_FAILED_PREFIX "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); + + if (va != probe_va) { + force_exit = true; + WARN_ONCE(true, TEST_FAILED_PREFIX "wrong va\n"); + } + + 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) @@ -176,8 +241,9 @@ static int __init page_frag_test_init(void) } 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); out: ptr_ring_cleanup(&ptr_ring, NULL); diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 2fc290d9430c..881c17803baf 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -466,6 +466,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 f55b105084cf..1c757fd11844 100755 --- a/tools/testing/selftests/mm/test_page_frag.sh +++ b/tools/testing/selftests/mm/test_page_frag.sh @@ -43,6 +43,8 @@ check_test_failed_prefix() { 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() { @@ -77,6 +79,20 @@ run_aligned_check() insmod $DRIVER $ALIGNED_PARAM > /dev/null 2>&1 } +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 +} + +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 +} + run_smoke_check() { echo "Run smoke test." @@ -87,6 +103,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:" @@ -107,6 +124,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 } @@ -158,6 +181,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