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 5C1AAC5AD49 for ; Thu, 29 May 2025 19:11:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B591F6B0085; Thu, 29 May 2025 15:11:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B09C16B0088; Thu, 29 May 2025 15:11:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1F796B0089; Thu, 29 May 2025 15:11:24 -0400 (EDT) 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 844F96B0085 for ; Thu, 29 May 2025 15:11:24 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1DE6AC1080 for ; Thu, 29 May 2025 19:11:24 +0000 (UTC) X-FDA: 83496888888.19.BD06C49 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) by imf16.hostedemail.com (Postfix) with ESMTP id 33E75180006 for ; Thu, 29 May 2025 19:11:21 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=saOQuajq; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf16.hostedemail.com: domain of yonghong.song@linux.dev designates 91.218.175.182 as permitted sender) smtp.mailfrom=yonghong.song@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1748545882; a=rsa-sha256; cv=none; b=olRCfWm5tnxx3O3KuWuFGV6ZVdQlHFJW7Nm30vCZXFFX39eMX1QOi16twpvJws0qPfG0nN 1xip65e5ixhiqP6KRP/8SJSX0IS6NPANONfgaCoYZLxJOEJV0BxwAVhs4x9RYTx55M/+S7 4g9F7uE4xwZ1StJtgP2ONuXHoNAh8Ws= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=saOQuajq; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf16.hostedemail.com: domain of yonghong.song@linux.dev designates 91.218.175.182 as permitted sender) smtp.mailfrom=yonghong.song@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1748545882; 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=GsLNV8w5Mk5SRqqTg1+3C9oZjlD06gLMBrLL9uNprEU=; b=RuUVpxp2MJZUSF/2YFxwxEm45UEDtJi2L6XBN/Gt2QI2A+2gIh+HdxNb8Xt+5h3L7yvuJX sfKTOzKxahJOcsZLb9MJ4j/H6VfnFfn8jgf1FgrsLAq14So1n57IqQBWbI+8VJE/AiHdYN mgkCalZjNveeMR/jOiU2ERoq9zFfoCQ= Message-ID: <99d3b3ef-44f7-4f93-a8e8-ec303dd6d750@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1748545878; h=from:from: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=GsLNV8w5Mk5SRqqTg1+3C9oZjlD06gLMBrLL9uNprEU=; b=saOQuajqoTkxw/CTjSJ5QTYXkA1wa5YMrGDGrX455yd9mnEV32eM5Ul+RCw8NPGs1xV66x dZ0VhI0JOjZr4vuwtRguud1YYPDAVvqMa96JVQLC65s4drPC5Ch5A8BY78fqHacvICuu1j 612gdrzzD4QySu6dJvJKhhK2BbGur90= Date: Thu, 29 May 2025 12:11:11 -0700 MIME-Version: 1.0 Subject: Re: [PATCH v4 1/5] cgroup: move rstat base stat objects into their own struct Content-Language: en-GB To: Ihor Solodrai , JP Kobryn , tj@kernel.org, shakeel.butt@linux.dev, yosryahmed@google.com, mkoutny@suse.com, hannes@cmpxchg.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, cgroups@vger.kernel.org, kernel-team@meta.com, bpf@vger.kernel.org References: <20250404011050.121777-1-inwardvessel@gmail.com> <20250404011050.121777-2-inwardvessel@gmail.com> <6f688f2e-7d26-423a-9029-d1b1ef1c938a@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <6f688f2e-7d26-423a-9029-d1b1ef1c938a@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 33E75180006 X-Stat-Signature: kuhsbojp1xutcgrtcabk1z5o74jfqxrw X-Rspam-User: X-HE-Tag: 1748545881-645906 X-HE-Meta: U2FsdGVkX1843wDjQkaSsWzeAzhPGVLRHK61xtyS7D1iFCOIaPGePIlDDxOBwUNRX+i2RvY3kyzoSQ3J3xTsDJbRI1W1HwljmuM5efHg1Gq9owAIIu1ta6kxYnW9HYNbah9/eNcifZ4YjKkw1+P8GVAZyYmCsTHES/N3sW4h9HjRFp/98KWVHuHXWvlIduQ7BBA9FEm3EH1Kg+vYYNWXnJds3i2hyj3vswj/QQmKU4oc9MV/oFwNQIFAXNLoEEs++cCBP9hbTlkO3jMKkLkwF8Pk5JFNDRR/wWoA9ixSpYMiLcjqBFvsA8gcxBCYlshck6Pfc60MSKxnJ2i25gMgTJM1iP+Q2hMO84H4ft8AK0dqEFw+ByCCBM3MbFmZ7H1Phb6x6VykR6W94kYinWNyRqntJC6gOEdg6vkvsI47BhCYFnmEwZCFNcorofFmJd1N1Tu4V3yKzPMGw7QDDYu+Q6LBS7FS1RC66ToBynt5DhlSMrz35w2qXSczazeUVp1XLbXOPIoTbKdGTSyooJR5Y80DqV741PF74WhN1npXRVSo31czSI5th183pyhkM9MJMC1cps1n/XM3zdMRrvyUu4X8xaRE2lELS6yNJMeMLZWly5ZnrFeBrPaHRhhok1qDl+SbgRoIdUwHUEuTc20IWyto5G4R75qwabQuW0UpZdQY+Mil+AEr9mAzuBpB03OHQJRm3oH84GKH6NrisSRwUkr/D8F4iPXPgIbz9RUBur28p8LOgekfFzt4ZLiqEicRaO51772qWG7SO3C3DuEHHK5RfuH6zBgqR68w9MWpnHckwBLbVgxYcFEzczxQDQuKgB+HwlbG/hbB7ZsYP4fhfbJe2ewlgFLspbIjEUN0p/eWotMGLS0J//hV3fXxfrCWyMOun8JekCC3KkEBFYAPPEzBV7e7Vpobt7TcguTrusZAN8JM3pjmeSbLESUlxQeh+fvhLbhQrOiPJ/V29t7 R4cQxoPZ GL+r4gZFDGnzo6zhR4yBWMfAY2HR+MpCF5+SMdxAf7pw2MFg2TQ+nDnfXeyUemTAUP57JxJnpldbcZuX7kxKkqU9UHADirSstQoKcmKxfQ079LNprhxaPPmB71J+U4tWyO8KMlGGT28uGN4vYEfccuV0EjGlSir9Svn102/yhVABoKmzN7RTbpvCcYSkukr3NuT8WHisJczJ5mbrjNfRI+OaVusDt7OuBSwRN7ZngpTtsjuofLFrV3PbwQ3nvkLSyaiC1yKFo4SEZn8hz0rcfciddmivV9jI+Vl5W6fvBfjo4p54A5n0vxp7vVLf+6Y0cIk4L 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 5/29/25 11:58 AM, Ihor Solodrai wrote: > On 4/3/25 6:10 PM, JP Kobryn wrote: >> This non-functional change serves as preparation for moving to >> subsystem-based rstat trees. The base stats are not an actual subsystem, >> but in future commits they will have exclusive rstat trees just as other >> subsystems will. >> >> Moving the base stat objects into a new struct allows the >> cgroup_rstat_cpu >> struct to become more compact since it now only contains the minimum >> amount >> of pointers needed for rstat participation. Subsystems will (in future >> commits) make use of the compact cgroup_rstat_cpu struct while >> avoiding the >> memory overhead of the base stat objects which they will not use. >> >> An instance of the new struct cgroup_rstat_base_cpu was placed on the >> cgroup struct so it can retain ownership of these base stats common >> to all >> cgroups. A helper function was added for looking up the cpu-specific >> base >> stats of a given cgroup. Finally, initialization and variable names were >> adjusted where applicable. >> >> Signed-off-by: JP Kobryn >> --- >>   include/linux/cgroup-defs.h | 38 ++++++++++------- >>   kernel/cgroup/cgroup.c      |  8 +++- >>   kernel/cgroup/rstat.c       | 84 ++++++++++++++++++++++--------------- >>   3 files changed, 79 insertions(+), 51 deletions(-) >> > > Hi everyone. > > BPF CI started failing after recent upstream merges (tip: 90b83efa6701). > I bisected the issue to this patch, see a log snippet below [1]: > >     ##[error]#44/9 btf_tag/btf_type_tag_percpu_vmlinux_helper >     load_btfs:PASS:could not load vmlinux BTF 0 nsec >     test_btf_type_tag_vmlinux_percpu:PASS:btf_type_tag_percpu 0 nsec >     libbpf: prog 'test_percpu_helper': BPF program load failed: -EACCES >     libbpf: prog 'test_percpu_helper': -- BEGIN PROG LOAD LOG -- >     0: R1=ctx() R10=fp0 >     ; int BPF_PROG(test_percpu_helper, struct cgroup *cgrp, const char > *path) @ btf_type_tag_percpu.c:58 >     0: (79) r1 = *(u64 *)(r1 +0) >     func 'cgroup_mkdir' arg0 has btf_id 437 type STRUCT 'cgroup' >     1: R1_w=trusted_ptr_cgroup() >     ; cpu = bpf_get_smp_processor_id(); @ btf_type_tag_percpu.c:63 >     1: (7b) *(u64 *)(r10 -8) = r1         ; R1_w=trusted_ptr_cgroup() > R10=fp0 fp-8_w=trusted_ptr_cgroup() >     2: (85) call bpf_get_smp_processor_id#8       ; > R0_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=1,var_off=(0x0; 0x1)) >     3: (79) r1 = *(u64 *)(r10 -8)         ; R1_w=trusted_ptr_cgroup() > R10=fp0 fp-8_w=trusted_ptr_cgroup() >     ; cgrp->self.rstat_cpu, cpu); @ btf_type_tag_percpu.c:65 >     4: (79) r1 = *(u64 *)(r1 +32)         ; > R1_w=percpu_ptr_css_rstat_cpu() >     ; rstat = (struct cgroup_rstat_cpu *)bpf_per_cpu_ptr( @ > btf_type_tag_percpu.c:64 >     5: (bc) w2 = w0                       ; > R0_w=scalar(id=1,smin=smin32=0,smax=umax=smax32=umax32=1,var_off=(0x0; > 0x1)) > R2_w=scalar(id=1,smin=smin32=0,smax=umax=smax32=umax32=1,var_off=(0x0; > 0x1)) >     6: (85) call bpf_per_cpu_ptr#153      ; > R0=ptr_or_null_css_rstat_cpu(id=2) >     ; if (rstat) { @ btf_type_tag_percpu.c:66 >     7: (15) if r0 == 0x0 goto pc+1        ; R0=ptr_css_rstat_cpu() >     ; *(volatile int *)rstat; @ btf_type_tag_percpu.c:68 >     8: (61) r1 = *(u32 *)(r0 +0) >     cannot access ptr member updated_children with moff 0 in struct > css_rstat_cpu with off 0 size 4 >     processed 9 insns (limit 1000000) max_states_per_insn 0 > total_states 1 peak_states 1 mark_read 1 >     -- END PROG LOAD LOG -- >     libbpf: prog 'test_percpu_helper': failed to load: -EACCES >     libbpf: failed to load object 'btf_type_tag_percpu' >     libbpf: failed to load BPF skeleton 'btf_type_tag_percpu': -EACCES > test_btf_type_tag_vmlinux_percpu:FAIL:btf_type_tag_percpu_helper > unexpected error: -13 (errno 13) > > The test in question [2]: > > SEC("tp_btf/cgroup_mkdir") > int BPF_PROG(test_percpu_helper, struct cgroup *cgrp, const char *path) > { >     struct cgroup_rstat_cpu *rstat; >     __u32 cpu; > >     cpu = bpf_get_smp_processor_id(); >     rstat = (struct cgroup_rstat_cpu > *)bpf_per_cpu_ptr(cgrp->rstat_cpu, cpu); >     if (rstat) { >         /* READ_ONCE */ >         *(volatile int *)rstat; // BPF verification fails here >     } > >     return 0; > } > > Any ideas about how to properly fix this? The struct cgroup_rstat_cpu is renamed to css_rstat_cpu. Most likely the test needs change. I will take a look. > > Thanks. > > [1] > https://github.com/kernel-patches/bpf/actions/runs/15316839796/job/43125242673 > [2] > https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tools/testing/selftests/bpf/progs/btf_type_tag_percpu.c#n68 [...]