Re: [PATCH] 2.5: task cpu affinity syscalls

Robert Love (rml@tech9.net)
11 Apr 2002 15:00:03 -0400


On Thu, 2002-04-11 at 10:23, Aneesh Kumar K.V wrote:

> Now that we have API that allow a process to say I would like to go to
> these CPU, Are there any API's available that will allow a CPU to say I
> will take only these process. ( Resource Affinity domains ? )

First, the Linux scheduler is not really designed to do this. It's cpu
affinity works on a per-process basis and in fact needs to explicitly
move CPUs from each CPU. Second, we could probably do this in userspace
using the exported sched_setaffinity syscall (just loop over all tasks,
setting the affinity as-needed).

There is a problem, though. In 2.5 with the O(1) scheduler, if the
process is not currently running on an allowed CPU when it is affined,
it must be forced off to a legal CPU via the migration threads. This is
expensive and complex and _not_ something we want to do to every process
on the system.

For this reason, and because I honestly favor the simple interfaces I
wrote, I think we should stick with just the exported interfaces we
currently have.

This isn't to say we could not do this in userspace - it would not be
hard (but still gross to move mass processes around). We could also
have a version of init that affines itself on boot, thereby having every
other process likewise affined. Then explicitly move away those
processes we want elsewhere. This is cheap and easy.

Robert Love

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/