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 3D177C4332F for ; Thu, 17 Nov 2022 20:04:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC89C6B0073; Thu, 17 Nov 2022 15:04:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B78408E0002; Thu, 17 Nov 2022 15:04:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A67C08E0001; Thu, 17 Nov 2022 15:04:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9745A6B0073 for ; Thu, 17 Nov 2022 15:04:46 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4ECFAABA17 for ; Thu, 17 Nov 2022 20:04:46 +0000 (UTC) X-FDA: 80144012172.14.AD80CFD Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id C234D140009 for ; Thu, 17 Nov 2022 20:04:45 +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=sO4Nog/bmEZybH4emg+O8TQHyWHaCEr7UrYdQK0Zg2I=; b=PqWopkTilfYrrsHB9/FZXh1wZ5 +bJUygVL+Yi75SFwEc+L/NNWFZUKUQ8amoefe9A5OrFQuY+3d6WRmB0qi+TM8S0uPQSG2b0dFa4ja lUkoRF5WgZGKt7zVPh+lQzymqEHpmlJayOWGUuJNZ1KmzPBmN+dR/SA+0aCDAkAmLapTnZoxUccRV H6wMJMTmDwqwSLQ7Tsls+qwwzstfvfUMdRUUr4Ol0ZcS+YlB/wFhyi7eYFo+a03lh999O7AHvuYPa HArpGc5JKKShw/RvVHTiU58YUb2hKrsiQ796NEvzT3q5zvZBjJMbPL2Qt+xGQye3X6tm5hFJEjZjU rGgMeJvA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovl7q-00H5Ma-4m; Thu, 17 Nov 2022 20:04:42 +0000 Date: Thu, 17 Nov 2022 12:04:42 -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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668715485; a=rsa-sha256; cv=none; b=CC9Mk00NXyxJDqv9WGzuumV71MNdmsTAWW2QhTtmdhRHhCNHuPpmMe0mHi4Qw3FzrEbwab VHj3VYTSDcC1DudApUuRLtTnnGulryK9OQZb+/B8ESXmFqMMdBFmTY4SnIpJPwC9FfLHoW Gt2EglIhEHPWzd0jC1YSINYrV6mqxY8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=PqWopkTi; spf=none (imf23.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668715485; 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=sO4Nog/bmEZybH4emg+O8TQHyWHaCEr7UrYdQK0Zg2I=; b=uNTYS1gMV1oxXatAWGf7qcoSBuh5eGOcMKzRqYwqV8WQ4u0O8kI3RJaGzHYuq2uWCYm7Pt x00iVrWrUV9yOXkEBrMsoLxJ5Citb2Y8rfVjrCO+dMZn4YfNlu0DeGf41zryb0mRs5BqhR iz3XhzSxFWJMEunfy9pU39d40lvPGf0= X-Stat-Signature: ahr7mgyxwensdn3joc13o1cgjg8diua3 X-Rspamd-Queue-Id: C234D140009 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=PqWopkTi; spf=none (imf23.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1668715485-47189 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 10:41:39PM -0800, Song Liu wrote: > On Wed, Nov 16, 2022 at 5:49 PM Luis Chamberlain wrote: > > > > 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. > > test_vmalloc supports parallel tests. We can do something like > > tools/testing/selftests/vm/test_vmalloc.sh nr_threads=XXX run_test_mask=1024 Nice, if that is not run by default we won't capture issues which may arise on selftests on 0day. Luis