All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Dobson <colpatch@us.ibm.com>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][PATCH] cpus_allowed/launch_policy patch, 2.4.16
Date: Wed, 05 Dec 2001 18:17:18 -0800	[thread overview]
Message-ID: <3C0ED52E.B15F0ED7@us.ibm.com> (raw)
In-Reply-To: <3C0ECBE0.F21464FA@us.ibm.com> <Pine.LNX.4.40.0112051800400.1644-100000@blue1.dev.mcafeelabs.com>

Davide Libenzi wrote:
> 
> On Wed, 5 Dec 2001, Matthew Dobson wrote:
> 
> > In response (albeit a week plus late) to the recent hubbub about the cpu
> > affinity patches,
> > I'd like to throw a third contender in the ring.
> >
> > Attatched is a patch (against 2.4.16) which implements a /proc and a prctl()
> > interface to
> > the cpus_allowed flag.  The truly exciting (at least for me) part of this patch
> > is the
> > launch_policy flag that it also introduces.  The launch_policy flag is used
> > similarly to
> > the cpus_allowed flag, but it controls the cpus_allowed flags of any subsequent
> > children
> > of the process, instead of the cpus_allowed of the process itself.  Via this
> > flag, there
> > are no worries about processes being able to fork children before a 'chaff' or
> > 'echo' or
> > anything else for that matter can be executed.  The child process is assigned
> > the desired
> > cpus_allowed at fork/exec time.  All this without having to bounce the current
> > process to
> > different cpus to (hopefully) acheive the same results.
> >
> > The launch_policy flag can acually be quite powerful.  It allows for children
> > to be
> > instantiated on the correct cpu/node with a minimum of memory footprint on the
> > wrong
> > cpu/node.  This can be taken advantage of via the /proc interface (for smp/numa
> > unaware
> > programs) or through prctl() for more clueful programs.
> 
> What you probably want to do in real life is to move a process to a cpu
> and have all its child spawned on that cpu, that is the actual behavior.
If you want a process moved, you change cpus_allowed; if you want the children
spawned
somewhere in particular, you change launch_policy; if you really want both, you
change both...

> Can't You achieve the same by coding a :
> 
\x03> pid_t affine_fork(int cpumask) {
>         pid_t pp = fork();
>         if (pp == 0) {
>                 set_affinity(getpid(), cpumask);
>                 ...
>         }
>         return pp;
> } 
>
> in your application and having the default bahavior to propagate it to the
> following fork()s.
you could do that, but that means you have to keep track of the cpumask
somewhere.
i suppose you could force your children to:

pid_t enforce_launch_policy_fork() {
        pid_t pp = fork();
        if (pp == 0) {
                set_affinity(getpid(), get_affinity());
                ...
        }
        return pp;
}

but, as soon as one of them exec()'s their no longer going to be using your
functions.
By making it a default part of fork's behavior, processes naturally end up
where they're
supposed to be.  And the default launch_policy if 0xffffffff, so unless you
purposely
change launch_policy, the old default behavior (run wherever you can) is
preserved.

> 
> > +int proc_pid_cpus_allowed_read(struct task_struct *task, char * buffer)
>        ^^^^^^^^^^^^^^^^^^^^^^^^^^
> You want Al Viro screaming, don't You ? :)
> 
> - Davide
If that is the biggest complaint about the patch, then I'll be quite happy
with some yelling and screaming about descriptive function names! ;)

Cheers!

-matt



> 
> -
> 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/

  reply	other threads:[~2001-12-06  2:22 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-22  8:59 [patch] sched_[set|get]_affinity() syscall, 2.4.15-pre9 Ingo Molnar
2001-11-22 20:22 ` Davide Libenzi
2001-11-22 23:45 ` Robert Love
2001-11-23  0:20   ` Ryan Cumming
2001-11-23  0:36     ` Mark Hahn
2001-11-23 11:46       ` Ingo Molnar
2001-11-24 22:44         ` Davide Libenzi
2001-11-23  0:51     ` Robert Love
2001-11-23  1:11       ` Andreas Dilger
2001-11-23  1:16         ` Robert Love
2001-11-23 11:36     ` Ingo Molnar
2001-11-24  2:01       ` Davide Libenzi
2001-11-27  3:39     ` Robert Love
2001-11-27  7:13       ` Joe Korty
2001-11-27 20:53         ` Robert Love
2001-11-27 21:31           ` Nathan Dabney
2001-11-27  8:04       ` procfs bloat, syscall bloat [in reference to cpu affinity] Joe Korty
2001-11-27 11:32         ` Ingo Molnar
2001-11-27 20:56           ` Robert Love
2001-11-27 14:04         ` Phil Howard
2001-11-27 18:05           ` Tim Hockin
2001-11-27  8:40       ` [patch] sched_[set|get]_affinity() syscall, 2.4.15-pre9 Ingo Molnar
2001-11-27  4:41     ` a nohup-like interface to cpu affinity Linux maillist account
2001-11-27  4:49       ` Robert Love
2001-11-27  6:32       ` Linux maillist account
2001-11-27  6:39         ` Robert Love
2001-11-27  8:42           ` Sean Hunter
2001-12-06  1:35         ` Matthew Dobson
2001-12-06  1:37         ` [RFC][PATCH] cpus_allowed/launch_policy patch, 2.4.16 Matthew Dobson
2001-12-06  2:08           ` Davide Libenzi
2001-12-06  2:17             ` Matthew Dobson [this message]
2001-12-06  2:39               ` Davide Libenzi
2001-12-06  2:42               ` Robert Love
2001-12-06 22:21                 ` Matthew Dobson
2001-11-27  6:50       ` a nohup-like interface to cpu affinity Linux maillist account
2001-11-27  8:26       ` Ingo Molnar
2001-11-23 11:02   ` [patch] sched_[set|get]_affinity() syscall, 2.4.15-pre9 Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C0ED52E.B15F0ED7@us.ibm.com \
    --to=colpatch@us.ibm.com \
    --cc=davidel@xmailserver.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.