linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Is register_cpu() now obligatory?
@ 2012-01-09  1:00 Richard Weinberger
  2012-01-09  2:36 ` Randy Dunlap
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2012-01-09  1:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, user-mode-linux-devel

[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]

Hi!

In Linus' tree as of today UML is broken.
It's crashing because get_cpu_device() in topology_add_dev()
returns a device with an invalid kobj (address is 0x10).

The code seems to assume that each arch has to register their CPUs
using register_cpu().

Is this a regression or was UML always faulty because it did not register it's CPU?

The below patch fixes the issue for UML.

Thanks,
//richard

---
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index bc49474..f3b43fe 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -12,7 +12,7 @@ clean-files :=
 obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \
 	physmem.o process.o ptrace.o reboot.o sigio.o \
 	signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o \
-	um_arch.o umid.o skas/
+	um_arch.o umid.o cpu.o skas/

 obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
 obj-$(CONFIG_GPROF)	+= gprof_syms.o
diff --git a/arch/um/kernel/cpu.c b/arch/um/kernel/cpu.c
new file mode 100644
index 0000000..4914df2
--- /dev/null
+++ b/arch/um/kernel/cpu.c
@@ -0,0 +1,19 @@
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/cpu.h>
+#include <linux/percpu.h>
+
+static DEFINE_PER_CPU(struct cpu, cpu_devices);
+
+static int __init topology_init(void)
+{
+	int cpu;
+
+	for_each_possible_cpu(cpu) {
+		struct cpu *c = &per_cpu(cpu_devices, cpu);
+		register_cpu(c, cpu);
+	}
+
+	return 0;
+}
+subsys_initcall(topology_init);


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Is register_cpu() now obligatory?
  2012-01-09  1:00 Is register_cpu() now obligatory? Richard Weinberger
@ 2012-01-09  2:36 ` Randy Dunlap
  0 siblings, 0 replies; 2+ messages in thread
From: Randy Dunlap @ 2012-01-09  2:36 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-kernel, gregkh, user-mode-linux-devel

On 01/08/2012 05:00 PM, Richard Weinberger wrote:
> Hi!
> 
> In Linus' tree as of today UML is broken.
> It's crashing because get_cpu_device() in topology_add_dev()
> returns a device with an invalid kobj (address is 0x10).
> 
> The code seems to assume that each arch has to register their CPUs
> using register_cpu().
> 
> Is this a regression or was UML always faulty because it did not register it's CPU?

See Linus's comment yesterday:
  https://lkml.org/lkml/2012/1/7/114


> The below patch fixes the issue for UML.
> 
> Thanks,
> //richard
> 
> ---
> diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
> index bc49474..f3b43fe 100644
> --- a/arch/um/kernel/Makefile
> +++ b/arch/um/kernel/Makefile
> @@ -12,7 +12,7 @@ clean-files :=
>  obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \
>  	physmem.o process.o ptrace.o reboot.o sigio.o \
>  	signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o \
> -	um_arch.o umid.o skas/
> +	um_arch.o umid.o cpu.o skas/
> 
>  obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
>  obj-$(CONFIG_GPROF)	+= gprof_syms.o
> diff --git a/arch/um/kernel/cpu.c b/arch/um/kernel/cpu.c
> new file mode 100644
> index 0000000..4914df2
> --- /dev/null
> +++ b/arch/um/kernel/cpu.c
> @@ -0,0 +1,19 @@
> +#include <linux/init.h>
> +#include <linux/device.h>
> +#include <linux/cpu.h>
> +#include <linux/percpu.h>
> +
> +static DEFINE_PER_CPU(struct cpu, cpu_devices);
> +
> +static int __init topology_init(void)
> +{
> +	int cpu;
> +
> +	for_each_possible_cpu(cpu) {
> +		struct cpu *c = &per_cpu(cpu_devices, cpu);
> +		register_cpu(c, cpu);
> +	}
> +
> +	return 0;
> +}
> +subsys_initcall(topology_init);
> 


-- 
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-09  1:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-09  1:00 Is register_cpu() now obligatory? Richard Weinberger
2012-01-09  2:36 ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).