Skip to contentSkip to conversation

MM: slqb, fix per_cpu access

PATCH In review Jiri Slaby 5 participants 9 messages Nov 1, 2009 – Nov 4, 2009 Memory management

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 MM: slqb, fix per_cpu access

We cannot use the same local variable name as the declared per_cpu variable since commit "percpu: remove per_cpu__ prefix."

Otherwise we would see crashes like:

general protection fault: 0000 [#1] SMP
last sysfs file:
CPU 1
Modules linked in:
Pid: 1, comm: swapper Tainted: G        W  2.6.32-rc5-mm1_64 #860
RIP: 0010:[<ffffffff8142ff94>]  [<ffffffff8142ff94>] start_cpu_timer+0x2b/0x87

...

Cc Nick Piggin <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Christoph Lameter <[email protected]>
---
 mm/slqb.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
mm/slqb.c +4 -4
index e745d9a..27f5025 100644
@@ -2770,16 +2770,16 @@ static DEFINE_PER_CPU(struct delayed_work, cache_trim_work);
 
 static void __cpuinit start_cpu_timer(int cpu)
 {
-	struct delayed_work *cache_trim_work = &per_cpu(cache_trim_work, cpu);
+	struct delayed_work *_cache_trim_work = &per_cpu(cache_trim_work, cpu);
 
 	/*
 	 * When this gets called from do_initcalls via cpucache_init(),
 	 * init_workqueues() has already run, so keventd will be setup
 	 * at that time.
 	 */
-	if (keventd_up() && cache_trim_work->work.func == NULL) {
-		INIT_DELAYED_WORK(cache_trim_work, cache_trim_worker);
-		schedule_delayed_work_on(cpu, cache_trim_work,
+	if (keventd_up() && _cache_trim_work->work.func == NULL) {
+		INIT_DELAYED_WORK(_cache_trim_work, cache_trim_worker);
+		schedule_delayed_work_on(cpu, _cache_trim_work,
 					__round_jiffies_relative(HZ, cpu));
 	}
 }
Signature · 1 line
1.6.4.2
#1 lore raw

Hello,

Review static DEFINE_PER_CPU(struct delayed_work, cache_trim_work);

Quoted 1 line · Jiri Slaby
(quoted diff) +0 -0
@@ -2770,16 +2770,16 @@ static DEFINE_PER_CPU(struct delayed_work, cache_trim_work);

How about renaming cache_trim_work to slqb_cache_trim_work? Another percpu name requirement is global uniqueness (for s390 and alpha support), so prefixing perpcu variables with subsystem name usually resolves situations like this better.

Thanks.

Signature · 7 lines
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#2 lore raw

PATCH 1/1 MM: slqb, fix per_cpu access

We cannot use the same local variable name as the declared per_cpu variable since commit "percpu: remove per_cpu__ prefix."

Otherwise we would see crashes like:

general protection fault: 0000 [#1] SMP
last sysfs file:
CPU 1
Modules linked in:
Pid: 1, comm: swapper Tainted: G        W  2.6.32-rc5-mm1_64 #860
RIP: 0010:[<ffffffff8142ff94>]  [<ffffffff8142ff94>] start_cpu_timer+0x2b/0x87

...

Use slqb_ prefix for the global variable so that we don't collide even with the rest of the kernel (s390 and alpha need this).

Cc Nick Piggin <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Christoph Lameter <[email protected]>
---
 mm/slqb.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
mm/slqb.c +6 -4
index e745d9a..e4bb53f 100644
@@ -2766,11 +2766,12 @@ out:
 	schedule_delayed_work(work, round_jiffies_relative(3*HZ));
 }
 
-static DEFINE_PER_CPU(struct delayed_work, cache_trim_work);
+static DEFINE_PER_CPU(struct delayed_work, slqb_cache_trim_work);
 
 static void __cpuinit start_cpu_timer(int cpu)
 {
-	struct delayed_work *cache_trim_work = &per_cpu(cache_trim_work, cpu);
+	struct delayed_work *cache_trim_work = &per_cpu(slqb_cache_trim_work,
+			cpu);
 
 	/*
 	 * When this gets called from do_initcalls via cpucache_init(),
@@ -3136,8 +3137,9 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
 
 	case CPU_DOWN_PREPARE:
 	case CPU_DOWN_PREPARE_FROZEN:
-		cancel_rearming_delayed_work(&per_cpu(cache_trim_work, cpu));
-		per_cpu(cache_trim_work, cpu).work.func = NULL;
+		cancel_rearming_delayed_work(&per_cpu(slqb_cache_trim_work,
+					cpu));
+		per_cpu(slqb_cache_trim_work, cpu).work.func = NULL;
 		break;
 
 	case CPU_UP_CANCELED:
Signature · 1 line
1.6.4.2
Tested-by on v1 1/1
#3 lore raw
Quoted 12 lines · Jiri Slaby

We cannot use the same local variable name as the declared per_cpu variable since commit "percpu: remove per_cpu__ prefix."

Otherwise we would see crashes like:

general protection fault: 0000 [#1] SMP
last sysfs file:
CPU 1
Modules linked in:
Pid: 1, comm: swapper Tainted: G        W  2.6.32-rc5-mm1_64 #860
RIP: 0010:[<ffffffff8142ff94>]  [<ffffffff8142ff94>] start_cpu_timer+0x2b/0x87

...

Quoted 8 lines

Use slqb_ prefix for the global variable so that we don't collide even with the rest of the kernel (s390 and alpha need this).

Cc Nick Piggin <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Christoph Lameter <[email protected]>
Quoted 44 lines

---
 mm/slqb.c |   10 ++++++----

 1 files changed, 6 insertions(+), 4 deletions(-)
mm/slqb.c +3 -2
index e745d9a..e4bb53f 100644
@@ -2766,11 +2766,12 @@ out:
        schedule_delayed_work(work, round_jiffies_relative(3*HZ));
  }
 
-static DEFINE_PER_CPU(struct delayed_work, cache_trim_work);
+static DEFINE_PER_CPU(struct delayed_work, slqb_cache_trim_work);
 
  static void __cpuinit start_cpu_timer(int cpu)
  {
-       struct delayed_work *cache_trim_work = &per_cpu(cache_trim_work, cpu);
+       struct delayed_work *cache_trim_work = &per_cpu(slqb_cache_trim_work,
+                       cpu);
 
        /*
         * When this gets called from do_initcalls via cpucache_init(),
@@ -3136,8 +3137,9 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
 

       case CPU_DOWN_PREPARE:
       case CPU_DOWN_PREPARE_FROZEN:
-               cancel_rearming_delayed_work(&per_cpu(cache_trim_work, cpu));
-               per_cpu(cache_trim_work, cpu).work.func = NULL;
+               cancel_rearming_delayed_work(&per_cpu(slqb_cache_trim_work,
+                                       cpu));
+               per_cpu(slqb_cache_trim_work, cpu).work.func = NULL; break;

       case CPU_UP_CANCELED:
--
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Signature · 2 lines
Regards
dave
Acked-by on v1 1/1
#4 lore raw
In reply to Jiri Slaby
Quoted 12 lines · Jiri Slaby

We cannot use the same local variable name as the declared per_cpu variable since commit "percpu: remove per_cpu__ prefix."

Otherwise we would see crashes like:

general protection fault: 0000 [#1] SMP
last sysfs file:
CPU 1
Modules linked in:
Pid: 1, comm: swapper Tainted: G        W  2.6.32-rc5-mm1_64 #860
RIP: 0010:[<ffffffff8142ff94>]  [<ffffffff8142ff94>] start_cpu_timer+0x2b/0x87

...

Quoted 8 lines

Use slqb_ prefix for the global variable so that we don't collide even with the rest of the kernel (s390 and alpha need this).

Cc Nick Piggin <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Christoph Lameter <[email protected]>

Thanks.

Signature · 7 lines
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#6 lore raw
In reply to Jiri Slaby
Quoted 34 lines · Jiri Slaby

We cannot use the same local variable name as the declared per_cpu variable since commit "percpu: remove per_cpu__ prefix."

Otherwise we would see crashes like:

general protection fault: 0000 [#1] SMP
last sysfs file:
CPU 1
Modules linked in:
Pid: 1, comm: swapper Tainted: G        W  2.6.32-rc5-mm1_64 #860
RIP: 0010:[<ffffffff8142ff94>]  [<ffffffff8142ff94>] start_cpu_timer+0x2b/0x87

...

Cc Nick Piggin <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Christoph Lameter <[email protected]>
---
 mm/slqb.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
mm/slqb.c +1 -1
index e745d9a..27f5025 100644
@@ -2770,16 +2770,16 @@ static DEFINE_PER_CPU(struct delayed_work, cache_trim_work);
 
 static void __cpuinit start_cpu_timer(int cpu)
 {
-	struct delayed_work *cache_trim_work = &per_cpu(cache_trim_work, cpu);
+	struct delayed_work *_cache_trim_work = &per_cpu(cache_trim_work, cpu);
 
 	/*
 	 * When this gets called from do_initcalls via cpucache_init(),

mm/slqb.c static DEFINE_PER_CPU(struct delayed_work, cache_trim_work); · line 2783

Quoted 10 lines
mm/slqb.c +3 -3
 	 * init_workqueues() has already run, so keventd will be setup
 	 * at that time.
 	 */
-	if (keventd_up() && cache_trim_work->work.func == NULL) {
-		INIT_DELAYED_WORK(cache_trim_work, cache_trim_worker);
-		schedule_delayed_work_on(cpu, cache_trim_work,
+	if (keventd_up() && _cache_trim_work->work.func == NULL) {
+		INIT_DELAYED_WORK(_cache_trim_work, cache_trim_worker);
+		schedule_delayed_work_on(cpu, _cache_trim_work,
 					__round_jiffies_relative(HZ, cpu));

How about calling the local var "trim"?

This actually makes the code more readable, IMHO.

Thanks,
Rusty.

author
#7 lore raw
Quoted 24 lines · Rusty Russell
Quoted 11 lines
mm/slqb.c +1 -1
@@ -2770,16 +2770,16 @@ static DEFINE_PER_CPU(struct delayed_work, cache_trim_work);
 
 static void __cpuinit start_cpu_timer(int cpu)
 {
-	struct delayed_work *cache_trim_work = &per_cpu(cache_trim_work, cpu);
+	struct delayed_work *_cache_trim_work = &per_cpu(cache_trim_work, cpu);
 
 	/*
 	 * When this gets called from do_initcalls via cpucache_init(),

mm/slqb.c static DEFINE_PER_CPU(struct delayed_work, cache_trim_work); · line 2783

Quoted 10 lines
mm/slqb.c +3 -3
 	 * init_workqueues() has already run, so keventd will be setup
 	 * at that time.
 	 */
-	if (keventd_up() && cache_trim_work->work.func == NULL) {
-		INIT_DELAYED_WORK(cache_trim_work, cache_trim_worker);
-		schedule_delayed_work_on(cpu, cache_trim_work,
+	if (keventd_up() && _cache_trim_work->work.func == NULL) {
+		INIT_DELAYED_WORK(_cache_trim_work, cache_trim_worker);
+		schedule_delayed_work_on(cpu, _cache_trim_work,
 					__round_jiffies_relative(HZ, cpu));

How about calling the local var "trim"?

Quoted 1 line

This actually makes the code more readable, IMHO.

Please ignore this version of the patch. After this I sent a new one which changes the global var name.

So the local variable is untouched there. If you want me to perform the cleanup, let me know. In any case I'd make it trim_work instead of trim which makes more sense to me.

#8 lore raw
Quoted 18 lines · Jiri Slaby
Quoted 18 lines
Quoted 5 lines
mm/slqb.c +1 -1
-	struct delayed_work *cache_trim_work = &per_cpu(cache_trim_work, cpu);
+	struct delayed_work *_cache_trim_work = &per_cpu(cache_trim_work, cpu);
 
 	/*
 	 * When this gets called from do_initcalls via cpucache_init(),

mm/slqb.c static DEFINE_PER_CPU(struct delayed_work, cache_trim_work); · line 2783

Quoted 10 lines
mm/slqb.c +3 -3
 	 * init_workqueues() has already run, so keventd will be setup
 	 * at that time.
 	 */
-	if (keventd_up() && cache_trim_work->work.func == NULL) {
-		INIT_DELAYED_WORK(cache_trim_work, cache_trim_worker);
-		schedule_delayed_work_on(cpu, cache_trim_work,
+	if (keventd_up() && _cache_trim_work->work.func == NULL) {
+		INIT_DELAYED_WORK(_cache_trim_work, cache_trim_worker);
+		schedule_delayed_work_on(cpu, _cache_trim_work,
 					__round_jiffies_relative(HZ, cpu));

How about calling the local var "trim"?

Quoted 4 lines
Quoted 1 line

This actually makes the code more readable, IMHO.

Please ignore this version of the patch. After this I sent a new one which changes the global var name.

OK, sure. It's not worth changing unless you were doing a rename anyway.

Quoted 3 lines

So the local variable is untouched there. If you want me to perform the cleanup, let me know. In any case I'd make it trim_work instead of trim which makes more sense to me.

This is getting pedantic and marginal, but the word "work" already appears everywhere this var is used. Either "XXX->work", or "INIT_DELAYED_WORK(XXX" or "scheduled_delayed_work_on(cpu, XXX".

That's why I think the word "work" in unnecessary.

Hope that clarifies why I preferred "trim".
Rusty.