From patchwork Tue Oct 1 07:58:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13895544 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 9AEA7E77172 for ; Thu, 5 Dec 2024 15:21:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E45786B013D; Thu, 5 Dec 2024 10:19:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DBAEC6B00C7; Thu, 5 Dec 2024 10:19:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4B5A6B00BB; Thu, 5 Dec 2024 10:19:10 -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 360DE6B0121 for ; Tue, 1 Oct 2024 04:00:13 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E597440E13 for ; Tue, 1 Oct 2024 08:00:12 +0000 (UTC) X-FDA: 82624285464.03.32E65A4 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf28.hostedemail.com (Postfix) with ESMTP id 060A8C0020 for ; Tue, 1 Oct 2024 08:00:10 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bOrEv8lJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of yunshenglin0825@gmail.com designates 209.85.216.66 as permitted sender) smtp.mailfrom=yunshenglin0825@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727769517; a=rsa-sha256; cv=none; b=uuINbcSbU+I8oROBFUde2Og5o0fj4kt2nQFwCIx9Bi2eXVOG4+74r9ZWKHVTY/s13iSUau b5U4mN/CrJ2ID3w0GUBSw2wqXYpLLqlloqwNIle0+aB+m2MAWTyBL1apazvxpUXAuZuMLm bTrlJ0GfsrFjatpEBR/00TNgtEWtVcE= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bOrEv8lJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of yunshenglin0825@gmail.com designates 209.85.216.66 as permitted sender) smtp.mailfrom=yunshenglin0825@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727769517; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5ojxcdjNvn9tfBEJlcLOUTnmOt/qIyQL5omYnTHVVOo=; b=eGXQOtXaaYuNcj3jkt52Hy7lqSX6ww5SLe8k+/EyMI3t1V1D4gMZKliIs4U01UDRo4Elfc gYy6gHob8iJEpNNVyt159hHikEldBOwG/4nwT+q6fF8uVBDYA2uZeVzotdgdBdoTKjW4yZ R+MXOKdPIsASCT51FpZaRtjKCGiZZJM= Received: by mail-pj1-f66.google.com with SMTP id 98e67ed59e1d1-2e0b9bca173so3007216a91.0 for ; Tue, 01 Oct 2024 01:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727769610; x=1728374410; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5ojxcdjNvn9tfBEJlcLOUTnmOt/qIyQL5omYnTHVVOo=; b=bOrEv8lJDUnHBYENrr85k+UsZ3zZXCwWOZBjwQivDPxvSnl++RDi9t+tBaFgXfwfVg /9H5J6xro1e+yNV5nPQd0uS4C/eCFtubKEOeMQ8lXET7IyCciAO1vYe8dTqwe42x4XN4 yfQ3bWkbgG0LGKJlDnqtzHCc2mj68PJ3vKbqLyMQi58X8VC65a8aHiFYrJQ9EwQnCY/8 nHklziXXD9jy1U3KTh5seveUH+ghbchxpRxyTcK5RhowmiTbucDoOo0hB6TlFN1koj9m 5sgo6jaec1lZzMxbIE8DWF3R85OZKLJgqU08E438JRssdAYzvwZ5ZzKKo0mF8thcBHlM XSmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727769610; x=1728374410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5ojxcdjNvn9tfBEJlcLOUTnmOt/qIyQL5omYnTHVVOo=; b=uwsYCfz1/vH1r+fF5cEWuJPy/LukNly7ZYGpgLjBY8pfMiEo8ylw5iXhtsnrNJPq7x LPg6waNpmeXrH/TYZLFQYtncZMyaeTP1RlBKvrIjnXuLUzs73cnUEgMyTQhDHHuiYcGB sSRle0TQLGpDULUCydbt1hKtdgThi+qh1YiEnJz77whX92nY+38MmHJht8k5lTZY0dGZ lVWOhCLaWSh6EhrXT7C5ajvrfgaq7k8hzdFQoGLGTz3uJsMWve6cQq6cotsr3nN56s3B 4BwpAy05WgMsH0d6BZ02MPMHQ3JUU+DXwdrwh9v62rhOOyHtjSvl0CWTrZJBsThSxN+k 9xEA== X-Forwarded-Encrypted: i=1; AJvYcCVk+bwMxQHLMgmHLxo/64JMKRFgTW/Z/LvttpheCKkGiysXMOcLHb6IL3RQy636KMiW5oYayFsSBQ==@kvack.org X-Gm-Message-State: AOJu0Ywzuc0UFHomyZL2tsyRW6rL3Z/kmBUhxWhqczaxXQo9j2Hbh2nw 3fMU1RQgdj9kVBA8XaqqsOMkRr1jfvG2C82RkXq8PMDwYgI78qId X-Google-Smtp-Source: AGHT+IF3IG9U7cija4N7THOiO2nq96RB2NLJHQxqNLCpLLW60MhGNrffUUs5bLpndLyek42gdCV41A== X-Received: by 2002:a17:90a:f2cf:b0:2e0:b26c:9069 with SMTP id 98e67ed59e1d1-2e0b8ea648cmr15853457a91.25.1727769609750; Tue, 01 Oct 2024 01:00:09 -0700 (PDT) Received: from yunshenglin-MS-7549.. ([2409:8a55:301b:e120:88bd:a0fb:c6d6:c4a2]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e06e16d6d2sm13168168a91.2.2024.10.01.01.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 01:00:09 -0700 (PDT) From: Yunsheng Lin X-Google-Original-From: Yunsheng Lin To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yunsheng Lin , Alexander Duyck , Andrew Morton , Shuah Khan , linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH net-next v19 11/14] mm: page_frag: add testing for the newly added prepare API Date: Tue, 1 Oct 2024 15:58:54 +0800 Message-Id: <20241001075858.48936-12-linyunsheng@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241001075858.48936-1-linyunsheng@huawei.com> References: <20241001075858.48936-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 060A8C0020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 8t1xkipbu1yjqq9wjq1ozhz3p1jodqgo X-HE-Tag: 1727769610-103412 X-HE-Meta: U2FsdGVkX1/qLhMl8mOJJkhmrTbDjoVSwl85Ciy4FFjGjr0eF5mxwacm32loRTqZma2GN7wisS+VsCr9308HjminhXX+hgX3YQzBw0H2JKRcTms/vFByPXmnR1c7QSSYeWXymsEwZo8eq7vSQniHaJeXy20QTtaxZwZTojS2VnvBw/YDrE/r+W5CQtG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JCT7xcf+JsoQPt9lHu7aw8yP/3IfOyPyjxnK9h0XB6dTI4l7UFK8WetD9o50JXneYT181kXgMNY8nOB+rN4RxwvnKEMinnUCpPA+wn70pmvxZO5GCUg6HMW0wiAURVcX4vukooneba6KOMZgOy6+kPxfVNi8JTi4xKHnmyyGIBL8PXS5vmMMnPYILOVCHk15gDJ1aJcG0C2UE6bVcNnwouzzBSU7x9D++LBGFArPLV/aoz88yjcb7gPkVQR86V19Z8q0R9SWIYkNn9MjKJAeCMTW8fAzT/vV+boneNPtUAoMKKPERdN0xOi37115YIOUi+y+wFUkIFjpO1FyR443mwJxO2Xm 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 36543a129e40..567bcc6a181e 100644 --- a/tools/testing/selftests/mm/page_frag/page_frag_test.c +++ b/tools/testing/selftests/mm/page_frag/page_frag_test.c @@ -29,6 +29,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"); @@ -68,6 +72,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) @@ -152,8 +207,9 @@ static int __init page_frag_test_init(void) test_pushed, test_popped); 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 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 d750d910c899..71c3531fa38e 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