All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi.com>
To: Mike Galbraith <efault@gmx.de>
Cc: vatsa@in.ibm.com, mingo@elte.hu, nickpiggin@yahoo.com.au,
	sam@vilain.net, linux-kernel@vger.kernel.org, dev@openvz.org,
	balbir@in.ibm.com, sekharan@us.ibm.com, akpm@osdl.org,
	nagar@watson.ibm.com, matthltc@us.ibm.com, dipankar@in.ibm.com
Subject: Re: [PATCH 7/7] CPU controller V1 - (temporary) cpuset interface
Date: Tue, 22 Aug 2006 11:55:40 -0700	[thread overview]
Message-ID: <20060822115540.627de867.pj@sgi.com> (raw)
In-Reply-To: <1156269661.4954.6.camel@Homer.simpson.net>

Mike wrote:
> By cat'ing each task pid
> (including init's) to root (or mikeg) task's file?

I guess you meant:
  echo'ing
not:
  cat'ing

Lets say for example one has cpusets:
    /dev/cpuset
    /dev/cpuset/foo

One cannot move the tasks in 'foo' to the top (root) cpuset by doing:

    cat < /dev/cpuset/foo/tasks > /dev/cpuset/tasks    		# fails

That cat fails because the tasks file has to be written one pid at a
time, not in big buffered writes of multiple lines like cat does.

The usual code for doing this move is:

    while read i
    do
	/bin/echo $i > /dev/cpuset/tasks
    done < /dev/cpuset/foo/tasks

There is a cute trick that lets you move all the tasks in one cpuset to
another cpuset in a one-liner, by making use of the "sed -u" unbuffered
option:

    sed -nu p < /dev/cpuset/foo/tasks > /dev/cpuset/tasks	# works

For serious production work, the above is still racey.  A task could be
added to the 'foo' cpuset when another task in 'foo' forks while the
copying is being done.  The following loop minimizes (doesn't perfectly
solve) this race:

    while test -s /dev/cpsuet/foo/tasks
    do
	sed -nu p < /dev/cpuset/foo/tasks > /dev/cpuset/tasks
    done

The above loop is still theoretically racey with fork, but seems to
work in practice.

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@sgi.com> 1.925.600.0401

  parent reply	other threads:[~2006-08-22 18:56 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-20 17:40 [PATCH 0/7] CPU controller - V1 Srivatsa Vaddagiri
2006-08-20 17:41 ` [PATCH 1/7] CPU controller V1 - split runqueue Srivatsa Vaddagiri
2006-08-25 12:38   ` Kirill Korotaev
2006-08-28  3:33     ` Srivatsa Vaddagiri
2006-08-28  8:15       ` Kirill Korotaev
2006-08-28 11:03         ` Srivatsa Vaddagiri
2006-08-28 12:31           ` Nick Piggin
2006-08-28 12:52             ` Srivatsa Vaddagiri
2006-08-20 17:42 ` [PATCH 2/7] CPU controller V1 - define group operations Srivatsa Vaddagiri
2006-08-20 17:44 ` [PATCH 3/7] CPU controller V1 - deal with movement of tasks Srivatsa Vaddagiri
2006-08-20 17:45 ` [PATCH 4/7] CPU controller V1 - Handle dont care groups Srivatsa Vaddagiri
2006-08-20 17:46 ` [PATCH 5/7] CPU controller V1 - Extend smpnice to be task-group aware Srivatsa Vaddagiri
2006-08-20 17:47 ` [PATCH 6/7] CPU controller V1 - task_cpu(p) needs to be correct always Srivatsa Vaddagiri
2006-08-20 17:48 ` [PATCH 7/7] CPU controller V1 - (temporary) cpuset interface Srivatsa Vaddagiri
2006-08-20 20:48   ` Paul Jackson
2006-08-21 17:49     ` Srivatsa Vaddagiri
2006-08-28  1:50       ` Paul Jackson
2006-08-22 11:10   ` Mike Galbraith
2006-08-22 10:10     ` Srivatsa Vaddagiri
2006-08-22 14:41       ` Mike Galbraith
2006-08-22 15:23         ` Mike Galbraith
2006-08-22 14:01           ` Srivatsa Vaddagiri
2006-08-22 18:01             ` Mike Galbraith
2006-08-22 15:58               ` Srivatsa Vaddagiri
2006-08-22 18:55               ` Paul Jackson [this message]
2006-08-22 15:45           ` Mike Galbraith
2006-08-22 13:50             ` Srivatsa Vaddagiri
2006-08-22 18:05               ` Mike Galbraith
2006-08-22 16:02                 ` Srivatsa Vaddagiri
2006-08-22 19:09                   ` Mike Galbraith
2006-08-23  9:43   ` Mike Galbraith
2006-08-23 15:24     ` Mike Galbraith
2006-08-23 13:25       ` Srivatsa Vaddagiri
2006-08-21 10:42 ` [PATCH 0/7] CPU controller - V1 Mike Galbraith
2006-08-21 12:48   ` Srivatsa Vaddagiri
2006-08-21 17:10     ` Mike Galbraith
2006-08-21 16:45       ` Srivatsa Vaddagiri
2006-08-21 20:33         ` Mike Galbraith
2006-08-21 18:36           ` Srivatsa Vaddagiri

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=20060822115540.627de867.pj@sgi.com \
    --to=pj@sgi.com \
    --cc=akpm@osdl.org \
    --cc=balbir@in.ibm.com \
    --cc=dev@openvz.org \
    --cc=dipankar@in.ibm.com \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthltc@us.ibm.com \
    --cc=mingo@elte.hu \
    --cc=nagar@watson.ibm.com \
    --cc=nickpiggin@yahoo.com.au \
    --cc=sam@vilain.net \
    --cc=sekharan@us.ibm.com \
    --cc=vatsa@in.ibm.com \
    /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.