Skip to contentSkip to conversation

2.5.61: x86_64 num_online_cpus() buglet?

DISCUSSION Mikael Pettersson 3 participants 3 messages Feb 17, 2003 – Feb 18, 2003

lore
Share & tools
lore
#0 lore raw

Andi,

Kernel 2.5.61's include/asm-x86_64/smp.h contains:

extern unsigned long cpu_online_map;
...
extern inline unsigned int num_online_cpus(void)

{ 
	return hweight32(cpu_online_map);
} 

and similarly for cpu_callout_map.

hweight32() truncates a 64-bit operand to 32-bits, so either
- the maps should be int rather than long, or
- x86_64 needs to define and use a new hweight64(), or
- CONFIG_NR_CPUS must not exceed 32 on x86_64.

Comments?

/Mikael

#1 lore raw
Quoted 11 lines · Mikael Pettersson

Andi,

Kernel 2.5.61's include/asm-x86_64/smp.h contains:

extern unsigned long cpu_online_map;
...
extern inline unsigned int num_online_cpus(void)

{ 
	return hweight32(cpu_online_map);
} 
Quoted 8 lines

and similarly for cpu_callout_map.

hweight32() truncates a 64-bit operand to 32-bits, so either
- the maps should be int rather than long, or
- x86_64 needs to define and use a new hweight64(), or
- CONFIG_NR_CPUS must not exceed 32 on x86_64.

Comments?

You're right - it should use hweight64. Thanks for the headup. I'll fix it.

Currently the x86-64 port is limited to 8 CPUs because the APIC drivers don't support cluster mode (yet) and can only talk to 8 local apics, so it isn't that harmful.

-Andi

#2 lore raw
Quoted 2 lines · Andi Kleen

You're right - it should use hweight64. Thanks for the headup. I'll fix it.

Can someone finally add a hweight64() to the generic code? I've been avoiding usage of hweight64() anywhere for this very reason.