public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Menglong Dong <menglong.dong@linux.dev>
To: Menglong Dong <menglong8.dong@gmail.com>,
	Ilya Leoshkevich <iii@linux.ibm.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
	yonghong.song@linux.dev, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
	jolsa@kernel.org, hca@linux.ibm.com, gor@linux.ibm.com,
	agordeev@linux.ibm.com, borntraeger@linux.ibm.com,
	svens@linux.ibm.com, bpf@vger.kernel.org,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next 2/3] bpf,s390: add fsession support for trampolines
Date: Tue, 24 Feb 2026 10:53:18 +0800	[thread overview]
Message-ID: <9580160.CDJkKcVGEf@7940hx> (raw)
In-Reply-To: <10367bd9-4b9f-48d1-9ee7-8e8b1ec57909@linux.ibm.com>

On 2026/2/23 20:14 Ilya Leoshkevich <iii@linux.ibm.com> write:
> 
> On 2/23/26 09:40, Menglong Dong wrote:
> > Implement BPF_TRACE_FSESSION support for s390. The logic here is similar
> > to what we did in x86_64.
> >
> > In order to simply the logic, we factor out the function invoke_bpf() for
> > fentry and fexit.
> >
> > Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> > ---
> >   arch/s390/net/bpf_jit_comp.c | 68 +++++++++++++++++++++++++++++++-----
> >   1 file changed, 59 insertions(+), 9 deletions(-)
> 
> 
> Thank you for contributing this series!
> 
> 
> In general this all looks very reasonable; I believe I found a few nits, 
> please take a look at my comments below.
> 
> 
> >
> > diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
> > index 763d2491dfa3..ea0c81f18ece 100644
[...]
> >   
> > -	for (i = 0; i < fentry->nr_links; i++)
> > -		if (invoke_bpf_prog(tjit, m, fentry->links[i],
> > -				    flags & BPF_TRAMP_F_RET_FENTRY_RET))
> > +	if (fsession_cnt) {
> > +		/* clear all the session cookies' value */
> 
> Here and below: please use the existing style for single-line comments: 
> full sentence starting with a capital letter and ending with a dot. 
> Unfortunately the JIT is somewhat inconsistent in this area, but let's 
> at least not introduce a new comment style here.

OK, I'll fix up the comments style in the next version.

> 
> > +		for (i = 0; i < cookie_cnt; i++)
> > +			emit_store_stack_imm64(jit, REG_0, cookie_off + 8 * i, 0);
> > +		/* clear the return value to make sure fentry always gets 0 */
> > +		emit_store_stack_imm64(jit, REG_0, tjit->retval_off, 0);
> > +	}
> 
> Would it make sense to clear cookies right after invoke_bpf_prog() and 
> only if bpf_prog_calls_session_cookie() is true?

I think it doesn't make much sense. We only reserve session cookies for
the fsession progs that called bpf_session_cookie(), which means that
all the cookies that we reserved here will be used. Right?

> 
> Going one step further and reducing the size of cookies array would 
> probably be ideal, but I guess this will complicate things 
> significantly, so I'm not suggesting to do this.
> 
> > +
> > +	if (fentry->nr_links) {
> 
> I think it's okay to drop this condition, invoke_bpf() is most likely 
> inlined and the loop will automatically have 0 iterations in this case.

OK, I'll drop this checking.

> 
> > +		if (invoke_bpf(tjit, m, fentry, flags & BPF_TRAMP_F_RET_FENTRY_RET,
> > +			       func_meta, cookie_off))
> >   			return -EINVAL;
> > +	}
> >   
> >   	if (fmod_ret->nr_links) {
> >   		/*
> > @@ -2842,11 +2880,18 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
> >   		EMIT6_PCREL_RILC(0xc0040000, 0, (u64)im->ip_epilogue);
> >   	}
> >   
> > +	/* set the "is_return" flag for fsession */
> > +	func_meta |= (1ULL << BPF_TRAMP_IS_RETURN_SHIFT);
> > +	if (fsession_cnt)
> > +		emit_store_stack_imm64(jit, REG_W0, tjit->func_meta_off,
> > +				       func_meta);
> > +
> >   	/* do_fexit: */
> >   	tjit->do_fexit = jit->prg;
> > -	for (i = 0; i < fexit->nr_links; i++)
> > -		if (invoke_bpf_prog(tjit, m, fexit->links[i], false))
> > +	if (fexit->nr_links) {
> Same as for fentry.

ACK.

Thanks!
Menglong Dong

> > +		if (invoke_bpf(tjit, m, fexit, false, func_meta, cookie_off))
> >   			return -EINVAL;
> > +	}
> >   
> >   	if (flags & BPF_TRAMP_F_CALL_ORIG) {
> >   		im->ip_epilogue = jit->prg_buf + jit->prg;
> > @@ -2951,6 +2996,11 @@ bool bpf_jit_supports_arena(void)
> >   	return true;
> >   }
> >   
> > +bool bpf_jit_supports_fsession(void)
> > +{
> > +	return true;
> > +}
> > +
> >   bool bpf_jit_supports_insn(struct bpf_insn *insn, bool in_arena)
> >   {
> >   	if (!in_arena)
> 
> 





  reply	other threads:[~2026-02-24  2:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23  8:40 [PATCH bpf-next 0/3] bpf: fsession support for s390 Menglong Dong
2026-02-23  8:40 ` [PATCH bpf-next 1/3] bpf,s390: introduce emit_store_stack_imm64() for trampoline Menglong Dong
2026-02-23 11:44   ` Ilya Leoshkevich
2026-02-24  2:48     ` Menglong Dong
2026-02-23  8:40 ` [PATCH bpf-next 2/3] bpf,s390: add fsession support for trampolines Menglong Dong
2026-02-23 12:14   ` Ilya Leoshkevich
2026-02-24  2:53     ` Menglong Dong [this message]
2026-02-23  8:40 ` [PATCH bpf-next 3/3] selftests/bpf: factor out get_func_* tests for fsession Menglong Dong
2026-02-23 11:44   ` Ilya Leoshkevich

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=9580160.CDJkKcVGEf@7940hx \
    --to=menglong.dong@linux.dev \
    --cc=agordeev@linux.ibm.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=borntraeger@linux.ibm.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=gor@linux.ibm.com \
    --cc=haoluo@google.com \
    --cc=hca@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=menglong8.dong@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=svens@linux.ibm.com \
    --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