From patchwork Thu Nov 14 12:16:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13875065 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 6065DD65C7E for ; Thu, 14 Nov 2024 12:23:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5C036B009D; Thu, 14 Nov 2024 07:23:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E0BAE6B009E; Thu, 14 Nov 2024 07:23:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD4D46B00A0; Thu, 14 Nov 2024 07:23:06 -0500 (EST) 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 A9C5D6B009D for ; Thu, 14 Nov 2024 07:23:06 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 644BA16064E for ; Thu, 14 Nov 2024 12:23:06 +0000 (UTC) X-FDA: 82784613828.23.34521FC Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf19.hostedemail.com (Postfix) with ESMTP id 955741A0012 for ; Thu, 14 Nov 2024 12:22:08 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.32 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=1731586748; 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=YXj8sFW2sI2fPPOekjTdISpPeCEMGaPkaag0g/i1t1I=; b=jR2RtrzUMLQSMIXulonrqt49MsTlNs8NnuKRVwLZQYyZ+K5UQXFiLMSUtB6fdls/kS1BGm Lhb7Nr128FJQ3BJW7wYQOoQN6YFDvXTtEfUZO1Ivi2hBIXr0UVd2y94+3y93tDfleu9djg A7UOpDddxxVPSRjcOvfj/uwpVyLLIDw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731586748; a=rsa-sha256; cv=none; b=aJblGfsAQfeTqq8AGl4pLy5lBKsqrG+sfNqLvhTGPekwinysOq94bwin9PZwXdXGraYu8z MYmapbuBAGbHZJPl9/JLR5y8wrZFzu6jhdnMYxYBsvQSL4yjsx87j+Y3UHsolbOGWQwgym ew2q3kE1pLxSFX09jF00FLKWtnvI9pQ= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Xpznr5xKPz1yqBZ; Thu, 14 Nov 2024 20:23:12 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id 191891A016C; Thu, 14 Nov 2024 20:23:01 +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; Thu, 14 Nov 2024 20:23:00 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Andrew Morton , Linux-MM , Shuah Khan , Subject: [PATCH net-next v1 08/10] mm: page_frag: add testing for the newly added API Date: Thu, 14 Nov 2024 20:16:03 +0800 Message-ID: <20241114121606.3434517-9-linyunsheng@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20241114121606.3434517-1-linyunsheng@huawei.com> References: <20241114121606.3434517-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.30.45] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemf200006.china.huawei.com (7.185.36.61) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 955741A0012 X-Stat-Signature: spghuqsikza8gc4sq1u7sjyhqo4ndkj5 X-Rspam-User: X-HE-Tag: 1731586928-933697 X-HE-Meta: U2FsdGVkX18BpcO9oWkjlvj525hklUF0fCSlGjC3I6oDieuget82SHFLOsbXb3vVVtGZWtA9sOAwmzylcgkypqsmKcFux7yyttBDFoe/OWkBO1jj+pDxI55c4TRVCXpECncNOUgAQXtcmmnkTS66uE2i9w7NBxeMhYwxnNBtEm15Sy9FMvM+1QSUApjOdTKMw6D1CpIgzdfI4aznxZXHW/4U+i3TCtbZvXMiPuYssLV46Od7QezqvXCXxjQubYmKmMNvRenMnslccucNy6utyfJJM5smw7tpc751wVUzzewliK3R1mhAmG2d1hXmQFB+XtOWu3JqrgnnXTan6syDR3IT2CnhzJtyE6knC/cre0AKYsYRWcb88CFp9wPKTo5922On4zhKfahOjM7OhdUo/fddsxn/mCmrWol0FbiRVSIeXQPLQx6YLuhUFvqdc4pbg0u8A1gKn1RqkgDcw0X4BQyohZc8bEcaPAotqzCYNlB6qmRNXFGCaJlIx9wvJ+8ewMYXr8yQWtO+F8LNt5GvdGzx1haYxSzRNS2XSAK8gw/xJoV+muGY7wrvY2WFtHgD0QuxwODYuymmt9IFYLL2NhNv4EL7znjBejYnWBzvNpTfkiURBq0dV6+zouoUftVj2lZpBI1GDW/VJC1YB2dtfi6pQE74eE2f4gTRawKIQDXx7MwINajyFGFDrNBhiysi4AMBgb6OZrbcb7k8ruBpurJAv0M3If2g80pkYxJN8oF5/cvd9k/dU9/lAxpRY/Zw/7Ln93LT+sP7YhZdLkVeSQ1FlMg355m7x3oaiEiqKWIt9kmRwngKDzVBXEyfjE3uXdqlZReSsHyTNEOuXWl/skg2pIdvh6NWKZ2SSpztBn7qUIVNf3Wu8Yi1ifA2iP2CUdwjA9zMdB1K6hIIlJeX+yRINadVCITr5B4nXB0etKKEogaXXGIP67GMfNe3WmFHSW/QIo1orvq/93e8ZY2 0WKMkBvL wyUC/J+3MJM0cdG+OiS85nliqLp5T00vxyOwq9xcyczLSJgYn2FjbR11duopv2R+mQLR8NEOXVhUdLROvNsh91HfbHy0Taj0XoWB1GmUM0ha4IOzLZtkFB6f6HzSjC+1bk1CArNbB8OGFms244wfJSnoBpGDrJWHqGkCpYQ1Ql+carOEsnmmKuIWVrnogZCfzGasjtSgSL98zrsYXJc3xRVzXtTI6t1vFKyxXMBuklY/jlan9UNKvAyBt7jhyr//jGKXKWlR3eYtTh9Pn/vtzQnFN7xK3zQjPnOqC+4IaQN8Mj+ztSW5Edjqm/u7zurZphzVZDDQumxMQiGk/+0iXci/VljXTbmW/SCy39v69azR1LmlEiDZqAzQXKRol1qbF9QvO52yDIXq9yoFEJQoPAKRFjQ== 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 2c5394584af4..f6ff9080a6f2 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 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