Subject: Re: [PATCH net 4/4] bpf, cpumap: Flush xdp after cpu_map_bpf_prog_run_skb().

From: Sebastian Andrzej Siewior <[email-masked]>
Date: Mon, 11 Sep 2023 08:50:16 +0200

On 2023-09-09 10:49:09 [+0800], Hou Tao wrote:
> Hi,
Hi,

> > --- a/kernel/bpf/cpumap.c
> > +++ b/kernel/bpf/cpumap.c
> > @@ -248,12 +248,12 @@ static int cpu_map_bpf_prog_run(struct bpf_cpu_map_entry *rcpu, void **frames,
> >  
> >  	nframes = cpu_map_bpf_prog_run_xdp(rcpu, frames, xdp_n, stats);
> >  
> > -	if (stats->redirect)
> > -		xdp_do_flush();
> > -
> >  	if (unlikely(!list_empty(list)))
> >  		cpu_map_bpf_prog_run_skb(rcpu, list, stats);
> >  
> > +	if (stats->redirect)
> > +		xdp_do_flush();
> > +
> 
> The purpose of xdp_do_flush() is to flush xdp frames stashed in per-cpu
> cpu_map_flush list into xdp_bulk_queue. But for redirected skbs, these
> skbs will be directly added into xdp_bulk_queue() in
> cpu_map_generic_redirect(), so I think xdp_do_flush() is not needed for
> redirected skbs.

Now that I checked the down streams of cpu_map_bpf_prog_run_skb() it
does not queue anything to the per-CPU lists like I assumed.  You are
right, it is no needed.

Sorry for the confusion.

> >  	rcu_read_unlock_bh(); /* resched point, may call do_softirq() */
> >  
> >  	return nframes;
> 

Sebastian