Subject: Re: Syscalls to set CPU affinity
To: None <firstname.lastname@example.org>
From: Mindaugas R. <rmind@NetBSD.org>
Date: 09/15/2007 21:54:09
> int pset_bind(psetid_t pset, idtype_t idtype, id_t id, psetid_t *opset);
> int pset_create(psetid_t *newpset);
> int pset_destroy(psetid_t pset);
> int pset_assign(psetid_t pset, processorid_t cpu, psetid_t *opset);
The only thing I am not sure is a definition of psetid_t. After some
thinking, perhaps such one would be OK for now:
typedef int32_t psetid_t;
However, in future I would like to see the ability to control 64 and more
processors in the set. The API allows dynamic allocation of the set, which
would be fine for the userland, but perhaps not very conformable in the
kernel. Any thoughts about these?
By the way, pset_* API is compatible with HP-UX too.
Andrew Doran <email@example.com> wrote:
> > int sched_setaffinity(pid_t pid, unsigned int cpusetsize, cpu_set_t
> > *mask); int sched_getaffinity(pid_t pid, unsigned int cpusetsize,
> > cpu_set_t *mask);
> I'm not sure how any of these work or what they do. Is there somewhere we
> can find a description? Affinity by PID seems odd, is that from before Linux
> had NPTL?
Yes, it is odd. Well, in NPTL there are also affinity calls for threads:
int pthread_setaffinity_np(pthread_t, size_t, const cpu_set_t *);
int pthread_getaffinity_np(pthread_t, size_t, cpu_set_t *);
But while they exist (and work, of course), I could not find any "official"
documentation about them.
> > Also, operations with CPU sets:
> > void CPU_CLR(int cpu, cpu_set_t *set);
> > int CPU_ISSET(int cpu, cpu_set_t *set);
> > void CPU_SET(int cpu, cpu_set_t *set);
> > void CPU_ZERO(cpu_set_t *set);
> Are these for kernel-internal use only?
No, for userland too. But please note, that it would be only for
compatibility with Linux. The question is it worth having them?