From: Paul Menage <menage@google.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Benjamin Blum <bblum@google.com>,
containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, lizf@cn.fujitzu.com
Subject: Re: [PATCH 1/2] Adds a read-only "procs" file similar to "tasks" that shows only unique tgids
Date: Wed, 15 Jul 2009 09:18:33 -0700 [thread overview]
Message-ID: <6599ad830907150918r5ed6f2cevde9dbc9ef304fb2b@mail.gmail.com> (raw)
In-Reply-To: <m1ocrm73cu.fsf@fess.ebiederm.org>
On Wed, Jul 15, 2009 at 1:33 AM, Eric W. Biederman<ebiederm@xmission.com> wrote:
>
> I think guaranteeing a truly atomic snapshot is likely to be a
> horrible idea requiring all kinds of nasty locking,
We don't guarantee a truly atomic snapshot unless you manage to read
the entire file with a single read() call.
> and smp
> scalability issues. So please walk the list of pids and
> just return those that belong to your cgroup.
The downside with that is that scanning any cgroup takes O(n) in the
number of threads on the machine, so scanning them all becomes O(n^2).
We've definitely seen problems (on older kernels using cpusets, which
did something similar, i.e. walking the tasklist) where we have lots
of small cpusets and a few huge ones, and this blew up the cost of
accessing any of them.
But having said that, the idea of being able to maintain just a cursor
is something that would definitely be nice.
Here's another idea that might work:
Currently, each cgroup has a list running through the attached css_set
objects, and each css_set has a list running through its tasks; we
iterate through these lists of lists to produce the cgroup's task list
Since this list isn't sorted in any way, there's no convenient way to
save/restore your position between seq_file invocations; this is why
we currently generate a sorted snapshot, so that even if the snapshot
is updated by someone else before our next read, we know where to pick
up from (the next pid above the last one that we returned).
Instead, we could actually store cursor objects in the list itself
whenever we need to pause/resume iterating through a large cgroup (due
to hitting the limits of a single seq_file read, i.e. probably after
every 700 threads).
Then we'd just need to teach cgroup_iter_next() to distinguish between
real tasks and cursors, and skip the latter. Simple way to do that
would be to change the existing declarations in task_struct:
#ifdef CONFIG_CGROUPS
/* Control Group info protected by css_set_lock */
struct css_set *cgroups;
/* cg_list protected by css_set_lock and tsk->alloc_lock */
struct list_head cg_list;
#endif
and instead define these two fields together as a struct
cgroup_css_list_elem. A cursor can just be a cgroup_css_list_elem
whose cgroups field points to a distinguishing address that identifies
it as a cursor.
So we're guaranteed to hit all threads that are in the cgroup before
we start, and stay there until we finish; there are no guarantees
about threads that move into or out of the cgroup while we're
iterating
It's a bit more complex than just iterating over the machine's entire
pid list, but I think it scales better.
Paul
next prev parent reply other threads:[~2009-07-15 16:18 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-02 23:26 [PATCH 0/2] CGroups: cgroup member list enhancement/fix Paul Menage
2009-07-02 23:26 ` [PATCH 1/2] Adds a read-only "procs" file similar to "tasks" that shows only unique tgids Paul Menage
2009-07-02 23:46 ` Andrew Morton
2009-07-03 0:31 ` Benjamin Blum
2009-07-03 0:53 ` Andrew Morton
2009-07-03 1:08 ` Paul Menage
2009-07-03 1:17 ` Benjamin Blum
2009-07-03 2:08 ` Andrew Morton
2009-07-03 4:16 ` Paul Menage
2009-07-03 6:55 ` Andrew Morton
2009-07-03 7:54 ` KAMEZAWA Hiroyuki
2009-07-03 16:11 ` Paul Menage
2009-07-03 16:50 ` Andrew Morton
2009-07-03 17:54 ` Paul Menage
2009-07-03 18:10 ` Andrew Morton
2009-07-15 8:33 ` Eric W. Biederman
2009-07-15 16:18 ` Paul Menage [this message]
2009-07-03 2:25 ` Matt Helsley
2009-07-03 3:49 ` Paul Menage
2009-07-03 7:08 ` Benjamin Blum
2009-07-03 1:30 ` Andrew Morton
2009-07-03 5:54 ` KAMEZAWA Hiroyuki
2009-07-03 15:52 ` Paul Menage
2009-07-04 2:07 ` KAMEZAWA Hiroyuki
2009-07-04 16:10 ` Paul Menage
2009-07-05 23:53 ` KAMEZAWA Hiroyuki
2009-07-02 23:26 ` [PATCH 2/2] Ensures correct concurrent opening/reading of pidlists across pid namespaces Paul Menage
2009-07-02 23:54 ` Andrew Morton
2009-07-03 0:22 ` Paul Menage
2009-07-03 0:26 ` Paul Menage
2009-07-03 0:43 ` Benjamin Blum
2009-07-03 1:15 ` [PATCH 0/2] CGroups: cgroup member list enhancement/fix Li Zefan
2009-07-05 6:38 ` Balbir Singh
2009-07-10 23:58 ` Paul Menage
2009-07-13 12:11 ` Balbir Singh
2009-07-13 16:26 ` Paul Menage
2009-07-14 5:56 ` Balbir Singh
2009-07-14 6:49 ` Paul Menage
2009-07-14 7:16 ` Balbir Singh
2009-07-14 17:34 ` Benjamin Blum
2009-07-14 17:43 ` Paul Menage
2009-07-14 20:38 ` Paul Menage
2009-07-14 23:08 ` Matt Helsley
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=6599ad830907150918r5ed6f2cevde9dbc9ef304fb2b@mail.gmail.com \
--to=menage@google.com \
--cc=akpm@linux-foundation.org \
--cc=bblum@google.com \
--cc=containers@lists.linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitzu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®