public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Shan Wei <shanwei88@gmail•com>
To: lindner_marek@yahoo•de, siwu@hrz•tu-chemnitz.de,
	ordex@autistici•org, b.a.t.m.a.n@lists•open-mesh.org,
	David Miller <davem@davemloft•net>,
	NetDev <netdev@vger•kernel.org>,
	Kernel-Maillist <linux-kernel@vger•kernel.org>,
	Shan Wei <shanwei88@gmail•com>, Christoph Lameter <cl@linux•com>
Subject: [PATCH v2 9/9] net: batman-adv: use per_cpu_add helper
Date: Sat, 03 Nov 2012 00:02:06 +0800	[thread overview]
Message-ID: <5093EE7E.6040400@gmail.com> (raw)

From: Shan Wei <davidshan@tencent•com>


As Christoph Lameter said:

> In addition, following usage of per_cpu_ptr can be replaced by this_cpu_read.
>
> cpu=get_cpu()
> ....
> *per_cpu_ptr(p,cpu)
> ....
> ....
> put_cpu()

Right.

Signed-off-by: Shan Wei <davidshan@tencent•com>
---
 net/batman-adv/main.h |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 897ba6a..3aef5b2 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -263,9 +263,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
 static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
 				      size_t count)
 {
-	int cpu = get_cpu();
-	per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count;
-	put_cpu();
+	this_cpu_add(bat_priv->bat_counters[idx], count);
 }
 
 #define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
-- 
1.7.1

             reply	other threads:[~2012-11-02 16:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-02 16:02 Shan Wei [this message]
2012-11-02 17:48 ` [PATCH v2 9/9] net: batman-adv: use per_cpu_add helper Christoph Lameter
     [not found] ` <5093EE7E.6040400-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-11-02 17:55   ` Sven Eckelmann
2012-11-03  4:58     ` Shan Wei
     [not found]       ` <5094A485.4060409-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-11-03 22:39         ` Sven Eckelmann
2012-11-05 15:19         ` Christoph Lameter

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=5093EE7E.6040400@gmail.com \
    --to=shanwei88@gmail$(echo .)com \
    --cc=b.a.t.m.a.n@lists$(echo .)open-mesh.org \
    --cc=cl@linux$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=lindner_marek@yahoo$(echo .)de \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=ordex@autistici$(echo .)org \
    --cc=siwu@hrz$(echo .)tu-chemnitz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox