From: Yunsheng Lin <linyunsheng@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Yunsheng Lin <linyunsheng@huawei.com>,
Alexander Duyck <alexander.duyck@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>, <linux-mm@kvack.org>,
<linux-kselftest@vger.kernel.org>
Subject: [PATCH net-next v22 11/14] mm: page_frag: add testing for the newly added prepare API
Date: Fri, 18 Oct 2024 18:53:48 +0800 [thread overview]
Message-ID: <20241018105351.1960345-12-linyunsheng@huawei.com> (raw)
In-Reply-To: <20241018105351.1960345-1-linyunsheng@huawei.com>
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 <alexander.duyck@gmail.com>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
---
.../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..1e47e9ad66f0 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_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
--
2.33.0
next prev parent reply other threads:[~2024-10-18 11:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241018105351.1960345-1-linyunsheng@huawei.com>
2024-10-18 10:53 ` [PATCH net-next v22 01/14] mm: page_frag: add a test module for page_frag Yunsheng Lin
2024-10-18 10:53 ` [PATCH net-next v22 02/14] mm: move the page fragment allocator from page_alloc into its own file Yunsheng Lin
2024-10-18 10:53 ` [PATCH net-next v22 03/14] mm: page_frag: use initial zero offset for page_frag_alloc_align() Yunsheng Lin
2024-10-18 10:53 ` [PATCH net-next v22 04/14] mm: page_frag: avoid caller accessing 'page_frag_cache' directly Yunsheng Lin
2024-10-18 10:53 ` [PATCH net-next v22 06/14] mm: page_frag: reuse existing space for 'size' and 'pfmemalloc' Yunsheng Lin
2024-10-18 16:43 ` Alexander Duyck
2024-10-18 10:53 ` [PATCH net-next v22 07/14] mm: page_frag: some minor refactoring before adding new API Yunsheng Lin
2024-10-18 17:26 ` Alexander Duyck
2024-10-19 8:29 ` Yunsheng Lin
2024-10-20 15:45 ` Alexander Duyck
2024-10-21 9:34 ` Yunsheng Lin
2024-10-18 10:53 ` [PATCH net-next v22 08/14] mm: page_frag: use __alloc_pages() to replace alloc_pages_node() Yunsheng Lin
2024-10-18 10:53 ` [PATCH net-next v22 10/14] mm: page_frag: introduce prepare/probe/commit API Yunsheng Lin
2024-10-18 18:03 ` Alexander Duyck
2024-10-19 8:33 ` Yunsheng Lin
2024-10-20 16:04 ` Alexander Duyck
2024-10-21 9:36 ` Yunsheng Lin
2024-10-18 10:53 ` Yunsheng Lin [this message]
2024-10-18 10:53 ` [PATCH net-next v22 13/14] mm: page_frag: update documentation for page_frag Yunsheng Lin
2024-10-20 10:02 ` Bagas Sanjaya
2024-10-21 9:32 ` Yunsheng Lin
[not found] ` <CAKgT0Uft5Ga0ub_Fj6nonV6E0hRYcej8x_axmGBBX_Nm_wZ_8w@mail.gmail.com>
[not found] ` <02d4971c-a906-44e8-b694-bd54a89cf671@gmail.com>
2024-10-24 9:05 ` [PATCH net-next v22 00/14] Replace page_frag with page_frag_cache for sk_page_frag() Paolo Abeni
2024-10-24 11:39 ` Yunsheng Lin
2024-10-27 3:42 ` Yunsheng Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241018105351.1960345-12-linyunsheng@huawei.com \
--to=linyunsheng@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.duyck@gmail.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox