public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
	jolsa@kernel.org, yonghong.song@linux.dev, song@kernel.org,
	eddyz87@gmail.com, dxu@dxuuu.xyz, deso@posteo.net,
	martin.lau@linux.dev, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
	shuah@kernel.org, kerneljasonxing@gmail.com,
	chen.dylane@linux.dev, willemb@google.com,
	paul.chaignon@gmail.com, a.s.protopopov@gmail.com,
	memxor@gmail.com, yatsenko@meta.com, tklauser@distanz.ch,
	kernel-patches-bot@fb.com, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, martin.lau@kernel.org,
	clm@meta.com, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v12 5/7] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_cgroup_storage maps
Date: Wed, 26 Nov 2025 23:35:44 +0800	[thread overview]
Message-ID: <73cda750-5979-4e4e-aa34-18e460b8b6e3@linux.dev> (raw)
In-Reply-To: <edd9991150f1456a7868025636825d7cf7595802e4a2fe405900c53fc1799ed8@mail.kernel.org>



On 2025/11/26 23:11, bot+bpf-ci@kernel.org wrote:
>> diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
>> index aedf573bd..013f4db99 100644
>> --- a/include/linux/bpf-cgroup.h
>> +++ b/include/linux/bpf-cgroup.h
> 
> [ ... ]
> 
>> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
>> index f79d2ae27..9e756db5e 100644
>> --- a/include/linux/bpf.h
>> +++ b/include/linux/bpf.h
> 
> [ ... ]
> 
>> diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c
>> index 2ab4b60ff..1ccbf28b2 100644
>> --- a/kernel/bpf/local_storage.c
>> +++ b/kernel/bpf/local_storage.c
>> @@ -180,7 +180,7 @@ static long cgroup_storage_update_elem(struct bpf_map *map, void *key,
>>  }
>>
>>  int bpf_percpu_cgroup_storage_copy(struct bpf_map *_map, void *key,
>> -				   void *value)
>> +				   void *value, u64 map_flags)
>>  {
>>  	struct bpf_cgroup_storage_map *map = map_to_storage(_map);
>>  	struct bpf_cgroup_storage *storage;
>> @@ -198,11 +198,17 @@ int bpf_percpu_cgroup_storage_copy(struct bpf_map *_map, void *key,
>>  	 * access 'value_size' of them, so copying rounded areas
>>  	 * will not leak any kernel data
>>  	 */
>> +	if (map_flags & BPF_F_CPU) {
>> +		cpu = map_flags >> 32;
>> +		copy_map_value(_map, value, per_cpu_ptr(storage->percpu_buf, cpu));
>> +		goto unlock;
>> +	}
> 
> Should check_and_init_map_value() be called here after copy_map_value()?
> 

It should not be called, because percpu_cgroup_storage maps do not
support any special fields.

Thanks,
Leon

> The similar implementations in bpf_percpu_array_copy() and
> bpf_percpu_hash_copy() both call check_and_init_map_value() after
> copying a single CPU's value when BPF_F_CPU is set:
> 
>   bpf_percpu_array_copy():
>     if (map_flags & BPF_F_CPU) {
>         cpu = map_flags >> 32;
>         copy_map_value(map, value, per_cpu_ptr(pptr, cpu));
>         check_and_init_map_value(map, value);
>         goto unlock;
>     }
> 
>   bpf_percpu_hash_copy():
>     if (map_flags & BPF_F_CPU) {
>         cpu = map_flags >> 32;
>         copy_map_value(map, value, per_cpu_ptr(pptr, cpu));
>         check_and_init_map_value(map, value);
>         goto out;
>     }
> 
> The check_and_init_map_value() call initializes special BTF fields
> (timers, kptrs, etc.) when copying map values to userspace. Without it,> these fields might not be properly initialized if percpu_cgroup_storage
> map values contain such fields.
> 
>>  	size = round_up(_map->value_size, 8);
>>  	for_each_possible_cpu(cpu) {
>>  		copy_map_value_long(_map, value + off, per_cpu_ptr(storage->percpu_buf, cpu));
>>  		off += size;
>>  	}
>> +unlock:
>>  	rcu_read_unlock();
>>  	return 0;
>>  }
> 
> [ ... ]
> 
> 
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
> 
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/19708012130


  reply	other threads:[~2025-11-26 15:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26 14:50 [PATCH bpf-next v12 0/7] bpf: Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags for percpu maps Leon Hwang
2025-11-26 14:50 ` [PATCH bpf-next v12 1/7] bpf: Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags Leon Hwang
2025-11-26 14:50 ` [PATCH bpf-next v12 2/7] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_array maps Leon Hwang
2025-11-26 15:11   ` bot+bpf-ci
2025-11-26 15:24     ` Leon Hwang
2025-11-26 15:56       ` Chris Mason
2025-11-26 22:20         ` Ihor Solodrai
2025-11-26 14:50 ` [PATCH bpf-next v12 3/7] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_hash and lru_percpu_hash maps Leon Hwang
2025-11-26 15:11   ` bot+bpf-ci
2025-11-26 16:24     ` Leon Hwang
2025-11-26 14:50 ` [PATCH bpf-next v12 4/7] bpf: Copy map value using copy_map_value_long for percpu_cgroup_storage maps Leon Hwang
2025-11-26 14:50 ` [PATCH bpf-next v12 5/7] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support " Leon Hwang
2025-11-26 15:11   ` bot+bpf-ci
2025-11-26 15:35     ` Leon Hwang [this message]
2025-11-26 14:50 ` [PATCH bpf-next v12 6/7] libbpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu maps Leon Hwang
2025-11-26 14:50 ` [PATCH bpf-next v12 7/7] selftests/bpf: Add cases to test BPF_F_CPU and BPF_F_ALL_CPUS flags Leon Hwang
2026-01-06 18:25 ` [PATCH bpf-next v12 0/7] bpf: Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags for percpu maps Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=73cda750-5979-4e4e-aa34-18e460b8b6e3@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=a.s.protopopov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chen.dylane@linux.dev \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=deso@posteo.net \
    --cc=dxu@dxuuu.xyz \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-patches-bot@fb.com \
    --cc=kerneljasonxing@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=paul.chaignon@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=tklauser@distanz.ch \
    --cc=willemb@google.com \
    --cc=yatsenko@meta.com \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox