Skip to contentSkip to conversation

core: simplify the getting percpu of flow_cache

PATCH Applied [email protected] 3 participants 4 messages Mar 28, 2013 – Mar 29, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 core: simplify the getting percpu of flow_cache

From: Li RongQing <[email protected]>

replace per_cpu with per_cpu_ptr to save conversion between address and pointer

---
 net/core/flow.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/flow.c +1 -1
index 7fae135..707fb7b 100644
@@ -334,7 +334,7 @@ static int flow_cache_percpu_empty(struct flow_cache *fc, int cpu)
 	struct flow_cache_percpu *fcp;
 	int i;
 
-	fcp = &per_cpu(*fc->percpu, cpu);
+	fcp = per_cpu_ptr(fc->percpu, cpu);
 	for (i = 0; i < flow_cache_hash_size(fc); i++)
 		if (!hlist_empty(&fcp->hash_table[i]))
 			return 0;
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 14 lines · On Thu, 2013-03-28 at 20:24 +0800, [email protected] wrote:

From: Li RongQing <[email protected]>

replace per_cpu with per_cpu_ptr to save conversion between address and pointer

---
 net/core/flow.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/flow.c +0 -0
index 7fae135..707fb7b 100644

net/core/flow.c static int flow_cache_percpu_empty(struct flow_cache *fc, int cpu) · line 340

Quoted 8 lines
net/core/flow.c +1 -1
@@ -334,7 +334,7 @@ static int flow_cache_percpu_empty(struct flow_cache *fc, int cpu)
 	struct flow_cache_percpu *fcp;
 	int i;
 
-	fcp = &per_cpu(*fc->percpu, cpu);
+	fcp = per_cpu_ptr(fc->percpu, cpu);
 	for (i = 0; i < flow_cache_hash_size(fc); i++)
 		if (!hlist_empty(&fcp->hash_table[i]))
 			return 0;

This makes no difference at all, at least on x86

Care to elaborate ?

#2 lore raw

2013/3/28 Eric Dumazet <[email protected]>:

Quoted 27 lines · On Thu, 2013-03-28 at 20:24 +0800, [email protected] wrote:
Quoted 14 lines

From: Li RongQing <[email protected]>

replace per_cpu with per_cpu_ptr to save conversion between address and pointer

---
 net/core/flow.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/flow.c +0 -0
index 7fae135..707fb7b 100644

net/core/flow.c static int flow_cache_percpu_empty(struct flow_cache *fc, int cpu) · line 340

Quoted 8 lines
net/core/flow.c +1 -1
@@ -334,7 +334,7 @@ static int flow_cache_percpu_empty(struct flow_cache *fc, int cpu)
      struct flow_cache_percpu *fcp;
      int i;
 
-     fcp = &per_cpu(*fc->percpu, cpu);
+     fcp = per_cpu_ptr(fc->percpu, cpu);
      for (i = 0; i < flow_cache_hash_size(fc); i++)
              if (!hlist_empty(&fcp->hash_table[i]))
                      return 0;

This makes no difference at all, at least on x86

Quoted 2 lines

Care to elaborate ?

I think it seems to be same as per_cpu, but it makes the codes easy to read, by ignore & before per_cpu() and * beore fc->percpu, and other places in flow.c are using per_cpu_ptr(fc->percpu, cpu)

-Roy