All of lore.kernel.org
 help / color / mirror / Atom feed
From: Serge Hallyn <serge.hallyn-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
To: atp <Andrew.Phillips-xheW4WVAX9Y@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: cpu shielding.
Date: Mon, 6 Feb 2012 20:15:27 -0600	[thread overview]
Message-ID: <20120207021527.GA17937@sergelap> (raw)
In-Reply-To: <1328536234.32188.49.camel@foo>

Quoting atp (Andrew.Phillips-xheW4WVAX9Y@public.gmane.org):
> Hello,
> 
>   Apologies if I'm about to ask a frequently asked question - I did
> check back over the last couple of months. 
> 
>   Is anyone working on cpu shielding for processes inside a cpu cgroup? 
> 
>   We would like to run Java in containers, and unfortunately it likes to
> know how many processors there are in the system - to initialise thread
> pools and such like. 
> 
>   I was thinking along these lines;
> 
> --- fs/proc/stat.c.orig	2010-05-21 11:32:32.941258466 +0000
> +++ fs/proc/stat.c	2010-05-21 11:40:47.681259133 +0000
> @@ -39,7 +39,9 @@
>  	getboottime(&boottime);
>  	jif = boottime.tv_sec;
>  
> -	for_each_possible_cpu(i) {
> +//	for_each_possible_cpu(i) {
> +//	// refer to the visible cpus.
> +	for_each_cpu_and(i,cpu_possible_mask,(&current->cpus_allowed)) {
>  		user = cputime64_add(user, kstat_cpu(i).cpustat.user);
>  		nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
>  		system = cputime64_add(system, kstat_cpu(i).cpustat.system);
> @@ -78,7 +80,10 @@
>  		(unsigned long long)cputime64_to_clock_t(steal),
>  		(unsigned long long)cputime64_to_clock_t(guest),
>  		(unsigned long long)cputime64_to_clock_t(guest_nice));
> -	for_each_online_cpu(i) {
> +     
> +//	for_each_online_cpu(i) {
> +//	// cgroup. 
> +	for_each_cpu_and(i,cpu_online_mask,(&current->cpus_allowed)) {
>  
>  		/* Copy values here to work around gcc-2.95.3, gcc-2.96 */
>  		user = kstat_cpu(i).cpustat.user;
> 
>   I'm sure that there are nicer ways of doing this, but Serge Hallyn
> suggested a while ago that I post here. Even though it says 2010, the
> patch above looks like it will go against 3.2.4 ok. 
>   
>   Thanks,
>      Andy

I'm afraid I haven't been following recent upstream discussions on
this, but there are other people who want proc to show cgroup-limited
information.  See for instance http://lwn.net/Articles/460310/ .  Glauber
has also brought this up since then.  I'd recommend pinging him.

I'm all for /proc showing cgroup-filtered information, unconditionally.

-serge

  reply	other threads:[~2012-02-07  2:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-06 13:50 cpu shielding atp
2012-02-07  2:15 ` Serge Hallyn [this message]
2012-02-07  9:02   ` atp
2012-02-07 10:35   ` Glauber Costa
2012-02-07  3:25 ` Zhu Yanhai

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=20120207021527.GA17937@sergelap \
    --to=serge.hallyn-z7wlfzj8ewms+fvcfc7uqw@public.gmane.org \
    --cc=Andrew.Phillips-xheW4WVAX9Y@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.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.