BPF List
 help / color / mirror / Atom feed
From: Leon Hwang <hffilwlqm@gmail.com>
To: Pu Lehui <pulehui@huawei.com>, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	maciej.fijalkowski@intel.com, jakub@cloudflare.com,
	iii@linux.ibm.com, hengqi.chen@gmail.com,
	kernel-patches-bot@fb.com
Subject: Re: [PATCH bpf-next v2 1/2] bpf, x64: Fix tailcall hierarchy
Date: Fri, 23 Feb 2024 23:30:45 +0800	[thread overview]
Message-ID: <1fdb4ba0-5b91-419a-960c-a26de0e51c25@gmail.com> (raw)
In-Reply-To: <8a3111a0-b190-437f-979e-393f0c890bf1@huawei.com>



On 2024/2/23 12:06, Pu Lehui wrote:
> 
> 
> On 2024/2/22 16:52, Leon Hwang wrote:

[SNIP]

>>   }
>>   @@ -575,6 +574,54 @@ static void emit_return(u8 **pprog, u8 *ip)
>>       *pprog = prog;
>>   }
>>   +DEFINE_PER_CPU(u32, bpf_tail_call_cnt);
> 
> Hi Leon, the solution is really simplifies complexity. If I understand
> correctly, this TAIL_CALL_CNT becomes the system global wise, not the
> prog global wise, but before it was limiting the TCC of entry prog.
> 

Correct. It becomes a PERCPU global variable.

But, I think this solution is not robust enough.

For example,

time      prog1           prog1
==================================>
line              prog2

this is a time-line on a CPU. If prog1 and prog2 have tailcalls to run,
prog2 will reset the tail_call_cnt on current CPU, which is used by
prog1. As a result, when the CPU schedules from prog2 to prog1,
tail_call_cnt on current CPU has been reset to 0, no matter whether
prog1 incremented it.

The tail_call_cnt reset issue happens too, even if PERCPU tail_call_cnt
moves to 'struct bpf_prog_aux', i.e. one kprobe bpf prog can be
triggered on many functions e.g. cilium/pwru. However, this moving is
better than this solution.

I think, my previous POC of 'struct bpf_prog_run_ctx' would be better.
I'll resend it later, with some improvements.

Thanks,
Leon

  reply	other threads:[~2024-02-23 15:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22  8:52 [PATCH bpf-next v2 0/2] bpf, x64: Fix tailcall hierarchy Leon Hwang
2024-02-22  8:52 ` [PATCH bpf-next v2 1/2] " Leon Hwang
2024-02-22 10:59   ` Leon Hwang
2024-02-23  4:06   ` Pu Lehui
2024-02-23 15:30     ` Leon Hwang [this message]
2024-02-23 16:35       ` Alexei Starovoitov
2024-02-26 15:32         ` Leon Hwang
2024-02-26 16:04           ` Leon Hwang
2024-02-26 22:12           ` Alexei Starovoitov
2024-02-28 14:30             ` Leon Hwang
2024-03-29 18:49               ` Alexei Starovoitov
2024-02-23 17:21   ` Alexei Starovoitov
2024-02-22  8:52 ` [PATCH bpf-next v2 2/2] selftests/bpf: Add testcases for tailcall hierarchy fixing Leon Hwang

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=1fdb4ba0-5b91-419a-960c-a26de0e51c25@gmail.com \
    --to=hffilwlqm@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hengqi.chen@gmail.com \
    --cc=iii@linux.ibm.com \
    --cc=jakub@cloudflare.com \
    --cc=kernel-patches-bot@fb.com \
    --cc=maciej.fijalkowski@intel.com \
    --cc=pulehui@huawei.com \
    /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