All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jason Wang <jasowang@redhat.com>,
	netdev@vger.kernel.org,
	Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Subject: Re: [PATCH net-next v2] tun: replace get_cpu_ptr with this_cpu_ptr when bh disabled
Date: Mon, 10 Dec 2018 22:31:06 -0500	[thread overview]
Message-ID: <20181210223057-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20181211024307.7156-1-bhole_prashant_q7@lab.ntt.co.jp>

On Tue, Dec 11, 2018 at 11:43:07AM +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.
> 
> 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>

> ---
> v1 -> v2: Added comment to explain why this change is safe
> 
>  drivers/net/tun.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 6760b86547df..cb90859d0433 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -2494,12 +2494,14 @@ 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);
> +	/* 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 += skb->len;
>  	u64_stats_update_end(&stats->syncp);
> -	put_cpu_ptr(stats);
>  
>  	if (rxhash)
>  		tun_flow_update(tun, rxhash, tfile);
> -- 
> 2.17.2
> 

  reply	other threads:[~2018-12-11  3:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11  2:43 [PATCH net-next v2] tun: replace get_cpu_ptr with this_cpu_ptr when bh disabled Prashant Bhole
2018-12-11  3:31 ` Michael S. Tsirkin [this message]
2018-12-14 21:33 ` David Miller

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=20181210223057-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=bhole_prashant_q7@lab.ntt.co.jp \
    --cc=davem@davemloft.net \
    --cc=jasowang@redhat.com \
    --cc=makita.toshiaki@lab.ntt.co.jp \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.