From mboxrd@z Thu Jan 1 00:00:00 1970 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 BB664C4332F for ; Thu, 17 Nov 2022 01:49:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2ECD46B0073; Wed, 16 Nov 2022 20:49:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 276296B0074; Wed, 16 Nov 2022 20:49:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 117926B0075; Wed, 16 Nov 2022 20:49:30 -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 F34386B0073 for ; Wed, 16 Nov 2022 20:49:29 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D77D61A01F5 for ; Thu, 17 Nov 2022 01:49:28 +0000 (UTC) X-FDA: 80141252016.15.EE333DF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id 7AC45100004 for ; Thu, 17 Nov 2022 01:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=g86pi13U5fqQjMMTOmWhOQ6kKD058Yl0Y95DFucR3dQ=; b=SDvjE5KtKIvgDRJi10Gyg0+YYm Mg27EFT21bONScnRw9uN4LpfuMDgAiKsxgFddxoCAyblWB7+2TE25sqIFUiL7uUj319oWcKA/iXgR +2uVXeC3vPopf/SamElZPDeu74g6w3XvvghUuVGCeeUw2iDh8UiNGOnzW2GMX/aNqehD0redx8SMv UZaW97cDwn2we2xG2ZMgWwup2nNgPRJIe/laPSn9UedlrPTobNyI2dbIqzAs8rP7GIL5NpqqW0JPD 3hTlbE67TzNrZtd0VI8EHLQIdAsr5lgghcj8mYZeAFRfWUjycJuTGS1ZahVhyv9g2ek3A+MYb3Nb5 CqlSYeJg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovU1p-009OY6-Ud; Thu, 17 Nov 2022 01:49:21 +0000 Date: Wed, 16 Nov 2022 17:49:21 -0800 From: Luis Chamberlain To: Song Liu Cc: bpf@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, x86@kernel.org, peterz@infradead.org, hch@lst.de, rick.p.edgecombe@intel.com, aaron.lu@intel.com, rppt@kernel.org Subject: Re: [PATCH bpf-next v3 3/6] selftests/vm: extend test_vmalloc to test execmem_* APIs Message-ID: References: <20221117010621.1891711-1-song@kernel.org> <20221117010621.1891711-4-song@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221117010621.1891711-4-song@kernel.org> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668649768; a=rsa-sha256; cv=none; b=eDCHzaEK0eswPQrk4Ug8fYKmQeezofFNZ5l3O+SjRjzMPEtqti7TjrqBwh71RB5C1cSeVX 7JYqx1Qw4N3Cl0LA9dgJI4cdXL61uPb7AZlCHewhrS1V4piIDTKxPq4tXq5gxmk8aziE3o jfdFdiPwE3OCszPdn9mviVhzCJbkpAg= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=SDvjE5Kt; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf05.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668649768; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=g86pi13U5fqQjMMTOmWhOQ6kKD058Yl0Y95DFucR3dQ=; b=BAdkxENJQPtWuP+uibzD4wy+ppLXwbh/xkMYfamr5nKGRsFVR9xEowdKEOy7+54pSgRedk ELHVOE7Ne8qgqACEsL6yP8s8EZtDx67EmEYXbpL8afrB3cxzUJ7Ent5BqJa6vCOhPjtP49 TZ/7MoNOMCIuj+paIDV7jWjOAR4S5F0= X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=SDvjE5Kt; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf05.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org X-Rspamd-Server: rspam02 X-Stat-Signature: ntjyu6kgq9tq1ik1ps1tdfhb51qnj8ou X-Rspamd-Queue-Id: 7AC45100004 X-HE-Tag: 1668649768-652979 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: On Wed, Nov 16, 2022 at 05:06:18PM -0800, Song Liu wrote: > 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; > +} > + This is a basic test and it is useful. But given all those WARN_ON() and WARN_ON_ONCE() I think the real value test here would be to race 1000 threads doing this at the same time. >From a quick look at the test I think adding another entry into the test_case_array with the same call again or 3 times would suffice for a basic clash test. Thoughts? Luis