Re: [PATCH bpf-next] bpf: Check map->record at the begin of check_and_free_fields()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux