Subject: Re: Syscalls to set CPU affinity
To: Andrew Doran <ad@netbsd.org>
From: Roman Divacky <rdivacky@freebsd.org>
List: tech-kern
Date: 09/12/2007 11:56:44
On Wed, Sep 12, 2007 at 02:13:11AM +0100, Andrew Doran wrote:
> On Mon, Sep 10, 2007 at 02:06:25AM +0300, Mindaugas R. wrote:
> > Hello,
> > 
> > I would like to discuss the API for setting and getting the affinity for
> > processes and threads, and operations with CPU sets. My suggestion would be
> > adopting the Solaris API, which looks flexible and good for compatibility:
> > 
> > int processor_bind(idtype_t idtype, id_t id, processorid_t processorid,
> >     processorid_t *obind);
> > 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);
> > 
> > Calls of Linux API can set affinity only for processes, however I think it
> > would be reasonable to have a support for Linux affinity calls in libpthread
> > for compatibility purposes:
> > 
> > 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?

note that "pid" in linux is actually "thread id" while "tgid" is what we understand
as "pid"... so it makes sense while I agree its confusing

roman