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 068A3CF649C for ; Mon, 30 Sep 2024 04:33:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEB826B00C0; Mon, 30 Sep 2024 00:33:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C4C996B0137; Mon, 30 Sep 2024 00:33:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AED606B0135; Mon, 30 Sep 2024 00:33:12 -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 83AB18D0002 for ; Mon, 30 Sep 2024 00:33:12 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DFE081C6F06 for ; Mon, 30 Sep 2024 04:33:11 +0000 (UTC) X-FDA: 82620134982.23.4E6A532 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 338001C0009 for ; Mon, 30 Sep 2024 04:33:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bYu0OAiD; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of namhyung@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=namhyung@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727670769; a=rsa-sha256; cv=none; b=fKiY78xPPUCG3Zcu/s64r97YBfuo+sz50V/EfezC2d9OMtoUSR3vVmJ2sxxcEsq/J8nUtW 6STweeOhpEbU5TlGMZ5qSrXSyDa6xts6nkf+QkdxdorFl7iGU2wff1hc4vD9mTUkgtRHGw WNH0m7J29cwH9y4Z5+WV3p+7FvghwPc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bYu0OAiD; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf21.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=1727670769; 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=EGQ2Asr8E7nHYkl3k6qEbPxXFcE4TbCGJkfnbaizZT4=; b=plafrB+pZq7A9DTMmsq9wY7OElFTpn5dalkIoDPNcNv3XB4DflHfldbPiMqwz6ci1X2D8I GdJfx7KZs3qe2/r0dZCkiqGtZwZtYoQlwl1lrh9bcaTgOI+vjE1b7PALvi+ImQhKF2fANt Vsh4i4xCjfq1t6znTZ/9LPmvZeb4ijk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id ECE995C4AC7; Mon, 30 Sep 2024 04:33:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC259C4CECE; Mon, 30 Sep 2024 04:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727670787; bh=3amIbln7dnz+oo73FF/zE0cL2D9f0zkJP2DspgBmvv0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bYu0OAiD2VrZYQCc+iHdpCAxMMHgle1krR6quuKisBiZ+n3EYmuo6WwQuX9f6u9CZ xJmZeh5vLMZysxoN+DXGofch7l8/88x3XZuFIR6Qh1t+avy+HOPeiZkYj64L8U4clL maz4jPNnmhW9edA1CMyLaxsWmwVifcUPxI+llHbxgoUaFkX8q6jo3K3BPe8uw0/OA5 Ti0YVlv3UeYCsGxeQupJ7cBrQ07Id4x0o6hYqBTUcWgiMfKm+U56QNqRDBvr7rOfJb Zxz+bjI4nAj61a6vE7Yv0U0niXdyGi6fKcEvJ8atsKV60bWcassWdbldUglFXbdZrW DjR21CmSoDadg== Date: Sun, 29 Sep 2024 21:33:05 -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-Rspam-User: X-Stat-Signature: n8qw3yx9ro7j36oqozfeycks8nfq37tw X-Rspamd-Queue-Id: 338001C0009 X-Rspamd-Server: rspam02 X-HE-Tag: 1727670789-421234 X-HE-Meta: U2FsdGVkX187MX9pdnnZiubOMEwGF4vNFfTooEgGdq/fAMMbkzRLM3WR0tWReeW2SG2LETnMB1+I/nsWTmm6OlpKHoeUY+5kM1ZyUnIQ3hXbYbP38YlCzXkoXK5teoqTra2Y3fcpGlaqIcFz4WKBZvqYX/lJ9aics3hh8L/olsLZgyNh+pJpgl7VAXtnUVN3hlKgAJ1rvy+qIsiqF6phWduKn0dmOaDAAhbtb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WBNDoiwPlp+YdRvUomsr+r7DLg9YfUn1kwRyGgI6+Logk2+Z6TB6Bw1vBx+wWzMENPh1m8plWxit4TSJoX5i2Gvi46COHQPIUdf/JVNz3TzXEK4UKEPj+kpxM7AsTZnpc= 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 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. Thanks, Namhyung