From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Izik Eidus <ieidus@redhat.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Chris Wright <chrisw@redhat.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] ksm: hold anon_vma in rmap_item fix
Date: Mon, 30 Nov 2009 09:46:17 +0530 [thread overview]
Message-ID: <20091130041617.GJ2970@balbir.in.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0911291544140.14991@sister.anvils>
* Hugh Dickins <hugh.dickins@tiscali.co.uk> [2009-11-29 15:50:32]:
> KSM mem_cgroup testing oopsed on NULL pointer in mem_cgroup_from_task(),
> called from the mm_match_cgroup() in page_referenced_ksm().
>
> Right, it is inappropriate to use mm_match_cgroup() on rmap_item->mm
> there: that mm could be waiting for ksmd's final mmdrop(), with its
> mm->owner task long gone.
>
> Move the mm_match_cgroup() test down into the anon_vma loop, which is
> where it now should be to match page_referenced_anon(). The anon_vma
> guarantees its vmas are valid, which guarantee their mms are valid.
>
> However... although this moves the oops from easy-to-reproduce to
> never-seen, I think we shall want to do more later: so far as I can
> see, with or without KSM, the use of mm->owner from page_referenced()
> is unsafe. No problem when NULL, but it may have been left pointing
> to a task_struct freed by now, with nonsense in mm->owner->cgroups.
>
Ideally we should not be left pointing to a stale task struct, unless
our assumption about mm_users is incorrect (discussed below).
> But let's put this patch in while we discuss that separately: perhaps
> mm_need_new_owner() should not short-circuit when mm_users <= 1, or
> perhaps it should then set mm->owner to NULL, or perhaps we abandon
> mm->owner as more trouble than it's worth, or... perhaps I'm wrong.
>
We short circuit, since the task is exiting and mm_users <= 1 and we
are shorting going to do a mmput(). I suspect what you are seeing is
mm_count >= 1 and mm_users == 0. With users == 0, we should set
owner to NULL
We could look for the above condition in mmput() and clear the owner
when users become 0.
--
Balbir
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2009-11-30 4:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-29 15:50 Hugh Dickins
2009-11-30 4:16 ` Balbir Singh [this message]
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=20091130041617.GJ2970@balbir.in.ibm.com \
--to=balbir@linux.vnet.ibm.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=chrisw@redhat.com \
--cc=hugh.dickins@tiscali.co.uk \
--cc=ieidus@redhat.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox