Re: [PATCH] proc-based cpu affinity user interface

From: Albert D. Cahalan (acahalan@cs.uml.edu)
Date: Mon Dec 10 2001 - 03:33:05 EST


> I've been working on a patch that is a roll up of Andrew Morton's patch, and
> also of some work by Nick Pollitt to use a prctl() interface to the
> cpus_allowed bitmask. It also includes a new bitmask 'launch_policy' which
> allows a process to set a launch policy which is used to determine it's
> childrens' cpus_allowed bitmasks prior to launch.

It looks like you are limiting the number of CPUs to sizeof(long).
Must you? Using "%lx" would be better in any case. Considering that
you may outgrow the format, maybe this info doesn't belong in the
/proc/*/stat files at all. For "ps" usage, a simple flag to indicate
if the process is locked to a CPU would be OK. There are 3 cases
of interest:

1. can run on all CPUs
2. can run on only the currently used CPU
3. can run on some subset of the available CPUs

(defined sanely for 1-CPU and 2-CPU systems of course)

> diff -Nur linux-2.4.10/fs/proc/array.c linux-2.4.10-launch_policy/fs/proc/array.c
> --- linux-2.4.10/fs/proc/array.c Fri Oct 26 15:07:16 2001
> +++ linux-2.4.10-launch_policy/fs/proc/array.c Thu Nov 15 13:38:57 2001
> @@ -50,6 +50,10 @@
> * Al Viro & Jeff Garzik : moved most of the thing into base.c and
> * : proc_misc.c. The rest may eventually go into
> * : base.c too.
> + *
> + * Andrew Morton : cpus_allowed
> + *
> + * Matthew Dobson : launch_policy (Thanks to Andrew Morton for inspiraton)
> */
>
> #include <linux/config.h>
> @@ -343,7 +347,7 @@
> read_unlock(&tasklist_lock);
> res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
> %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu \
> -%lu %lu %lu %lu %lu %lu %lu %lu %d %d\n",
> +%lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n",
> task->pid,
> task->comm,
> state,
> @@ -386,7 +390,9 @@
> task->nswap,
> task->cnswap,
> task->exit_signal,
> - task->processor);
> + task->processor,
> + task->cpus_allowed,
> + task->launch_policy);
-
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/



This archive was generated by hypermail 2b29 : Sat Dec 15 2001 - 21:00:16 EST