diff mbox series

[1/1] bpf: avoid unnecessary IPI in bpf_flush_icache

Message ID 20210601150625.37419-2-yanfei.xu@windriver.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series bpf: avoid unnecessary IPI in bpf_flush_icache | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Xu, Yanfei June 1, 2021, 3:06 p.m. UTC
It's no need to trigger IPI for keeping pipeline fresh in bpf case.

Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
---
 arch/arm64/net/bpf_jit_comp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Borkmann June 1, 2021, 5:20 p.m. UTC | #1
On 6/1/21 5:06 PM, Yanfei Xu wrote:
> It's no need to trigger IPI for keeping pipeline fresh in bpf case.

This needs a more concrete explanation/analysis on "why it is safe" to do so
rather than just saying that it is not needed.

> Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
> ---
>   arch/arm64/net/bpf_jit_comp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index f7b194878a99..5311f8be4ba4 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -974,7 +974,7 @@ static int validate_code(struct jit_ctx *ctx)
>   
>   static inline void bpf_flush_icache(void *start, void *end)
>   {
> -	flush_icache_range((unsigned long)start, (unsigned long)end);
> +	__flush_icache_range((unsigned long)start, (unsigned long)end);
>   }
>   
>   struct arm64_jit_data {
>
Will Deacon June 1, 2021, 5:41 p.m. UTC | #2
On Tue, Jun 01, 2021 at 07:20:04PM +0200, Daniel Borkmann wrote:
> On 6/1/21 5:06 PM, Yanfei Xu wrote:
> > It's no need to trigger IPI for keeping pipeline fresh in bpf case.
> 
> This needs a more concrete explanation/analysis on "why it is safe" to do so
> rather than just saying that it is not needed.

Agreed. You need to show how the executing thread ends up going through a
context synchronizing operation before jumping to the generated code if
the IPI here is removed.

Will
Xu, Yanfei June 2, 2021, 11:26 a.m. UTC | #3
On 6/2/21 1:41 AM, Will Deacon wrote:
> [Please note: This e-mail is from an EXTERNAL e-mail address]
> 
> On Tue, Jun 01, 2021 at 07:20:04PM +0200, Daniel Borkmann wrote:
>> On 6/1/21 5:06 PM, Yanfei Xu wrote:
>>> It's no need to trigger IPI for keeping pipeline fresh in bpf case.
>>
>> This needs a more concrete explanation/analysis on "why it is safe" to do so
>> rather than just saying that it is not needed.
> 
> Agreed. You need to show how the executing thread ends up going through a
> context synchronizing operation before jumping to the generated code if
> the IPI here is removed.

This patch came out with I looked through ftrace codes. Ftrace modify
the text code and don't send IPI in aarch64_insn_patch_text_nosync(). I
mistakenly thought the bpf is same with ftrace.

But now I'm still not sure why the ftrace don't need the IPI to go
through context synchronizing, maybe the worst situation is omit a
tracing event?

Thanks,
Yanfei

> 
> Will
>
Will Deacon June 2, 2021, 5:26 p.m. UTC | #4
On Wed, Jun 02, 2021 at 07:26:03PM +0800, Xu, Yanfei wrote:
> 
> 
> On 6/2/21 1:41 AM, Will Deacon wrote:
> > [Please note: This e-mail is from an EXTERNAL e-mail address]
> > 
> > On Tue, Jun 01, 2021 at 07:20:04PM +0200, Daniel Borkmann wrote:
> > > On 6/1/21 5:06 PM, Yanfei Xu wrote:
> > > > It's no need to trigger IPI for keeping pipeline fresh in bpf case.
> > > 
> > > This needs a more concrete explanation/analysis on "why it is safe" to do so
> > > rather than just saying that it is not needed.
> > 
> > Agreed. You need to show how the executing thread ends up going through a
> > context synchronizing operation before jumping to the generated code if
> > the IPI here is removed.
> 
> This patch came out with I looked through ftrace codes. Ftrace modify
> the text code and don't send IPI in aarch64_insn_patch_text_nosync(). I
> mistakenly thought the bpf is same with ftrace.
> 
> But now I'm still not sure why the ftrace don't need the IPI to go
> through context synchronizing, maybe the worst situation is omit a
> tracing event?

I think ftrace handles this itself via ftrace_sync_ipi, no?

Will
Xu, Yanfei June 3, 2021, 10:29 a.m. UTC | #5
On 6/3/21 1:26 AM, Will Deacon wrote:
> [Please note: This e-mail is from an EXTERNAL e-mail address]
> 
> On Wed, Jun 02, 2021 at 07:26:03PM +0800, Xu, Yanfei wrote:
>>
>>
>> On 6/2/21 1:41 AM, Will Deacon wrote:
>>> [Please note: This e-mail is from an EXTERNAL e-mail address]
>>>
>>> On Tue, Jun 01, 2021 at 07:20:04PM +0200, Daniel Borkmann wrote:
>>>> On 6/1/21 5:06 PM, Yanfei Xu wrote:
>>>>> It's no need to trigger IPI for keeping pipeline fresh in bpf case.
>>>>
>>>> This needs a more concrete explanation/analysis on "why it is safe" to do so
>>>> rather than just saying that it is not needed.
>>>
>>> Agreed. You need to show how the executing thread ends up going through a
>>> context synchronizing operation before jumping to the generated code if
>>> the IPI here is removed.
>>
>> This patch came out with I looked through ftrace codes. Ftrace modify
>> the text code and don't send IPI in aarch64_insn_patch_text_nosync(). I
>> mistakenly thought the bpf is same with ftrace.
>>
>> But now I'm still not sure why the ftrace don't need the IPI to go
>> through context synchronizing, maybe the worst situation is omit a
>> tracing event?
> 
> I think ftrace handles this itself via ftrace_sync_ipi, no?

Ah, Yes! I missed this...

Anyway, thanks for your reminding and very sorry for my noise.

Regards,
Yanfei

> 
> Will
>
diff mbox series

Patch

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index f7b194878a99..5311f8be4ba4 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -974,7 +974,7 @@  static int validate_code(struct jit_ctx *ctx)
 
 static inline void bpf_flush_icache(void *start, void *end)
 {
-	flush_icache_range((unsigned long)start, (unsigned long)end);
+	__flush_icache_range((unsigned long)start, (unsigned long)end);
 }
 
 struct arm64_jit_data {