Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1603328 > unrolled thread
| Started by | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| First post | 2017-03-17 15:00 +0100 |
| Last post | 2017-03-26 15:30 +0200 |
| Articles | 6 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [locking/lockdep] 383776fa75: INFO: trying to register non-static key. Peter Zijlstra <peterz@infradead.org> - 2017-03-17 15:00 +0100
Re: [locking/lockdep] 383776fa75: INFO: trying to register non-static key. Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-03-17 15:50 +0100
Re: [locking/lockdep] 383776fa75: INFO: trying to register non-static key. Peter Zijlstra <peterz@infradead.org> - 2017-03-20 12:50 +0100
Re: [locking/lockdep] 383776fa75: INFO: trying to register non-static key. Borislav Petkov <bp@alien8.de> - 2017-03-25 19:20 +0100
[tip:locking/core] lockdep: Fix per-cpu static objects tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2017-03-26 11:50 +0200
[tip:locking/core] lockdep: Fix per-cpu static objects tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2017-03-26 15:30 +0200
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2017-03-17 15:00 +0100 |
| Subject | Re: [locking/lockdep] 383776fa75: INFO: trying to register non-static key. |
| Message-ID | <tm0A9-7ex-9@gated-at.bofh.it> |
On Fri, Mar 17, 2017 at 02:07:05AM +0800, kernel test robot wrote:
> locking/lockdep: Handle statically initialized PER_CPU locks properly
> [ 11.712266] INFO: trying to register non-static key.
Blergh; so the problem is that when we assign can_addr to lock->key, we
can, upon using a different subclass, reach static_obj(lock->key), which
will fail on the can_addr.
One way to fix this would be to redefine the canonical address as the
per-cpu address for a specific cpu; the below hard codes cpu0, but I'm
not sure we want to rely on cpu0 being a valid cpu.
---
diff --git a/kernel/module.c b/kernel/module.c
index 5ef618133849..bdd9d62ce08c 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -682,8 +682,10 @@ bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
void *va = (void *)addr;
if (va >= start && va < start + mod->percpu_size) {
- if (can_addr)
+ if (can_addr) {
*can_addr = (unsigned long) (va - start);
+ *can_addr += (unsigned long)per_cpu_ptr(mod->percpu, 0);
+ }
preempt_enable();
return true;
}
diff --git a/mm/percpu.c b/mm/percpu.c
index e30c995f2b7b..a5d7b7477888 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1296,8 +1296,10 @@ bool __is_kernel_percpu_address(unsigned long addr, unsigned long *can_addr)
void *va = (void *)addr;
if (va >= start && va < start + static_size) {
- if (can_addr)
+ if (can_addr) {
*can_addr = (unsigned long) (va - start);
+ *can_addr += (unsigned long)per_cpu_ptr(base, 0);
+ }
return true;
}
}
[toc] | [next] | [standalone]
| From | Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
|---|---|
| Date | 2017-03-17 15:50 +0100 |
| Message-ID | <tm1mx-7VB-11@gated-at.bofh.it> |
| In reply to | #1603328 |
On 2017-03-17 14:41:09 [+0100], Peter Zijlstra wrote: > On Fri, Mar 17, 2017 at 02:07:05AM +0800, kernel test robot wrote: > > > locking/lockdep: Handle statically initialized PER_CPU locks properly > > > [ 11.712266] INFO: trying to register non-static key. > > Blergh; so the problem is that when we assign can_addr to lock->key, we > can, upon using a different subclass, reach static_obj(lock->key), which > will fail on the can_addr. > > One way to fix this would be to redefine the canonical address as the > per-cpu address for a specific cpu; the below hard codes cpu0, but I'm > not sure we want to rely on cpu0 being a valid cpu. This solves two problems: The one reported by the bot. The other thing, that is fixed by the patch, is that the first PER-CPU variable built-in will return 0 for can_addr and so will the first variable in every module. As far as I understand it, this should be unique and having the same value for multiple different variables does not look too good :) So adding the offset from CPU0 sounds good. Sebastian
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2017-03-20 12:50 +0100 |
| Message-ID | <tn3Z0-48j-7@gated-at.bofh.it> |
| In reply to | #1603368 |
On Fri, Mar 17, 2017 at 03:41:41PM +0100, Sebastian Andrzej Siewior wrote:
> On 2017-03-17 14:41:09 [+0100], Peter Zijlstra wrote:
> > On Fri, Mar 17, 2017 at 02:07:05AM +0800, kernel test robot wrote:
> >
> > > locking/lockdep: Handle statically initialized PER_CPU locks properly
> >
> > > [ 11.712266] INFO: trying to register non-static key.
> >
> > Blergh; so the problem is that when we assign can_addr to lock->key, we
> > can, upon using a different subclass, reach static_obj(lock->key), which
> > will fail on the can_addr.
> >
> > One way to fix this would be to redefine the canonical address as the
> > per-cpu address for a specific cpu; the below hard codes cpu0, but I'm
> > not sure we want to rely on cpu0 being a valid cpu.
>
> This solves two problems: The one reported by the bot. The other thing,
> that is fixed by the patch, is that the first PER-CPU variable built-in
> will return 0 for can_addr and so will the first variable in every
> module. As far as I understand it, this should be unique and having the
> same value for multiple different variables does not look too good :)
> So adding the offset from CPU0 sounds good.
Right; so how about something liek this?
---
Subject: lockdep: Fix per-cpu static objects
From: Peter Zijlstra <peterz@infradead.org>
Date: Mon Mar 20 12:26:55 CET 2017
Since commit:
383776fa7527 ("locking/lockdep: Handle statically initialized PER_CPU locks properly")
we try to collapse per-cpu locks into a single class by giving them
all the same key. For this key we choose the canonical address of the
per-cpu object, which would be the offset into the per-cpu area.
This has two problems:
- there is a case where we run !0 lock->key through static_obj() and
expect this to pass; it doesn't for canonical pointers.
- 0 is a valid canonical address.
Cure both issues by redefining the canonical address as the address of
the per-cpu variable on the boot CPU.
Since I didn't want to rely on CPU0 being the boot-cpu, or even
existing at all, track the boot CPU in a variable.
Fixes: 383776fa7527 ("locking/lockdep: Handle statically initialized PER_CPU locks properly")
Reported-by: kernel test robot <fengguang.wu@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -120,6 +120,13 @@ extern unsigned int setup_max_cpus;
extern void __init setup_nr_cpu_ids(void);
extern void __init smp_init(void);
+extern int __boot_cpu_id;
+
+static inline int boot_cpu_id(void)
+{
+ return __boot_cpu_id;
+}
+
#else /* !SMP */
static inline void smp_send_stop(void) { }
@@ -158,6 +165,11 @@ static inline void smp_init(void) { up_l
static inline void smp_init(void) { }
#endif
+static inline int boot_cpu_id(void)
+{
+ return 0;
+}
+
#endif /* !SMP */
/*
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1125,6 +1125,8 @@ core_initcall(cpu_hotplug_pm_sync_init);
#endif /* CONFIG_PM_SLEEP_SMP */
+int __boot_cpu_id;
+
#endif /* CONFIG_SMP */
/* Boot processor state steps */
@@ -1815,6 +1817,10 @@ void __init boot_cpu_init(void)
set_cpu_active(cpu, true);
set_cpu_present(cpu, true);
set_cpu_possible(cpu, true);
+
+#ifdef CONFIG_SMP
+ __boot_cpu_id = cpu;
+#endif
}
/*
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -682,8 +682,11 @@ bool __is_module_percpu_address(unsigned
void *va = (void *)addr;
if (va >= start && va < start + mod->percpu_size) {
- if (can_addr)
+ if (can_addr) {
*can_addr = (unsigned long) (va - start);
+ *can_addr += (unsigned long)
+ per_cpu_ptr(mod->percpu, boot_cpu_id());
+ }
preempt_enable();
return true;
}
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1296,8 +1296,11 @@ bool __is_kernel_percpu_address(unsigned
void *va = (void *)addr;
if (va >= start && va < start + static_size) {
- if (can_addr)
+ if (can_addr) {
*can_addr = (unsigned long) (va - start);
+ *can_addr += (unsigned long)
+ per_cpu_ptr(base, boot_cpu_id());
+ }
return true;
}
}
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2017-03-25 19:20 +0100 |
| Message-ID | <toYs9-4Ag-3@gated-at.bofh.it> |
| In reply to | #1604428 |
On Mon, Mar 20, 2017 at 12:41:08PM +0100, Peter Zijlstra wrote:
> Subject: lockdep: Fix per-cpu static objects
> From: Peter Zijlstra <peterz@infradead.org>
> Date: Mon Mar 20 12:26:55 CET 2017
>
> Since commit:
>
> 383776fa7527 ("locking/lockdep: Handle statically initialized PER_CPU locks properly")
>
> we try to collapse per-cpu locks into a single class by giving them
> all the same key. For this key we choose the canonical address of the
> per-cpu object, which would be the offset into the per-cpu area.
>
> This has two problems:
>
> - there is a case where we run !0 lock->key through static_obj() and
> expect this to pass; it doesn't for canonical pointers.
>
> - 0 is a valid canonical address.
>
> Cure both issues by redefining the canonical address as the address of
> the per-cpu variable on the boot CPU.
>
> Since I didn't want to rely on CPU0 being the boot-cpu, or even
> existing at all, track the boot CPU in a variable.
>
> Fixes: 383776fa7527 ("locking/lockdep: Handle statically initialized PER_CPU locks properly")
> Reported-by: kernel test robot <fengguang.wu@intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Borislav Petkov <bp@suse.de>
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Peter Zijlstra <tipbot@zytor.com> |
|---|---|
| Date | 2017-03-26 11:50 +0200 |
| Subject | [tip:locking/core] lockdep: Fix per-cpu static objects |
| Message-ID | <tpcYa-6pH-3@gated-at.bofh.it> |
| In reply to | #1604428 |
Commit-ID: 4ef9ea9524c0015e551d062ac75ab9fd04365277
Gitweb: http://git.kernel.org/tip/4ef9ea9524c0015e551d062ac75ab9fd04365277
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 20 Mar 2017 12:26:55 +0100
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 26 Mar 2017 11:27:42 +0200
lockdep: Fix per-cpu static objects
Since commit 383776fa7527 ("locking/lockdep: Handle statically initialized
PER_CPU locks properly") we try to collapse per-cpu locks into a single
class by giving them all the same key. For this key we choose the canonical
address of the per-cpu object, which would be the offset into the per-cpu
area.
This has two problems:
- there is a case where we run !0 lock->key through static_obj() and
expect this to pass; it doesn't for canonical pointers.
- 0 is a valid canonical address.
Cure both issues by redefining the canonical address as the address of the
per-cpu variable on the boot CPU.
Since I didn't want to rely on CPU0 being the boot-cpu, or even existing at
all, track the boot CPU in a variable.
Fixes: 383776fa7527 ("locking/lockdep: Handle statically initialized PER_CPU locks properly")
Reported-by: kernel test robot <fengguang.wu@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Borislav Petkov <bp@suse.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-mm@kvack.org
Cc: wfg@linux.intel.com
Cc: kernel test robot <fengguang.wu@intel.com>
Cc: LKP <lkp@01.org>
Link: http://lkml.kernel.org/r/20170320114108.kbvcsuepem45j5cr@hirez.programming.kicks-ass.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/smp.h | 12 ++++++++++++
kernel/cpu.c | 6 ++++++
kernel/module.c | 5 ++++-
mm/percpu.c | 5 ++++-
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 8e0cb7a..8d41185 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -120,6 +120,13 @@ extern unsigned int setup_max_cpus;
extern void __init setup_nr_cpu_ids(void);
extern void __init smp_init(void);
+extern int __boot_cpu_id;
+
+static inline int boot_cpu_id(void)
+{
+ return __boot_cpu_id;
+}
+
#else /* !SMP */
static inline void smp_send_stop(void) { }
@@ -158,6 +165,11 @@ static inline void smp_init(void) { up_late_init(); }
static inline void smp_init(void) { }
#endif
+static inline int boot_cpu_id(void)
+{
+ return 0;
+}
+
#endif /* !SMP */
/*
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f7c0632..a795725 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1125,6 +1125,8 @@ core_initcall(cpu_hotplug_pm_sync_init);
#endif /* CONFIG_PM_SLEEP_SMP */
+int __boot_cpu_id;
+
#endif /* CONFIG_SMP */
/* Boot processor state steps */
@@ -1815,6 +1817,10 @@ void __init boot_cpu_init(void)
set_cpu_active(cpu, true);
set_cpu_present(cpu, true);
set_cpu_possible(cpu, true);
+
+#ifdef CONFIG_SMP
+ __boot_cpu_id = cpu;
+#endif
}
/*
diff --git a/kernel/module.c b/kernel/module.c
index 5ef6181..043ca86 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -682,8 +682,11 @@ bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
void *va = (void *)addr;
if (va >= start && va < start + mod->percpu_size) {
- if (can_addr)
+ if (can_addr) {
*can_addr = (unsigned long) (va - start);
+ *can_addr += (unsigned long)
+ per_cpu_ptr(mod->percpu, boot_cpu_id());
+ }
preempt_enable();
return true;
}
diff --git a/mm/percpu.c b/mm/percpu.c
index 7d3b728..c95b475 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1293,8 +1293,11 @@ bool __is_kernel_percpu_address(unsigned long addr, unsigned long *can_addr)
void *va = (void *)addr;
if (va >= start && va < start + static_size) {
- if (can_addr)
+ if (can_addr) {
*can_addr = (unsigned long) (va - start);
+ *can_addr += (unsigned long)
+ per_cpu_ptr(base, boot_cpu_id());
+ }
return true;
}
}
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Peter Zijlstra <tipbot@zytor.com> |
|---|---|
| Date | 2017-03-26 15:30 +0200 |
| Subject | [tip:locking/core] lockdep: Fix per-cpu static objects |
| Message-ID | <tpgp3-wE-5@gated-at.bofh.it> |
| In reply to | #1604428 |
Commit-ID: 8ce371f9846ef1e8b3cc8f6865766cb5c1f17e40
Gitweb: http://git.kernel.org/tip/8ce371f9846ef1e8b3cc8f6865766cb5c1f17e40
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 20 Mar 2017 12:26:55 +0100
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 26 Mar 2017 15:09:45 +0200
lockdep: Fix per-cpu static objects
Since commit 383776fa7527 ("locking/lockdep: Handle statically initialized
PER_CPU locks properly") we try to collapse per-cpu locks into a single
class by giving them all the same key. For this key we choose the canonical
address of the per-cpu object, which would be the offset into the per-cpu
area.
This has two problems:
- there is a case where we run !0 lock->key through static_obj() and
expect this to pass; it doesn't for canonical pointers.
- 0 is a valid canonical address.
Cure both issues by redefining the canonical address as the address of the
per-cpu variable on the boot CPU.
Since I didn't want to rely on CPU0 being the boot-cpu, or even existing at
all, track the boot CPU in a variable.
Fixes: 383776fa7527 ("locking/lockdep: Handle statically initialized PER_CPU locks properly")
Reported-by: kernel test robot <fengguang.wu@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Borislav Petkov <bp@suse.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-mm@kvack.org
Cc: wfg@linux.intel.com
Cc: kernel test robot <fengguang.wu@intel.com>
Cc: LKP <lkp@01.org>
Link: http://lkml.kernel.org/r/20170320114108.kbvcsuepem45j5cr@hirez.programming.kicks-ass.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/smp.h | 12 ++++++++++++
kernel/cpu.c | 6 ++++++
kernel/module.c | 6 +++++-
mm/percpu.c | 5 ++++-
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 8e0cb7a..68123c1 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -120,6 +120,13 @@ extern unsigned int setup_max_cpus;
extern void __init setup_nr_cpu_ids(void);
extern void __init smp_init(void);
+extern int __boot_cpu_id;
+
+static inline int get_boot_cpu_id(void)
+{
+ return __boot_cpu_id;
+}
+
#else /* !SMP */
static inline void smp_send_stop(void) { }
@@ -158,6 +165,11 @@ static inline void smp_init(void) { up_late_init(); }
static inline void smp_init(void) { }
#endif
+static inline int get_boot_cpu_id(void)
+{
+ return 0;
+}
+
#endif /* !SMP */
/*
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f7c0632..a795725 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1125,6 +1125,8 @@ core_initcall(cpu_hotplug_pm_sync_init);
#endif /* CONFIG_PM_SLEEP_SMP */
+int __boot_cpu_id;
+
#endif /* CONFIG_SMP */
/* Boot processor state steps */
@@ -1815,6 +1817,10 @@ void __init boot_cpu_init(void)
set_cpu_active(cpu, true);
set_cpu_present(cpu, true);
set_cpu_possible(cpu, true);
+
+#ifdef CONFIG_SMP
+ __boot_cpu_id = cpu;
+#endif
}
/*
diff --git a/kernel/module.c b/kernel/module.c
index 5ef6181..6d99880 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -682,8 +682,12 @@ bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
void *va = (void *)addr;
if (va >= start && va < start + mod->percpu_size) {
- if (can_addr)
+ if (can_addr) {
*can_addr = (unsigned long) (va - start);
+ *can_addr += (unsigned long)
+ per_cpu_ptr(mod->percpu,
+ get_boot_cpu_id());
+ }
preempt_enable();
return true;
}
diff --git a/mm/percpu.c b/mm/percpu.c
index 7d3b728..bd74167 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1293,8 +1293,11 @@ bool __is_kernel_percpu_address(unsigned long addr, unsigned long *can_addr)
void *va = (void *)addr;
if (va >= start && va < start + static_size) {
- if (can_addr)
+ if (can_addr) {
*can_addr = (unsigned long) (va - start);
+ *can_addr += (unsigned long)
+ per_cpu_ptr(base, get_boot_cpu_id());
+ }
return true;
}
}
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web