Skip to contentSkip to conversation

net: xfrm: use __this_cpu_read per-cpu helper

PATCH Superseded Shan Wei 2 participants 3 messages Nov 9, 2012 – Nov 12, 2012

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Shan Wei

author
#0 lore raw

PATCH v3 3/9 net: xfrm: use __this_cpu_read per-cpu helper

From: Shan Wei <[email protected]>

---
v3 fix compile warning:
net/xfrm/xfrm_ipcomp.c: In function 'ipcomp_alloc_tfms':
net/xfrm/xfrm_ipcomp.c:285: warning: assignment from incompatible pointer type

---
 net/xfrm/xfrm_ipcomp.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
net/xfrm/xfrm_ipcomp.c +2 -5
index e5246fb..898c899 100644
@@ -276,18 +276,15 @@ 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);
+		tfm = (struct crypto_comp *) __this_cpu_read(pos->tfms);
 
 		if (!strcmp(crypto_comp_name(tfm), alg_name)) {
 			pos->users++;
-			return tfms;
+			return pos->tfms;
 		}
 	}
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 3 lines · Shan Wei

v3 fix compile warning:
net/xfrm/xfrm_ipcomp.c: In function 'ipcomp_alloc_tfms':
net/xfrm/xfrm_ipcomp.c:285: warning: assignment from incompatible pointer type

Why exactly is the pointer type not compatible? Looks like we have a problem here.

author
#2 lore raw

Christoph Lameter said, at 2012/11/10 4:12:

Quoted 9 lines · Shan Wei
Quoted 4 lines

v3 fix compile warning:
net/xfrm/xfrm_ipcomp.c: In function 'ipcomp_alloc_tfms':
net/xfrm/xfrm_ipcomp.c:285: warning: assignment from incompatible pointer type

Why exactly is the pointer type not compatible? Looks like we have a problem here.

pos->tfms(struct crypto_comp **tfms) is a double pointer that point to struct crypto_comp. returned value is a pointer that point to struct crypto_comp;
So, we need to dereference and then read.

+ tfm = __this_cpu_read(*pos->tfms);

I will update this patch in v4 to fix it.

Thanks~