2002-06-19 03:20:50

by John Weber

[permalink] [raw]
Subject: Linux 2.5.23 cpu_online_map undeclared

I am running on a UP system, so I don't believe that cpu_online_map
should be declared. Any suggestions?

gcc -Wp,-MD,./.sched.o.d -D__KERNEL__ -I/usr/src/linux-2.5.23/include
-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
-march=i686 -nostdinc -iwithprefix include -fno-omit-frame-pointer
-DKBUILD_BASENAME=sched -c -o sched.o sched.c
sched.c: In function `sys_sched_setaffinity':
sched.c:1332: `cpu_online_map' undeclared (first use in this function)
sched.c:1332: (Each undeclared identifier is reported only once
sched.c:1332: for each function it appears in.)
sched.c: In function `sys_sched_getaffinity':
sched.c:1391: `cpu_online_map' undeclared (first use in this function)
make[1]: *** [sched.o] Error 1
make[1]: Leaving directory `/usr/src/linux-2.5.23/kernel'
make: *** [kernel] Error 2


-o) J o h n W e b e r
/\\ [email protected]
_\/v http://www.linuxhq.com/people/weber/


2002-06-19 05:39:17

by Linus Torvalds

[permalink] [raw]
Subject: Re: Linux 2.5.23 cpu_online_map undeclared

In article <[email protected]>,
John Weber <[email protected]> wrote:
>I am running on a UP system, so I don't believe that cpu_online_map
>should be declared. Any suggestions?

Actually, it _should_ be declared, it's just that on UP it should be
defined to the constant 1.

Somehow that #define got dropped by the hotplug-CPU stuff.

To fix, just add a

#define cpu_online_map 1

to the non-SMP parts of include/linus/smp.h. The patch looks something
like the appended (totally untested) thing.

Does that make UP happier?

Linus

--- 1.8/include/linux/smp.h Mon Jun 17 23:25:22 2002
+++ edited/include/linux/smp.h Tue Jun 18 22:30:47 2002
@@ -86,6 +86,7 @@
#define smp_call_function(func,info,retry,wait) ({ 0; })
static inline void smp_send_reschedule(int cpu) { }
static inline void smp_send_reschedule_all(void) { }
+#define cpu_online_map 1
#define cpu_online(cpu) 1
#define num_online_cpus() 1
#define __per_cpu_data

2002-06-19 06:40:11

by Ingo Molnar

[permalink] [raw]
Subject: Re: Linux 2.5.23 cpu_online_map undeclared


On Wed, 19 Jun 2002, Linus Torvalds wrote:

> static inline void smp_send_reschedule_all(void) { }
> +#define cpu_online_map 1
> #define cpu_online(cpu) 1

yesterday i've tested a number of UP kernels that had an equivalent fix
and this works as expected, nothing else broke.

Ingo

2002-06-20 22:55:30

by Rusty Russell

[permalink] [raw]
Subject: Re: Linux 2.5.23 cpu_online_map undeclared

On Wed, 19 Jun 2002 05:36:08 +0000 (UTC)
[email protected] (Linus Torvalds) wrote:

> Actually, it _should_ be declared, it's just that on UP it should be
> defined to the constant 1.
>
> Somehow that #define got dropped by the hotplug-CPU stuff.

Actually, was deliberate. Not exposing the mask when almost everyone
just wants to know "are any of these cpus online" was a preemptive strike
against NR_CPUS > BITS_PER_LONG (I wouldn't have bothered but I was so
close anyway).

My mistake was not noticing that x86 SMP was still exposing it and that
scheduler changes since my original patch were using it. Fixed with
cpu_online_mask(res, mask) in prior patch.

Apologies, and hope that clarifies,
Rusty.
--
there are those who do and those who hang on and you don't see too
many doers quoting their contemporaries. -- Larry McVoy