From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: balbir@linux.vnet.ibm.com, menage@google.com, serue@us.ibm.com,
penberg@cs.helsinki.fi, linux-kernel@vger.kernel.org
Subject: Re: [Fwd: [-mm] Add an owner to the mm_struct (v9)]
Date: Tue, 15 Apr 2008 21:13:59 +0400 [thread overview]
Message-ID: <20080415171359.GA352@tv-sign.ru> (raw)
In-Reply-To: <20080414170709.736819b6.akpm@linux-foundation.org>
On 04/14, Andrew Morton wrote:
>
> On Mon, 14 Apr 2008 19:43:11 +0530
> Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
>
> > +void mm_update_next_owner(struct mm_struct *mm)
> > +{
> > + struct task_struct *c, *g, *p = current;
> > +
> > +retry:
> > + if (!mm_need_new_owner(mm, p))
> > + return;
> > +
> > + read_lock(&tasklist_lock);
> > + /*
> > + * Search in the children
> > + */
> > + list_for_each_entry(c, &p->children, sibling) {
> > + if (c->mm == mm)
> > + goto assign_new_owner;
> > + }
> > +
> > + /*
> > + * Search in the siblings
> > + */
> > + list_for_each_entry(c, &p->parent->children, sibling) {
> > + if (c->mm == mm)
> > + goto assign_new_owner;
> > + }
> > +
> > + /*
> > + * Search through everything else. We should not get
> > + * here often
> > + */
> > + do_each_thread(g, c) {
> > + if (c->mm == mm)
> > + goto assign_new_owner;
> > + } while_each_thread(g, c);
> > +
> > + read_unlock(&tasklist_lock);
>
> Potentially-long tasklist_lock hold times are a concern. I don't suppose
> rcu can save us?
I guess rcu can't help...
> Some additional commentary fleshing out "We should not get here often"
> might set minds at ease. How not-often? Under which circumstances?
Oh, I don't know what cgroup is, at all, but this looks really strange.
What about use_mm()? We can choose a kernel thread, but unuse_mm() doesn't
try to change ->owner...
Let's suppose the process with a lot of threads does exit_group() and nobody
else uses this ->mm. How many time we will re-assign mm->owner and iterate
over the all threads in system ?
Perhaps, we can add mm_struct->mm_user_list instead? In that case mm->owner
becomes first_entry()...
> > +assign_new_owner:
> > + BUG_ON(c == p);
> > + get_task_struct(c);
> > + /*
> > + * The task_lock protects c->mm from changing.
> > + * We always want mm->owner->mm == mm
> > + */
> > + task_lock(c);
> > + /*
> > + * Delay read_unlock() till we have the task_lock()
> > + * to ensure that c does not slip away underneath us
> > + */
> > + read_unlock(&tasklist_lock);
You can drop tasklist_lock right after get_task_struct(), the nested locks
are not preempt-friendly.
> > + if (c->mm != mm) {
> > + task_unlock(c);
> > + put_task_struct(c);
> > + goto retry;
> > + }
> > + cgroup_mm_owner_callbacks(mm->owner, c);
Can't we avoid calling cgroup_mm_owner_callbacks() at least when
mm->owner->cgroups == c->cgroups ?
Minor, but perhaps cgroup_mm_owner_callbacks() should check ->mm_owner_changed
!= NULL first, then play with task_cgroup()...
Oleg.
next prev parent reply other threads:[~2008-04-15 18:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-14 14:13 [Fwd: [-mm] Add an owner to the mm_struct (v9)] Balbir Singh
2008-04-14 14:49 ` Pekka Enberg
2008-04-14 16:04 ` Paul Menage
2008-04-14 19:36 ` Andrew Morton
2008-04-14 21:06 ` Pekka Enberg
2008-04-15 0:07 ` Andrew Morton
2008-04-15 17:13 ` Oleg Nesterov [this message]
2008-04-15 18:13 ` Paul Menage
2008-04-15 19:59 ` Oleg Nesterov
2008-04-17 3:38 ` Balbir Singh
2008-04-17 11:30 ` Oleg Nesterov
2008-04-17 16:34 ` Paul Menage
2008-04-17 16:19 ` Oleg Nesterov
2008-04-17 17:40 ` Balbir Singh
2008-04-17 17:08 ` Oleg Nesterov
2008-04-17 17:50 ` Paul Menage
2008-04-17 19:07 ` Balbir Singh
2008-04-17 17:49 ` Paul Menage
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=20080415171359.GA352@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
--cc=penberg@cs.helsinki.fi \
--cc=serue@us.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox