2003-01-17 04:51:37

by Zwane Mwaikambo

[permalink] [raw]
Subject: [PATCH][2.5] fix for_each_cpu compilation on UP

This adds a definition for for_each_cpu when !CONFIG_SMP

Please apply

Index: linux-2.5.58-cpu_hotplug/include/linux/smp.h
===================================================================
RCS file: /build/cvsroot/linux-2.5.58/include/linux/smp.h,v
retrieving revision 1.1.1.1.2.3
diff -u -r1.1.1.1.2.3 smp.h
--- linux-2.5.58-cpu_hotplug/include/linux/smp.h 17 Jan 2003 03:13:12 -0000 1.1.1.1.2.3
+++ linux-2.5.58-cpu_hotplug/include/linux/smp.h 17 Jan 2003 03:14:40 -0000
@@ -109,6 +109,7 @@
#define num_booting_cpus() 1
#define cpu_possible(cpu) ({ BUG_ON((cpu) != 0); 1; })
#define smp_prepare_boot_cpu() do {} while (0)
+#define for_each_cpu(cpu, mask) for (cpu = 0; cpu == 0; cpu++)

struct notifier_block;


--
function.linuxpower.ca


2003-01-17 05:44:26

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH][2.5] fix for_each_cpu compilation on UP

Zwane Mwaikambo <[email protected]> wrote:
>
> This adds a definition for for_each_cpu when !CONFIG_SMP
>
> Please apply
>
> Index: linux-2.5.58-cpu_hotplug/include/linux/smp.h
> ===================================================================
> RCS file: /build/cvsroot/linux-2.5.58/include/linux/smp.h,v
> retrieving revision 1.1.1.1.2.3
> diff -u -r1.1.1.1.2.3 smp.h
> --- linux-2.5.58-cpu_hotplug/include/linux/smp.h 17 Jan 2003 03:13:12 -0000 1.1.1.1.2.3
> +++ linux-2.5.58-cpu_hotplug/include/linux/smp.h 17 Jan 2003 03:14:40 -0000
> @@ -109,6 +109,7 @@
> #define num_booting_cpus() 1
> #define cpu_possible(cpu) ({ BUG_ON((cpu) != 0); 1; })
> #define smp_prepare_boot_cpu() do {} while (0)
> +#define for_each_cpu(cpu, mask) for (cpu = 0; cpu == 0; cpu++)
>

This will cause nasty warnings (and posibly break) x86_64 builds, which
define their own for_each_cpu() in the !CONFIG_SMP case.

wimpy fix: move this into include/asm-i386/smp.h

nice fix: do a generic for_each_cpu() in include/linux/wherever.h, and rip
out the arch-private definitions.


2003-01-17 14:55:07

by James Bottomley

[permalink] [raw]
Subject: Re: [PATCH][2.5] fix for_each_cpu compilation on UP

[email protected] said:
> This adds a definition for for_each_cpu when !CONFIG_SMP
> Please apply

Could you elaborate on the purpose of this a bit? for_each_cpu() is only used
by the voyager subarch on x86 to traverse sparse CPU bitmaps efficiently in
critical path code. It has no other use in x86 SMP because all other
subarch's tend to compact the CPU bitmap much more.

If there are other uses for the construct, it should probably be put in bitops
and become for_each_bit(i, mask)

James


2003-01-17 16:35:03

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: [PATCH][2.5] fix for_each_cpu compilation on UP

On Fri, 17 Jan 2003, James Bottomley wrote:

> [email protected] said:
> > This adds a definition for for_each_cpu when !CONFIG_SMP
> > Please apply
>
> Could you elaborate on the purpose of this a bit? for_each_cpu() is only used
> by the voyager subarch on x86 to traverse sparse CPU bitmaps efficiently in
> critical path code. It has no other use in x86 SMP because all other
> subarch's tend to compact the CPU bitmap much more.
>
> If there are other uses for the construct, it should probably be put in bitops
> and become for_each_bit(i, mask)

It's still useful in the general case for avoiding access of per cpu
memory when a cpu is offline as well as avoiding triggering events on
cpus which aren't online anymore. I'm going to hold back on this for a bit
till i actually release the code which depends on this infrastructure.

Zwane
--
function.linuxpower.ca