tun: replace get_cpu_ptr with this_cpu_ptr when bh disabled
authorPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Tue, 11 Dec 2018 02:43:07 +0000 (11:43 +0900)
committerDavid S. Miller <davem@davemloft.net>
Fri, 14 Dec 2018 21:36:26 +0000 (13:36 -0800)
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.

Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c

index 72577aa35b06018781b7abd5a29e3b37b1b4037b..a4fdad47559462fbd049a89f880cc3fb33d1151d 100644 (file)
@@ -2495,12 +2495,14 @@ build:
        skb_record_rx_queue(skb, tfile->queue_index);
        netif_receive_skb(skb);
 
-       stats = get_cpu_ptr(tun->pcpu_stats);
+       /* No need for get_cpu_ptr() here since this function is
+        * always called with bh disabled
+        */
+       stats = this_cpu_ptr(tun->pcpu_stats);
        u64_stats_update_begin(&stats->syncp);
        stats->rx_packets++;
        stats->rx_bytes += datasize;
        u64_stats_update_end(&stats->syncp);
-       put_cpu_ptr(stats);
 
        if (rxhash)
                tun_flow_update(tun, rxhash, tfile);