Skip to contentSkip to conversation

net: core: use this_cpu_ptr per-cpu helper

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

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Shan Wei

author
#0 lore raw

PATCH v3 1/9 net: core: use this_cpu_ptr per-cpu helper

From: Shan Wei <[email protected]>

flush_tasklet is a struct, not a pointer in percpu var. so use this_cpu_ptr to get the member pointer.

---
 net/core/flow.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
net/core/flow.c +1 -3
index e318c7e..b0901ee 100644
@@ -327,11 +327,9 @@ static void flow_cache_flush_tasklet(unsigned long data)
 static void flow_cache_flush_per_cpu(void *data)
 {
 	struct flow_flush_info *info = data;
-	int cpu;
 	struct tasklet_struct *tasklet;
 
-	cpu = smp_processor_id();
-	tasklet = &per_cpu_ptr(info->cache->percpu, cpu)->flush_tasklet;
+	tasklet = this_cpu_ptr(&info->cache->percpu->flush_tasklet);
 	tasklet->data = (unsigned long)info;
 	tasklet_schedule(tasklet);
 }
Signature · 1 line
1.7.1
#1 lore raw
Quoted 5 lines · Shan Wei
net/core/flow.c +0 -0
index e318c7e..b0901ee 100644

net/core/flow.c static void flow_cache_flush_tasklet(unsigned long data) · line 333

Quoted 10 lines
net/core/flow.c +1 -3
@@ -327,11 +327,9 @@ static void flow_cache_flush_tasklet(unsigned long data)
 static void flow_cache_flush_per_cpu(void *data)
 {
 	struct flow_flush_info *info = data;
-	int cpu;
 	struct tasklet_struct *tasklet;
 
-	cpu = smp_processor_id();
-	tasklet = &per_cpu_ptr(info->cache->percpu, cpu)->flush_tasklet;
+	tasklet = this_cpu_ptr(&info->cache->percpu->flush_tasklet);
 	tasklet->data = (unsigned long)info;

this_cpu_write(info->cache->percpu->flush_tasklet->data, (unsigned

	long)info);

should also do the trick in less instructions and get rid of all temporary variables as well.

#2 lore raw
Quoted 19 lines · Christoph Lameter
Quoted 5 lines · Shan Wei
net/core/flow.c +0 -0
index e318c7e..b0901ee 100644

net/core/flow.c static void flow_cache_flush_tasklet(unsigned long data) · line 333

Quoted 10 lines
net/core/flow.c +1 -3
@@ -327,11 +327,9 @@ static void flow_cache_flush_tasklet(unsigned long data)
 static void flow_cache_flush_per_cpu(void *data)
 {
 	struct flow_flush_info *info = data;
-	int cpu;
 	struct tasklet_struct *tasklet;
 
-	cpu = smp_processor_id();
-	tasklet = &per_cpu_ptr(info->cache->percpu, cpu)->flush_tasklet;
+	tasklet = this_cpu_ptr(&info->cache->percpu->flush_tasklet);
 	tasklet->data = (unsigned long)info;

this_cpu_write(info->cache->percpu->flush_tasklet->data, (unsigned

Quoted 4 lines
	long)info);

should also do the trick in less instructions and get rid of all temporary variables as well.

Its not the case.

We need the _pointer_ to call :

tasklet_schedule(tasklet);