bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Raj Sahu <rjsu26@gmail.com>
Cc: bpf@vger.kernel.org,  ast@kernel.org,  daniel@iogearbox.net,
	andrii@kernel.org,  martin.lau@linux.dev,  song@kernel.org,
	yonghong.song@linux.dev,  john.fastabend@gmail.com,
	 kpsingh@kernel.org, sdf@fomichev.me,  haoluo@google.com,
	 jolsa@kernel.org,  djwillia@vt.edu, miloc@vt.edu,
	 ericts@vt.edu,  rahult@vt.edu,  doniaghazy@vt.edu,
	quanzhif@vt.edu,  jinghao7@illinois.edu,
	 sidchintamaneni@gmail.com, memxor@gmail.com,
	 sidchintamaneni <sidchintamaneni@vt.edu>
Subject: Re: [RFC bpf-next 1/4] bpf: Introduce new structs and struct fields
Date: Mon, 12 May 2025 17:04:22 -0700	[thread overview]
Message-ID: <m2msbh1im1.fsf@gmail.com> (raw)
In-Reply-To: <20250420105524.2115690-2-rjsu26@gmail.com> (Raj Sahu's message of "Sun, 20 Apr 2025 06:55:19 -0400")

Raj Sahu <rjsu26@gmail.com> writes:

Hi Raj,

Sorry for delayed response, finally got to read through this series.
Please find a few comments below and in patch #3.
I understand that things are in an incomplete state atm.

[...]

> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index ba6b6118cf50..27dcf59f4445 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c

[...]

> @@ -135,6 +160,16 @@ struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_extra_flag
>  	mutex_init(&fp->aux->dst_mutex);
>  
>  	return fp;
> +
> +free_per_cpu_state:
> +	kfree(termination_states->per_cpu_state);
> +free_bpf_termination_states:
> +	kfree(termination_states);
> +free_bpf_struct_ptr_alloc:

Nit: In verifier code base such exit labels are usually collapsed as one,
     as free() functions can handle NULL arguments.

> +	free_percpu(fp->active);
> +	vfree(fp);
> +	kfree(aux);
> +	return NULL;
>  }
>  
>  struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags)
> @@ -282,6 +317,13 @@ void __bpf_prog_free(struct bpf_prog *fp)
>  		kfree(fp->aux->poke_tab);
>  		kfree(fp->aux);
>  	}
> +
> +	if (fp->termination_states) {
> +		kfree(fp->termination_states->pre_execution_state);
> +		kfree(fp->termination_states->per_cpu_state);
> +		kfree(fp->termination_states);
> +	}
> +

Does this need special handling in core.c:bpf_prog_realloc ?
Also, is it possible to use alloc_percpu_gfp()/free_percpu() functions
for these fields?

>  	free_percpu(fp->stats);
>  	free_percpu(fp->active);
>  	vfree(fp);

  reply	other threads:[~2025-05-13  0:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-20 10:55 [RFC bpf-next 0/4] bpf: Fast-Path approach for BPF program Termination Raj Sahu
2025-04-20 10:55 ` [RFC bpf-next 1/4] bpf: Introduce new structs and struct fields Raj Sahu
2025-05-13  0:04   ` Eduard Zingerman [this message]
2025-04-20 10:55 ` [RFC bpf-next 2/4] bpftool/libbpf : Introduce bpf_prog_termination to trigger termination signal Raj Sahu
2025-04-20 10:55 ` [RFC bpf-next 3/4] bpf: Generating a stubbed version of BPF program for termination Raj Sahu
2025-05-13  0:07   ` Eduard Zingerman
2025-05-13  0:20     ` Alexei Starovoitov
2025-05-13  4:40       ` Eduard Zingerman
2025-05-13  5:16       ` Siddharth Chintamaneni
2025-05-15  1:59         ` Alexei Starovoitov
2025-05-15 17:43           ` Andrii Nakryiko
2025-05-17  5:01           ` Raj Sahu
2025-05-19  1:20             ` Alexei Starovoitov
2025-05-28  7:10               ` Raj Sahu
2025-06-04 23:02                 ` Alexei Starovoitov
2025-06-10 22:06                   ` Siddharth Chintamaneni
2025-06-11 15:59                     ` Alexei Starovoitov
2025-04-20 10:55 ` [RFC bpf-next 4/4] bpf: Runtime part of fast-path termination approach Raj Sahu
2025-05-05 20:13 ` [RFC bpf-next 0/4] bpf: Fast-Path approach for BPF program Termination Kumar Kartikeya Dwivedi
2025-05-06  5:55   ` Raj Sahu
2025-05-06 22:45     ` Alexei Starovoitov
2025-05-06 22:59       ` Kumar Kartikeya Dwivedi
2025-05-07  0:32         ` Alexei Starovoitov
2025-05-07  0:38           ` Kumar Kartikeya Dwivedi
2025-05-07  1:15             ` Alexei Starovoitov
2025-05-07  2:10               ` Kumar Kartikeya Dwivedi
2025-05-07  3:36                 ` Alexei Starovoitov
2025-05-07  5:04                   ` Kumar Kartikeya Dwivedi
2025-05-07 18:15 ` Zvi Effron
2025-05-07 20:01   ` 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=m2msbh1im1.fsf@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=djwillia@vt.edu \
    --cc=doniaghazy@vt.edu \
    --cc=ericts@vt.edu \
    --cc=haoluo@google.com \
    --cc=jinghao7@illinois.edu \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=miloc@vt.edu \
    --cc=quanzhif@vt.edu \
    --cc=rahult@vt.edu \
    --cc=rjsu26@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=sidchintamaneni@gmail.com \
    --cc=sidchintamaneni@vt.edu \
    --cc=song@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).