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 0F42FCE8379 for ; Mon, 30 Sep 2024 17:48:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97C8F280016; Mon, 30 Sep 2024 13:48:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92CA2280003; Mon, 30 Sep 2024 13:48:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CDE5280016; Mon, 30 Sep 2024 13:48:21 -0400 (EDT) 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 56A62280003 for ; Mon, 30 Sep 2024 13:48:21 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 09E48A087E for ; Mon, 30 Sep 2024 17:48:21 +0000 (UTC) X-FDA: 82622138802.11.705004D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 595A118000D for ; Mon, 30 Sep 2024 17:48:19 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BjVQMSNb; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of namhyung@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=namhyung@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727718360; 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:dkim-signature; bh=lkm6Pr8MwhOBQruHErFQgL5nUQVjna8tryw+nMllQpQ=; b=iZeUxaNQoYlrKM7K3ZRzmBgPETYgaDwrtHWupmenk2MMk+IMG5ka6o12e+A7wiECINv3WE S/I8v8UEVDsKj7FPGlMjz+F5q3lB0PqRp7WBMvJ67o15CnBpd7yHDvzQFqqKifAy6+N1lS FYjKFhus7eY7RXRS42iC1Hv2jrXI9ME= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727718360; a=rsa-sha256; cv=none; b=nFEvOoXn7cFlPicE52hGTxg3pf7gfwcgCwx0NKwmMpgSbnDbiC0LVqOQHw2H6FG2cAt7BD rqIeQL9Tgx2sCvLYT/OklH3k+YTD+WG3jJvoPZjw8B3JQLxLbeZjix6U5j5aovqlJstxNz t8ZDb5gtCEliGSZxsliWKn91AzIn5Yk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BjVQMSNb; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of namhyung@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=namhyung@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4C80D5C4365; Mon, 30 Sep 2024 17:48:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23EEFC4CECE; Mon, 30 Sep 2024 17:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727718498; bh=QtxA2Gn1aPRs/9qbO2VdoDhSsNonNYdVRLyEOTPcCrM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BjVQMSNbjcfK0va4WqlUman7lD7aD6LhM6v5t1lWhSqmqwouwNKP/jb+xZKHV/WFG LFHyuWRgcsztTkv3ttZjUNi4VgVy/lsS9074kviNwyfinHyLqEv+wy/baKrKS374FN ebiGgGg6A5gdNIKvLWZb3Q2N8MfagY/WYAdCoPurnjbn+YMbQ4NBgbM+eQ9H1KDT2o yRFzuzHiVSxG0mg8wEg1uLT/bLIFxhghq1VpCyD78L7XB+AobiBumyvRmaUntxgcn7 gqOZ5ZUmAaymnj9gzwUrC3+ewiu91Ito5DK5Vl3GE9mDWmuK+xFBLLUdvowbRrdNjW hfy/lQ38GpD7A== Date: Mon, 30 Sep 2024 10:48:14 -0700 From: Namhyung Kim To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , LKML , bpf@vger.kernel.org, Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , linux-mm@kvack.org, Arnaldo Carvalho de Melo Subject: Re: [RFC/PATCH bpf-next 3/3] selftests/bpf: Add a test for kmem_cache_iter Message-ID: References: <20240927184133.968283-1-namhyung@kernel.org> <20240927184133.968283-4-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 595A118000D X-Stat-Signature: 8r8nkjpybuqdgiwuo6bojedkxnrxnzzz X-Rspam-User: X-HE-Tag: 1727718499-699859 X-HE-Meta: U2FsdGVkX1+FQUJm1sRbciMFC7EXzGW+yJDF6juZjVNC7D+6InvSJoM0hGliMi3F6xyDRRWBJhY4jICIvOJCKABb+wtypWEgVJZQwUVpDCc22FZmUWvjSIDeST/d3C9z7lFiQ2zelquA1YeX+G7HoeqrTGXtYCks7Br1d/iNoQl864KBersxqzdKOrTp8DUDG2nB1Evm+IFgyaM3omcsxs49to9WSVNR3HHYufSe7vwC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zgjCQGljG6o4TzQG9PkxRDjssFY3Ksn3FhbSUIaQtxeSXRplB1DuUd0Wvd/a6FVlTBXwgejP6bU4tVXiOabTP6pYHIPrSUgARGu+kE= 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: On Sun, Sep 29, 2024 at 09:33:05PM -0700, Namhyung Kim wrote: > On Mon, Sep 30, 2024 at 12:24:52PM +0900, Hyeonggon Yoo wrote: > > On Mon, Sep 30, 2024 at 11:18 AM Namhyung Kim wrote: > > > > > > Hello Hyeonggon, > > > > > > On Sun, Sep 29, 2024 at 11:27:25PM +0900, Hyeonggon Yoo wrote: > > > > On Sun, Sep 29, 2024 at 3:13 PM Namhyung Kim wrote: > > > > > > +SEC("raw_tp/bpf_test_finish") > > > > > > +int BPF_PROG(check_task_struct) > > > > > > +{ > > > > > > + __u64 curr = bpf_get_current_task(); > > > > > > + struct kmem_cache *s; > > > > > > + char *name; > > > > > > + > > > > > > + s = bpf_get_kmem_cache(curr); > > > > > > + if (s == NULL) { > > > > > > + found = -1; > > > > > > + return 0; > > > > > > > > > > ... it cannot find a kmem_cache for the current task. This program is > > > > > run by bpf_prog_test_run_opts() with BPF_F_TEST_RUN_ON_CPU. So I think > > > > > the curr should point a task_struct in a slab cache. > > > > > > > > > > Am I missing something? > > > > > > > > Hi Namhyung, > > > > > > > > Out of curiosity I've been investigating this issue on my machine and > > > > running some experiments. > > > > > > Thanks a lot for looking at this! > > > > > > > > > > > When the test fails, calling dump_page() for the page the task_struct > > > > belongs to, > > > > shows that the page does not have the PGTY_slab flag set which is why > > > > virt_to_slab(current) returns NULL. > > > > > > > > Does the test always fails on your environment? On my machine, the > > > > test passed sometimes but failed some times. > > > > > > I'm using vmtest.sh but it succeeded mostly. I thought I couldn't > > > reproduce it locally, but I also see the failure sometimes. I'll take a > > > deeper look. > > > > > > > > > > > Maybe sometimes the value returned by 'current' macro belongs to a > > > > slab, but sometimes it does not. > > > > But that doesn't really make sense to me as IIUC task_struct > > > > descriptors are allocated from slab. > > > > > > AFAIK the notable exception is the init_task which lives in the kernel > > > data. I'm not sure the if the test is running by PID 1. > > > > I checked that the test is running under PID 0 (swapper) when it fails and > > non-0 PID when it succeeds. This makes sense as the task_struct for PID 0 > > should be in the kernel image area, not in a slab. > > > > Phew, fortunately, it's not a bug! :) > > Thanks for the test, I've seen the same now. > > > > > Any plans on how to adjust the test program? > > I thought the test runs in a separate task. I'll think about how to > test this more reliably. Oh, I think BPF_F_TEST_RUN_ON_CPU was the problem since it requires to run the test on the given CPU (cpu0 in this case). If the cpu0 was idle, it would fail like this. I think removing the flag will run the test on the current CPU so it won't get the swapper task anymore. Thanks, Namhyung