Re: [PATCH] cpumask 5/10 rewrite cpumask.h - single bitmap based implementation

Rusty Russell
2004-06-06T23:22:34Z

On Sun, 2004-06-06 at 22:16, Paul Jackson wrote:
> Rusty wrote:
> > Yes, NR_CPUS needs to get to userspace somehow sanely if we want to fix
> > this in general.
>
> Are you saying that NR_CPUS is needed, or just the number of longs in a
> cpumask (sizeof (cpumask_t), essentially)?

You're right. Three things are required.

1) Access to cpu_online_map (currently usually intuited from
/proc/cpuinfo)
2) Notification of cpu add/remove (currently via /sbin/hotplug)
3) Minimum size of cpumask_t (currently hardcoded, could be detected by
looping).

Although we don't, in general, know the size of long (think i386 binary
on x86_64), in practice if you always round NR_CPUS up to 64-bits you
can get #3.

> I am a firm believer in passing the minimum essential information across
> major boundaries. Passing too much creates maintaince problems, and
> encourages misuse of information, resulting in bogus user code.

In this case, though, the early example programs for setaffinity all
used "unsigned long mask; sys_sched_setaffinity(...&mask,
sizeof(mask))", which was both simple and wrong. Similarly, getaffinity
users who didn't zero the mask before handing it to the kernel.

Oh well,
Rusty.
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell