On Thu, Nov 11, 2021 at 9:02 PM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > From: Alexei Starovoitov <ast@xxxxxxxxxx> > > Rename btf_member_bit_offset() and btf_member_bitfield_size() to > avoid conflicts with similarly named helpers in libbpf's btf.h. > Rename the kernel helpers, since libbpf helpers are part of uapi. > > Suggested-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx> > --- See below, I'd get rid of those "almost duplicates" instead, but up to you, I'm fine either way. Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > include/linux/btf.h | 8 ++++---- > kernel/bpf/bpf_struct_ops.c | 6 +++--- > kernel/bpf/btf.c | 18 +++++++++--------- > net/ipv4/bpf_tcp_ca.c | 6 +++--- > 4 files changed, 19 insertions(+), 19 deletions(-) > > diff --git a/include/linux/btf.h b/include/linux/btf.h > index 203eef993d76..956f70388f69 100644 > --- a/include/linux/btf.h > +++ b/include/linux/btf.h > @@ -194,15 +194,15 @@ static inline bool btf_type_kflag(const struct btf_type *t) > return BTF_INFO_KFLAG(t->info); > } > > -static inline u32 btf_member_bit_offset(const struct btf_type *struct_type, > - const struct btf_member *member) > +static inline u32 __btf_member_bit_offset(const struct btf_type *struct_type, > + const struct btf_member *member) a bit surprised you didn't choose to just remove them, given you had to touch all 24 places in the kernel that call this helper > { > return btf_type_kflag(struct_type) ? BTF_MEMBER_BIT_OFFSET(member->offset) > : member->offset; > } > > -static inline u32 btf_member_bitfield_size(const struct btf_type *struct_type, > - const struct btf_member *member) > +static inline u32 __btf_member_bitfield_size(const struct btf_type *struct_type, > + const struct btf_member *member) > { > return btf_type_kflag(struct_type) ? BTF_MEMBER_BITFIELD_SIZE(member->offset) > : 0; > diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c > index 8ecfe4752769..21069dbe9138 100644 > --- a/kernel/bpf/bpf_struct_ops.c > +++ b/kernel/bpf/bpf_struct_ops.c > @@ -165,7 +165,7 @@ void bpf_struct_ops_init(struct btf *btf, struct bpf_verifier_log *log) > break; > } > > - if (btf_member_bitfield_size(t, member)) { > + if (__btf_member_bitfield_size(t, member)) { like in this case it would be btf_member_bitfield_size(t, j) > pr_warn("bit field member %s in struct %s is not supported\n", > mname, st_ops->name); > break; > @@ -296,7 +296,7 @@ static int check_zero_holes(const struct btf_type *t, void *data) > const struct btf_type *mtype; > > for_each_member(i, t, member) { > - moff = btf_member_bit_offset(t, member) / 8; > + moff = __btf_member_bit_offset(t, member) / 8; same here, seema like in all the cases we already have member_idx (i in this case) > if (moff > prev_mend && > memchr_inv(data + prev_mend, 0, moff - prev_mend)) > return -EINVAL; [...]