On Sun, Mar 20, 2022 at 12:00:28AM IST, Alexei Starovoitov wrote: > On Thu, Mar 17, 2022 at 05:29:47PM +0530, Kumar Kartikeya Dwivedi wrote: > > Make adjustments to the code to allow storing percpu PTR_TO_BTF_ID in a > > map. Similar to 'kptr_ref' tag, a new 'kptr_percpu' allows tagging types > > of pointers accepting stores of such register types. On load, verifier > > marks destination register as having type PTR_TO_BTF_ID | MEM_PERCPU | > > PTR_MAYBE_NULL. > > > > Cc: Hao Luo <haoluo@xxxxxxxxxx> > > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> > > --- > > include/linux/bpf.h | 3 ++- > > kernel/bpf/btf.c | 13 ++++++++++--- > > kernel/bpf/verifier.c | 26 +++++++++++++++++++++----- > > 3 files changed, 33 insertions(+), 9 deletions(-) > > > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > > index 702aa882e4a3..433f5cb161cf 100644 > > --- a/include/linux/bpf.h > > +++ b/include/linux/bpf.h > > @@ -161,7 +161,8 @@ enum { > > }; > > > > enum { > > - BPF_MAP_VALUE_OFF_F_REF = (1U << 0), > > + BPF_MAP_VALUE_OFF_F_REF = (1U << 0), > > + BPF_MAP_VALUE_OFF_F_PERCPU = (1U << 1), > > What is the use case for storing __percpu pointer into a map? No specific use case for me, just thought it would be useful, especially now that __percpu tag is understood by verifier for kernel BTF, so it may also refer to dynamically allocated per-CPU memory, not just global percpu variables. But fine with dropping both this and user kptr if you don't feel like keeping them. -- Kartikeya