Message ID | 20181210050618.13300-1-bhole_prashant_q7@lab.ntt.co.jp |
---|---|
State | Superseded, archived |
Delegated to: | David Miller |
Headers | show |
Series | [net-next] tun: replace get_cpu_ptr with this_cpu_ptr when bh disabled | expand |
On 2018/12/10 下午1:06, Prashant Bhole wrote: > tun_xdp_one() runs with local bh disabled. So there is no need to > disable preemption by calling get_cpu_ptr while updating stats. This > patch replaces the use of get_cpu_ptr() with this_cpu_ptr() as a > micro-optimization. Also removes related put_cpu_ptr call. > > Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> > --- > drivers/net/tun.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > index 6760b86547df..abb750a9c9ca 100644 > --- a/drivers/net/tun.c > +++ b/drivers/net/tun.c > @@ -2494,12 +2494,11 @@ static int tun_xdp_one(struct tun_struct *tun, > skb_record_rx_queue(skb, tfile->queue_index); > netif_receive_skb(skb); > > - stats = get_cpu_ptr(tun->pcpu_stats); > + stats = this_cpu_ptr(tun->pcpu_stats); > u64_stats_update_begin(&stats->syncp); > stats->rx_packets++; > stats->rx_bytes += skb->len; > u64_stats_update_end(&stats->syncp); > - put_cpu_ptr(stats); > > if (rxhash) > tun_flow_update(tun, rxhash, tfile); Acked-by: Jason Wang <jasowang@redhat.com>
On Mon, Dec 10, 2018 at 02:06:18PM +0900, Prashant Bhole wrote: > tun_xdp_one() runs with local bh disabled. So there is no need to > disable preemption by calling get_cpu_ptr while updating stats. This > patch replaces the use of get_cpu_ptr() with this_cpu_ptr() as a > micro-optimization. Also removes related put_cpu_ptr call. > > Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> Seems to make sense but how about a comment here explaining by it's safe? > --- > drivers/net/tun.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > index 6760b86547df..abb750a9c9ca 100644 > --- a/drivers/net/tun.c > +++ b/drivers/net/tun.c > @@ -2494,12 +2494,11 @@ static int tun_xdp_one(struct tun_struct *tun, > skb_record_rx_queue(skb, tfile->queue_index); > netif_receive_skb(skb); > > - stats = get_cpu_ptr(tun->pcpu_stats); > + stats = this_cpu_ptr(tun->pcpu_stats); > u64_stats_update_begin(&stats->syncp); > stats->rx_packets++; > stats->rx_bytes += skb->len; > u64_stats_update_end(&stats->syncp); > - put_cpu_ptr(stats); > > if (rxhash) > tun_flow_update(tun, rxhash, tfile); > -- > 2.17.2 >
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 6760b86547df..abb750a9c9ca 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2494,12 +2494,11 @@ static int tun_xdp_one(struct tun_struct *tun, skb_record_rx_queue(skb, tfile->queue_index); netif_receive_skb(skb); - stats = get_cpu_ptr(tun->pcpu_stats); + stats = this_cpu_ptr(tun->pcpu_stats); u64_stats_update_begin(&stats->syncp); stats->rx_packets++; stats->rx_bytes += skb->len; u64_stats_update_end(&stats->syncp); - put_cpu_ptr(stats); if (rxhash) tun_flow_update(tun, rxhash, tfile);
tun_xdp_one() runs with local bh disabled. So there is no need to disable preemption by calling get_cpu_ptr while updating stats. This patch replaces the use of get_cpu_ptr() with this_cpu_ptr() as a micro-optimization. Also removes related put_cpu_ptr call. Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> --- drivers/net/tun.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)