From patchwork Thu Nov 17 01:06:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 13045995 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 4E2EBC4332F for ; Thu, 17 Nov 2022 01:09:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE1A18E0001; Wed, 16 Nov 2022 20:09:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D91C46B007E; Wed, 16 Nov 2022 20:09:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C80818E0001; Wed, 16 Nov 2022 20:09:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B9B476B007D for ; Wed, 16 Nov 2022 20:09:19 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 68AA91A062E for ; Thu, 17 Nov 2022 01:09:19 +0000 (UTC) X-FDA: 80141150838.21.9EFA1B8 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf10.hostedemail.com (Postfix) with ESMTP id D9A4AC0007 for ; Thu, 17 Nov 2022 01:09:18 +0000 (UTC) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.19/8.17.1.19) with ESMTP id 2AH0boj3017742 for ; Wed, 16 Nov 2022 17:09:18 -0800 Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 3kw33fvgtb-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 16 Nov 2022 17:09:17 -0800 Received: from twshared24004.14.frc2.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 16 Nov 2022 17:09:15 -0800 Received: by devbig932.frc1.facebook.com (Postfix, from userid 4523) id 851E2FE65C3C; Wed, 16 Nov 2022 17:06:32 -0800 (PST) From: Song Liu To: , CC: , , , , , , , , Song Liu Subject: [PATCH bpf-next v3 3/6] selftests/vm: extend test_vmalloc to test execmem_* APIs Date: Wed, 16 Nov 2022 17:06:18 -0800 Message-ID: <20221117010621.1891711-4-song@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221117010621.1891711-1-song@kernel.org> References: <20221117010621.1891711-1-song@kernel.org> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: 6mPLdC81Mxjd0g8HBTB_8h3RwpYTmGTn X-Proofpoint-GUID: 6mPLdC81Mxjd0g8HBTB_8h3RwpYTmGTn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-16_03,2022-11-16_01,2022-06-22_01 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668647359; a=rsa-sha256; cv=none; b=6vhKVgM/iXCjgep/DBp1vNzeI1No4mowBpnOtxICdcV21kPJj86rNcLJMGIkd/oNpKacr5 e+GDJWqfXc/V13c8t+qAeEWGwdMW0nuIwLdB98lmle18P9ejcSuVCD03UqVF3LadQECOWs nbHPs8b84B5G/8VtgKk8he3iuI7PCXA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of "prvs=232048c045=songliubraving@meta.com" designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=232048c045=songliubraving@meta.com"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668647359; 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=NvRNcfGDwjQ09lcjsrkjXKVAPOAsiiO9jnHUgdUHjtw=; b=JvxCA1nghMpp1FVVmw1hcMaKuIQiKxrbkdDTPWwqO39r7r1IZu8UlQA0H0uPsomg+joPvl YOSA/X1tI6ccBB+8F14W7kmWbcqamVbW3VVNMwiQobx58rr+hjuAXUFkKaS8c9mXbziPE8 PiSacfJ19ZjqCfwMZQyerLCvZgccOqU= X-Stat-Signature: jtyr71c6typ4hmu5czdeiw81ehuietoh X-Rspamd-Queue-Id: D9A4AC0007 Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of "prvs=232048c045=songliubraving@meta.com" designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=232048c045=songliubraving@meta.com"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1668647358-80808 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: Add logic to test execmem_[alloc|fill|free] in test_vmalloc.c. No need to change tools/testing/selftests/vm/test_vmalloc.sh. Signed-off-by: Song Liu --- lib/test_vmalloc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c index cf7780572f5b..6591c4932c3c 100644 --- a/lib/test_vmalloc.c +++ b/lib/test_vmalloc.c @@ -50,6 +50,7 @@ __param(int, run_test_mask, INT_MAX, "\t\tid: 128, name: pcpu_alloc_test\n" "\t\tid: 256, name: kvfree_rcu_1_arg_vmalloc_test\n" "\t\tid: 512, name: kvfree_rcu_2_arg_vmalloc_test\n" + "\t\tid: 1024, name: execmem_alloc_test\n" /* Add a new test case description here. */ ); @@ -352,6 +353,34 @@ kvfree_rcu_2_arg_vmalloc_test(void) return 0; } +static int +execmem_alloc_test(void) +{ + void *p, *tmp; + int i; + + for (i = 0; i < test_loop_count; i++) { + /* allocate variable size, up to 64kB */ + size_t size = (i % 1024 + 1) * 64; + + p = execmem_alloc(size, 64); + if (!p) + return -1; + + tmp = execmem_fill(p, "a", 1); + if (tmp != p) + return -1; + + tmp = execmem_fill(p + size - 1, "b", 1); + if (tmp != p + size - 1) + return -1; + + execmem_free(p); + } + + return 0; +} + struct test_case_desc { const char *test_name; int (*test_func)(void); @@ -368,6 +397,7 @@ static struct test_case_desc test_case_array[] = { { "pcpu_alloc_test", pcpu_alloc_test }, { "kvfree_rcu_1_arg_vmalloc_test", kvfree_rcu_1_arg_vmalloc_test }, { "kvfree_rcu_2_arg_vmalloc_test", kvfree_rcu_2_arg_vmalloc_test }, + { "execmem_alloc_test", execmem_alloc_test }, /* Add a new test case here. */ };