linux-kernel.vger.kernel.org archive mirror
 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 v4 9/9] net: batman-adv: use per_cpu_add helper
Date: Tue, 13 Nov 2012 09:53:26 +0800	[thread overview]
Message-ID: <50A1A816.3070900@gmail.com> (raw)

From: Shan Wei <davidshan@tencent.com>

this_cpu_add is an atomic operation.
and be more faster than per_cpu_ptr operation.

Signed-off-by: Shan Wei <davidshan@tencent.com>
Reviewed-by: Christoph Lameter <cl@linux.com>
---
v4: no changes vs v3.
---
 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-13  1:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-13  1:53 Shan Wei [this message]
2012-11-13  9:55 ` [B.A.T.M.A.N.] [PATCH v4 9/9] net: batman-adv: use per_cpu_add helper Marek Lindner
2012-11-13 10:25   ` Shan Wei

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=50A1A816.3070900@gmail.com \
    --to=shanwei88@gmail.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=cl@linux.com \
    --cc=davem@davemloft.net \
    --cc=lindner_marek@yahoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ordex@autistici.org \
    --cc=siwu@hrz.tu-chemnitz.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).