From patchwork Fri Aug 30 11:18:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13784989 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 E8F33CA0FE0 for ; Fri, 30 Aug 2024 11:25:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5959A6B011D; Fri, 30 Aug 2024 07:25:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 546CB6B011E; Fri, 30 Aug 2024 07:25:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 349BC6B011F; Fri, 30 Aug 2024 07:25:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1817E6B011D for ; Fri, 30 Aug 2024 07:25:03 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C0AAF41830 for ; Fri, 30 Aug 2024 11:25:02 +0000 (UTC) X-FDA: 82508680044.14.6FCC4F4 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf03.hostedemail.com (Postfix) with ESMTP id 614A72000C for ; Fri, 30 Aug 2024 11:24:59 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725017034; a=rsa-sha256; cv=none; b=omm7u/C8LFEF/VkrAXxPRR4H2Ry2FKrCzfiNYfUfDdEWNC+JQZNfO5e4ZRyKozQC8uRHn4 ryDMHOEFFNxn9HQpy6J0J7TJ6MyIb0+yxp/F4fUcljMecl7mnSLW8JmvEtqfUNfFvTbbNO T73kCSJd/xG/ptF5OQOtxVirXxE1ubs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.189 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=1725017034; 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=o5PzVX9irsgWPVjJ9MtCi3riUjaxFx8elnQzLB+zs80=; b=hmWWUDMHZDwlGxs6oLJKbmLx7bysyRsXa8tH0/K8Yx0OSpxFp+8g/PbwEGc82YmltUghW8 SxTSvheyNK3fOm61CT5BWmjkuQ8C8banl2uSLaUJgwh1ODpsE+eOHUjT2LgBWmFuhjwCj/ yoaOR3nfRCzhNHvYg9Ee0ZWJ0ehy384= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WwG052v3VzQr55; Fri, 30 Aug 2024 19:20:05 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id 6D6CC180100; Fri, 30 Aug 2024 19:24:57 +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, 30 Aug 2024 19:24:57 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Andrew Morton , Shuah Khan , , Subject: [PATCH net-next v16 11/14] mm: page_frag: add testing for the newly added prepare API Date: Fri, 30 Aug 2024 19:18:41 +0800 Message-ID: <20240830111845.1593542-12-linyunsheng@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240830111845.1593542-1-linyunsheng@huawei.com> References: <20240830111845.1593542-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-Rspamd-Queue-Id: 614A72000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 59xz4dcfk7ix6z5w59pmsq1p18qt5e93 X-HE-Tag: 1725017099-309662 X-HE-Meta: U2FsdGVkX188g6IYxunaYw2e7ZUvO31u8ABr+RWfT+a8xieHfoAw6Fs8yspPzddmQ3fjxhS6nMJvZdq1arf2LOlaY+Gqz6e5N0qDwKDXZvf0eSXUbwA151PgWuz8f43+iDD4KnOn7LTEl0JN2nS2pLeBfKLCQLA72qJncPGxmnS6HsTvl9bbLTcsKCGI9PVywsXZ8aM88t785PESAN/S2Be13z1LXS4B+vpMuFSu/ux/S+hdTVQkBdkCjpIBh4v3jcXRD5riIzX1rR2Eybw9Ep/V7jFyDpVqEGNXsTmkq+zFGoUCVeRh7KI2wi61Lmd/l/pzNR6VGII0//GYJCA0coAzyQGNDomaTbc4OCV22BT+FnxxeftkBq7tvPcXW6W9tIbEWUVLgUcsZwIMu8OeRBFHETkLxmu48Hjn00GfzIGBiOWgU+wJFoqlJaJHd8h67JDJipkSABhDKfjEWnDkSiEGCwcpU9w3k3IzQqPrAAs2zZNj1VtgA8PXaxsIRv3XKB1YHyUFouKGJXnTZ0MYsaiLGPkJ0Mui9puYl5MLgbJFi24gRhPDojp3+SqAtGduHBfxc9Qte720MjkjO4b9dMlm+5tJj02mT10aMTlqKdgIV/T+uB2BoTzTPfPI09OLbwGVmXhpXJRM3S/OIIiNQxa9tdEbkcvhi81fU3aWXckuw1L0H+3az6xfMGUch5AHvEMYmwdHbg3TLE8P6taeb2Aa9yR5FxZae4FvsGgJJmOcQdDW/aVICFTLMysMLv2TLT6ViWY15M8AFyN7ZoRuz6IAjozoOFQBj8rFWmTRvBoUewSTfRvjM52Ek4xq/7zQRR0Aw0TBw7vS1zO0Twio4JHuyM9kDU4j/HXEEMkZB5wJSHoFjS4PGpFWpy8Pzzy3YcBB5sZNg8+baqQblu5+iFI0XyG0BcrMW1DKC6KwJjY8aLVTNDXsveMIoNb8A9d/86TecITnIdo6LBBs+8x mp+3RX+l XKSZsSTx0XDSK+E/WiHlxlaxTFvTVONbqTnWis4qXvdRWK4sk1C++J3IHsCDn39CH2XNcbONbXJNEwWRbxgX5kk1bqeVj7x0YFpBBkdIOkKW37dTnO/n7K/E0/V10Nrad7X1F6xb+i3D9nmh/EwajIfn/wwT74rLVAgoRV4HxN3HRKsNBDz9fiNC55tFBy3hE56zLbKA7vms/1cc/HmJWCwBVfPmoCxeS1iVXu/i+wVOW/ow/o2VnQDJkBTAqwQzMwjjH3KORD9ieRA8g+GgUbGk6ZDLjUNy0W2H1 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 e21a22b1d70b..856eacdd1c90 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 aad55e0ca2cd..753ec4b6fdc3 100755 --- a/tools/testing/selftests/mm/test_page_frag.sh +++ b/tools/testing/selftests/mm/test_page_frag.sh @@ -32,6 +32,8 @@ ksft_skip=4 # NONALIGNED_PARAM="test_push_cpu=$TEST_CPU_0 test_pop_cpu=$TEST_CPU_1 test_alloc_len=12 nr_test=512000000" 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() { @@ -70,6 +72,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." @@ -82,6 +102,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:" @@ -102,6 +123,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 } @@ -155,6 +182,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