lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20060822115540.627de867.pj@sgi.com>
Date:	Tue, 22 Aug 2006 11:55:40 -0700
From:	Paul Jackson <pj@....com>
To:	Mike Galbraith <efault@....de>
Cc:	vatsa@...ibm.com, mingo@...e.hu, nickpiggin@...oo.com.au,
	sam@...ain.net, linux-kernel@...r.kernel.org, dev@...nvz.org,
	balbir@...ibm.com, sekharan@...ibm.com, akpm@...l.org,
	nagar@...son.ibm.com, matthltc@...ibm.com, dipankar@...ibm.com
Subject: Re: [PATCH 7/7] CPU controller V1 - (temporary) cpuset interface

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@....com> 1.925.600.0401
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ