linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 3/9] net: xfrm: use __this_cpu_read per-cpu helper
@ 2012-11-13  1:52 Shan Wei
  2012-11-13  7:21 ` Steffen Klassert
  0 siblings, 1 reply; 6+ messages in thread
From: Shan Wei @ 2012-11-13  1:52 UTC (permalink / raw)
  To: steffen.klassert, David Miller, NetDev, Herbert Xu,
	Kernel-Maillist, cl, Shan Wei

From: Shan Wei <davidshan@tencent.com>


Signed-off-by: Shan Wei <davidshan@tencent.com>
---
v4:
  derefrence pointer before reading to avoid compile warning.
---
 net/xfrm/xfrm_ipcomp.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index e5246fb..2906d52 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -276,18 +276,16 @@ static struct crypto_comp * __percpu *ipcomp_alloc_tfms(const char *alg_name)
 	struct crypto_comp * __percpu *tfms;
 	int cpu;
 
-	/* This can be any valid CPU ID so we don't need locking. */
-	cpu = raw_smp_processor_id();
 
 	list_for_each_entry(pos, &ipcomp_tfms_list, list) {
 		struct crypto_comp *tfm;
 
-		tfms = pos->tfms;
-		tfm = *per_cpu_ptr(tfms, cpu);
+		/* This can be any valid CPU ID so we don't need locking. */
+		tfm = __this_cpu_read(*pos->tfms);
 
 		if (!strcmp(crypto_comp_name(tfm), alg_name)) {
 			pos->users++;
-			return tfms;
+			return pos->tfms;
 		}
 	}
 
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-14  8:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-13  1:52 [PATCH v4 3/9] net: xfrm: use __this_cpu_read per-cpu helper Shan Wei
2012-11-13  7:21 ` Steffen Klassert
2012-11-13  9:33   ` Shan Wei
2012-11-13 10:48     ` Steffen Klassert
2012-11-13 12:36       ` [PATCH v5 " Shan Wei
2012-11-14  8:43         ` Steffen Klassert

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).