Please ignore this patch. Send out the old version that has not been proofread yet. Will resend. Sorry for the inconvenience. On 3/15/2025 11:02 PM, Hou Tao wrote: > From: Hou Tao <houtao1@xxxxxxxxxx> > > When there is no special field in the map value, there is no need to > invoke bpf_obj_free_fields(). Therefore, checking the validity of > map->record in advance. > > After the change, the benchmark result of per-cpu update case in > map_perf_test increase 30%+. > > Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx> > --- > kernel/bpf/hashtab.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c > index 6527e9ce83cd9..2623970175dcf 100644 > --- a/kernel/bpf/hashtab.c > +++ b/kernel/bpf/hashtab.c > @@ -906,6 +906,9 @@ static void htab_free_dynptr_key(struct bpf_htab *htab, void *key) > static void check_and_free_fields(struct bpf_htab *htab, > struct htab_elem *elem) > { > + if (IS_ERR_OR_NULL(htab->map.record)) > + return; > + > if (htab_is_percpu(htab)) { > void __percpu *pptr = htab_elem_get_ptr(elem, htab->map.key_size); > int cpu;