* [PATCH 1/2] topology: Check for missing CPU devices
@ 2012-01-08 20:48 Ben Hutchings
2012-01-09 0:18 ` Linus Torvalds
2012-01-09 20:13 ` Geert Uytterhoeven
0 siblings, 2 replies; 11+ messages in thread
From: Ben Hutchings @ 2012-01-08 20:48 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Linus Torvalds, Geert Uytterhoeven, Andrew Morton, linux-kernel,
Linux-Arch, Thorsten Glaser, Debian kernel team, linux-m68k,
debian-68k
Commit ccbc60d3e19a1b6ae66ca0d89b3da02dde62088b ('topology: Provide
CPU topology in sysfs in !SMP configurations') causes a crash at boot
on a several architectures. The topology sysfs code assumes that
there is a CPU device for each online CPU whereas some architectures
that do not support SMP or cpufreq do not register any CPU devices.
Check for this before trying to use a device.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
drivers/base/topology.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index ae989c5..4467c85 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -147,6 +147,8 @@ static int __cpuinit topology_add_dev(unsigned int cpu)
{
struct device *dev = get_cpu_device(cpu);
+ if (!dev)
+ return -ENODEV;
return sysfs_create_group(&dev->kobj, &topology_attr_group);
}
@@ -154,7 +156,8 @@ static void __cpuinit topology_remove_dev(unsigned int cpu)
{
struct device *dev = get_cpu_device(cpu);
- sysfs_remove_group(&dev->kobj, &topology_attr_group);
+ if (dev)
+ sysfs_remove_group(&dev->kobj, &topology_attr_group);
}
static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
--
1.7.8.2
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-08 20:48 [PATCH 1/2] topology: Check for missing CPU devices Ben Hutchings
@ 2012-01-09 0:18 ` Linus Torvalds
2012-01-09 1:06 ` richard -rw- weinberger
2012-01-09 2:47 ` Ben Hutchings
2012-01-09 20:13 ` Geert Uytterhoeven
1 sibling, 2 replies; 11+ messages in thread
From: Linus Torvalds @ 2012-01-09 0:18 UTC (permalink / raw)
To: Ben Hutchings
Cc: Greg Kroah-Hartman, Geert Uytterhoeven, Andrew Morton,
linux-kernel, Linux-Arch, Thorsten Glaser, Debian kernel team,
linux-m68k, debian-68k
Ok, both of the patches look sane to me, but it would really be nice
to hear from somebody with the actual affected architectures, and get
a tested-by.
Testing it on hacked-up x86 sounds fine, but doesn't quite have the
same kind of "yes, this fixes the actual problem" feel to it.
Also, can you clarify: does the second patch make the first patch just
an "irrelevant safety net", or are there possible callers of
topology_add_dev() that could cause problems? I'm just wondering
whether maybe the safety net ends up then possibly hiding some future
bug where we (once more) don't register a cpu and then never really
notice?
Or am I just being difficult?
Linus
On Sun, Jan 8, 2012 at 12:48 PM, Ben Hutchings <ben@decadent.org.uk> wrote:
> Commit ccbc60d3e19a1b6ae66ca0d89b3da02dde62088b ('topology: Provide
> CPU topology in sysfs in !SMP configurations') causes a crash at boot
> on a several architectures. The topology sysfs code assumes that
> there is a CPU device for each online CPU whereas some architectures
> that do not support SMP or cpufreq do not register any CPU devices.
> Check for this before trying to use a device.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---
> drivers/base/topology.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/base/topology.c b/drivers/base/topology.c
> index ae989c5..4467c85 100644
> --- a/drivers/base/topology.c
> +++ b/drivers/base/topology.c
> @@ -147,6 +147,8 @@ static int __cpuinit topology_add_dev(unsigned int cpu)
> {
> struct device *dev = get_cpu_device(cpu);
>
> + if (!dev)
> + return -ENODEV;
> return sysfs_create_group(&dev->kobj, &topology_attr_group);
> }
>
> @@ -154,7 +156,8 @@ static void __cpuinit topology_remove_dev(unsigned int cpu)
> {
> struct device *dev = get_cpu_device(cpu);
>
> - sysfs_remove_group(&dev->kobj, &topology_attr_group);
> + if (dev)
> + sysfs_remove_group(&dev->kobj, &topology_attr_group);
> }
>
> static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
> --
> 1.7.8.2
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-09 0:18 ` Linus Torvalds
@ 2012-01-09 1:06 ` richard -rw- weinberger
2012-01-09 1:29 ` Linus Torvalds
2012-01-09 20:15 ` Geert Uytterhoeven
2012-01-09 2:47 ` Ben Hutchings
1 sibling, 2 replies; 11+ messages in thread
From: richard -rw- weinberger @ 2012-01-09 1:06 UTC (permalink / raw)
To: Linus Torvalds
Cc: Ben Hutchings, Greg Kroah-Hartman, Geert Uytterhoeven,
Andrew Morton, linux-kernel, Linux-Arch, Thorsten Glaser,
Debian kernel team, linux-m68k, debian-68k
On Mon, Jan 9, 2012 at 1:18 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> Ok, both of the patches look sane to me, but it would really be nice
> to hear from somebody with the actual affected architectures, and get
> a tested-by.
UML is affected:
https://lkml.org/lkml/2012/1/8/186
I wasted an hour finding out why it is crashing.
Instead of testing kernels I really should read more LKML. ;-)
--
Thanks,
//richard
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-09 1:06 ` richard -rw- weinberger
@ 2012-01-09 1:29 ` Linus Torvalds
2012-01-09 2:52 ` Ben Hutchings
2012-01-09 20:15 ` Geert Uytterhoeven
1 sibling, 1 reply; 11+ messages in thread
From: Linus Torvalds @ 2012-01-09 1:29 UTC (permalink / raw)
To: richard -rw- weinberger
Cc: Ben Hutchings, Greg Kroah-Hartman, Geert Uytterhoeven,
Andrew Morton, linux-kernel, Linux-Arch, Thorsten Glaser,
Debian kernel team, linux-m68k, debian-68k
On Sun, Jan 8, 2012 at 5:06 PM, richard -rw- weinberger
<richard.weinberger@gmail.com> wrote:
> On Mon, Jan 9, 2012 at 1:18 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>> Ok, both of the patches look sane to me, but it would really be nice
>> to hear from somebody with the actual affected architectures, and get
>> a tested-by.
>
> UML is affected:
> https://lkml.org/lkml/2012/1/8/186
>
> I wasted an hour finding out why it is crashing.
> Instead of testing kernels I really should read more LKML. ;-)
Hmm.
Ben - how about that
static DEFINE_PER_CPU(struct cpu, cpu_devices);
approach that Richard uses in his patch, instead of the kcalloc? And
clearly UM should also do that CONFIG_GENERIC_CPU_DEVICES thing with
your patch.
Richard - does Ben's patch work for you too if you just add "select
GENERIC_CPU_DEVICES" in the UM Kconfig too (Kconfig.common, probably)?
Linus
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-09 1:29 ` Linus Torvalds
@ 2012-01-09 2:52 ` Ben Hutchings
2012-01-09 14:19 ` Richard Weinberger
0 siblings, 1 reply; 11+ messages in thread
From: Ben Hutchings @ 2012-01-09 2:52 UTC (permalink / raw)
To: Linus Torvalds
Cc: richard -rw- weinberger, Greg Kroah-Hartman, Geert Uytterhoeven,
Andrew Morton, linux-kernel, Linux-Arch, Thorsten Glaser,
Debian kernel team, linux-m68k, debian-68k
[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]
On Sun, 2012-01-08 at 17:29 -0800, Linus Torvalds wrote:
> On Sun, Jan 8, 2012 at 5:06 PM, richard -rw- weinberger
> <richard.weinberger@gmail.com> wrote:
> > On Mon, Jan 9, 2012 at 1:18 AM, Linus Torvalds
> > <torvalds@linux-foundation.org> wrote:
> >> Ok, both of the patches look sane to me, but it would really be nice
> >> to hear from somebody with the actual affected architectures, and get
> >> a tested-by.
> >
> > UML is affected:
> > https://lkml.org/lkml/2012/1/8/186
> >
> > I wasted an hour finding out why it is crashing.
> > Instead of testing kernels I really should read more LKML. ;-)
>
> Hmm.
>
> Ben - how about that
>
> static DEFINE_PER_CPU(struct cpu, cpu_devices);
>
> approach that Richard uses in his patch, instead of the kcalloc?
That seems perfectly good.
> And
> clearly UM should also do that CONFIG_GENERIC_CPU_DEVICES thing with
> your patch.
>
> Richard - does Ben's patch work for you too if you just add "select
> GENERIC_CPU_DEVICES" in the UM Kconfig too (Kconfig.common, probably)?
Sorry, I meant to cover UM as well but I couldn't see how its Kconfig
files were organised.
Ben.
--
Ben Hutchings
Life is what happens to you while you're busy making other plans.
- John Lennon
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-09 2:52 ` Ben Hutchings
@ 2012-01-09 14:19 ` Richard Weinberger
0 siblings, 0 replies; 11+ messages in thread
From: Richard Weinberger @ 2012-01-09 14:19 UTC (permalink / raw)
To: Ben Hutchings
Cc: Linus Torvalds, richard -rw- weinberger, Greg Kroah-Hartman,
Geert Uytterhoeven, Andrew Morton, linux-kernel, Linux-Arch,
Thorsten Glaser, Debian kernel team, linux-m68k, debian-68k
[-- Attachment #1: Type: text/plain, Size: 1555 bytes --]
Am 09.01.2012 03:52, schrieb Ben Hutchings:
> On Sun, 2012-01-08 at 17:29 -0800, Linus Torvalds wrote:
>> On Sun, Jan 8, 2012 at 5:06 PM, richard -rw- weinberger
>> <richard.weinberger@gmail.com> wrote:
>>> On Mon, Jan 9, 2012 at 1:18 AM, Linus Torvalds
>>> <torvalds@linux-foundation.org> wrote:
>>>> Ok, both of the patches look sane to me, but it would really be nice
>>>> to hear from somebody with the actual affected architectures, and get
>>>> a tested-by.
>>>
>>> UML is affected:
>>> https://lkml.org/lkml/2012/1/8/186
>>>
>>> I wasted an hour finding out why it is crashing.
>>> Instead of testing kernels I really should read more LKML. ;-)
>>
>> Hmm.
>>
>> Ben - how about that
>>
>> static DEFINE_PER_CPU(struct cpu, cpu_devices);
>>
>> approach that Richard uses in his patch, instead of the kcalloc?
>
> That seems perfectly good.
>
>> And
>> clearly UM should also do that CONFIG_GENERIC_CPU_DEVICES thing with
>> your patch.
>>
>> Richard - does Ben's patch work for you too if you just add "select
>> GENERIC_CPU_DEVICES" in the UM Kconfig too (Kconfig.common, probably)?
>
Yeah, Ben's patch solves the problem too. :-)
Ben, please add the attached patch snippet to your patch.
--
diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index a923483..b37ae70 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -8,6 +8,7 @@ config UML
default y
select HAVE_GENERIC_HARDIRQS
select GENERIC_IRQ_SHOW
+ select GENERIC_CPU_DEVICES
config MMU
bool
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-09 1:06 ` richard -rw- weinberger
2012-01-09 1:29 ` Linus Torvalds
@ 2012-01-09 20:15 ` Geert Uytterhoeven
1 sibling, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2012-01-09 20:15 UTC (permalink / raw)
To: richard -rw- weinberger
Cc: Linus Torvalds, Ben Hutchings, Greg Kroah-Hartman, Andrew Morton,
linux-kernel, Linux-Arch, Thorsten Glaser, Debian kernel team,
linux-m68k, debian-68k
On Mon, Jan 9, 2012 at 02:06, richard -rw- weinberger
<richard.weinberger@gmail.com> wrote:
> Instead of testing kernels I really should read more LKML. ;-)
As an architecture maintainer, you want to read at least linux-arch.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-09 0:18 ` Linus Torvalds
2012-01-09 1:06 ` richard -rw- weinberger
@ 2012-01-09 2:47 ` Ben Hutchings
2012-01-09 2:56 ` Ben Hutchings
1 sibling, 1 reply; 11+ messages in thread
From: Ben Hutchings @ 2012-01-09 2:47 UTC (permalink / raw)
To: Linus Torvalds
Cc: Greg Kroah-Hartman, Geert Uytterhoeven, Andrew Morton,
linux-kernel, Linux-Arch, Thorsten Glaser, Debian kernel team,
linux-m68k, debian-68k
[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]
On Sun, 2012-01-08 at 16:18 -0800, Linus Torvalds wrote:
> Ok, both of the patches look sane to me, but it would really be nice
> to hear from somebody with the actual affected architectures, and get
> a tested-by.
>
> Testing it on hacked-up x86 sounds fine, but doesn't quite have the
> same kind of "yes, this fixes the actual problem" feel to it.
Indeed.
> Also, can you clarify: does the second patch make the first patch just
> an "irrelevant safety net", or are there possible callers of
> topology_add_dev() that could cause problems? I'm just wondering
> whether maybe the safety net ends up then possibly hiding some future
> bug where we (once more) don't register a cpu and then never really
> notice?
[...]
driver_init() doesn't check that cpu_dev_init() - or any of the other
functions it calls - is successful. So in theory at least we could boot
and still have no CPU devices after the first patch.
Ben.
--
Ben Hutchings
Life is what happens to you while you're busy making other plans.
- John Lennon
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-09 2:47 ` Ben Hutchings
@ 2012-01-09 2:56 ` Ben Hutchings
2012-01-09 20:23 ` Linus Torvalds
0 siblings, 1 reply; 11+ messages in thread
From: Ben Hutchings @ 2012-01-09 2:56 UTC (permalink / raw)
To: Linus Torvalds
Cc: Greg Kroah-Hartman, Geert Uytterhoeven, Andrew Morton,
linux-kernel, Linux-Arch, Thorsten Glaser, Debian kernel team,
linux-m68k, debian-68k
[-- Attachment #1: Type: text/plain, Size: 1424 bytes --]
On Mon, 2012-01-09 at 02:47 +0000, Ben Hutchings wrote:
> On Sun, 2012-01-08 at 16:18 -0800, Linus Torvalds wrote:
> > Ok, both of the patches look sane to me, but it would really be nice
> > to hear from somebody with the actual affected architectures, and get
> > a tested-by.
> >
> > Testing it on hacked-up x86 sounds fine, but doesn't quite have the
> > same kind of "yes, this fixes the actual problem" feel to it.
>
> Indeed.
>
> > Also, can you clarify: does the second patch make the first patch just
> > an "irrelevant safety net", or are there possible callers of
> > topology_add_dev() that could cause problems? I'm just wondering
> > whether maybe the safety net ends up then possibly hiding some future
> > bug where we (once more) don't register a cpu and then never really
> > notice?
> [...]
>
> driver_init() doesn't check that cpu_dev_init() - or any of the other
> functions it calls - is successful. So in theory at least we could boot
> and still have no CPU devices after the first patch.
I mean to say that we could have no CPU devices after the *second*
patch. So the first patch is an extra defence against that. (Though we
could just as well panic if register_cpu() fails at boot time.)
Ben.
--
Ben Hutchings
Life is what happens to you while you're busy making other plans.
- John Lennon
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-09 2:56 ` Ben Hutchings
@ 2012-01-09 20:23 ` Linus Torvalds
0 siblings, 0 replies; 11+ messages in thread
From: Linus Torvalds @ 2012-01-09 20:23 UTC (permalink / raw)
To: Ben Hutchings
Cc: Greg Kroah-Hartman, Geert Uytterhoeven, Andrew Morton,
linux-kernel, Linux-Arch, Thorsten Glaser, Debian kernel team,
linux-m68k, debian-68k
On Sun, Jan 8, 2012 at 6:56 PM, Ben Hutchings <ben@decadent.org.uk> wrote:
>
> I mean to say that we could have no CPU devices after the *second*
> patch. So the first patch is an extra defence against that. (Though we
> could just as well panic if register_cpu() fails at boot time.)
I think I'd rather just panic - if you have allocation issues during
early boot, the machine is hosed anyway - and then get rid of the
first patch?
Willing to send out a new patch along those lines (and with UML added)?
Thanks,
Linus
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] topology: Check for missing CPU devices
2012-01-08 20:48 [PATCH 1/2] topology: Check for missing CPU devices Ben Hutchings
2012-01-09 0:18 ` Linus Torvalds
@ 2012-01-09 20:13 ` Geert Uytterhoeven
1 sibling, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2012-01-09 20:13 UTC (permalink / raw)
To: Ben Hutchings
Cc: Greg Kroah-Hartman, Linus Torvalds, Andrew Morton, linux-kernel,
Linux-Arch, Thorsten Glaser, Debian kernel team, linux-m68k,
debian-68k
On Sun, Jan 8, 2012 at 21:48, Ben Hutchings <ben@decadent.org.uk> wrote:
> Commit ccbc60d3e19a1b6ae66ca0d89b3da02dde62088b ('topology: Provide
> CPU topology in sysfs in !SMP configurations') causes a crash at boot
> on a several architectures. The topology sysfs code assumes that
> there is a CPU device for each online CPU whereas some architectures
> that do not support SMP or cpufreq do not register any CPU devices.
> Check for this before trying to use a device.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Thanks!
Works on its own or combined with "[PATCH 2/2] cpu: Register a generic
CPU device on architectures that currently do not".
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-01-09 20:23 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-08 20:48 [PATCH 1/2] topology: Check for missing CPU devices Ben Hutchings
2012-01-09 0:18 ` Linus Torvalds
2012-01-09 1:06 ` richard -rw- weinberger
2012-01-09 1:29 ` Linus Torvalds
2012-01-09 2:52 ` Ben Hutchings
2012-01-09 14:19 ` Richard Weinberger
2012-01-09 20:15 ` Geert Uytterhoeven
2012-01-09 2:47 ` Ben Hutchings
2012-01-09 2:56 ` Ben Hutchings
2012-01-09 20:23 ` Linus Torvalds
2012-01-09 20:13 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox