From: Andrea Arcangeli <andrea@qumranet.com>
To: Jack Steiner <steiner@sgi.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <clameter@sgi.com>, Robin Holt <holt@sgi.com>,
Nick Piggin <npiggin@suse.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
kvm-devel@lists.sourceforge.net,
Kanoj Sarcar <kanojsarcar@yahoo.com>,
Roland Dreier <rdreier@cisco.com>,
Steve Wise <swise@opengridcomputing.com>,
linux-kernel@vger.kernel.org, Avi Kivity <avi@qumranet.com>,
linux-mm@kvack.org, general@lists.openfabrics.org,
Hugh Dickins <hugh@veritas.com>,
Rusty Russell <rusty@rustcorp.com.au>,
Anthony Liguori <aliguori@us.ibm.com>,
Chris Wright <chrisw@redhat.com>,
Marcelo Tosatti <marcelo@kvack.org>,
Eric Dumazet <dada1@cosmosbay.com>,
"Paul E. McKenney" <paulmck@us.ibm.com>
Subject: Re: [PATCH 01 of 11] mmu-notifier-core
Date: Tue, 6 May 2008 16:46:54 +0200 [thread overview]
Message-ID: <20080506144654.GD8471@duo.random> (raw)
In-Reply-To: <20080505194625.GA17734@sgi.com>
On Mon, May 05, 2008 at 02:46:25PM -0500, Jack Steiner wrote:
> If a task fails to unmap a GRU segment, they still exist at the start of
Yes, this will also happen in case the well behaved task receives
SIGKILL, so you can test it that way too.
> exit. On the ->release callout, I set a flag in the container of my
> mmu_notifier that exit has started. As VMA are cleaned up, TLB flushes
> are skipped because of the flag is set. When the GRU VMA is deleted, I free
GRU TLB flushes aren't skipped because your flag is set but because
__mmu_notifier_release already executed
list_del_init_rcu(&grunotifier->hlist) before proceeding with
unmap_vmas.
> my structure containing the notifier.
As long as nobody can write through the already established gru tlbs
and nobody can establish new tlbs after exit_mmap run you don't
strictly need ->release.
> I _think_ works. Do you see any problems?
You can remove the flag and ->release and ->clear_flush_young (if you
keep clear_flush_young implemented it should return 0). The
synchronize_rcu after mmu_notifier_register can also be dropped thanks
to mm_lock(). gru_drop_mmu_notifier should be careful with current->mm
if you're using an fd and if the fd can be passed to a different task
through unix sockets (you should probably fail any operation if
current->mm != gru->mm).
The way I use ->release in KVM is to set the root hpa to -1UL
(invalid) as a debug trap. That's only for debugging because even if
tlb entries and sptes are still established on the secondary mmu they
are only relevant when the cpu jumps to guest mode and that can never
happen again after exit_mmap is started.
> I should also mention that I have an open-coded function that possibly
> belongs in mmu_notifier.c. A user is allowed to have multiple GRU segments.
> Each GRU has a couple of data structures linked to the VMA. All, however,
> need to share the same notifier. I currently open code a function that
> scans the notifier list to determine if a GRU notifier already exists.
> If it does, I update a refcnt & use it. Otherwise, I register a new
> one. All of this is protected by the mmap_sem.
>
> Just in case I mangled the above description, I'll attach a copy of the GRU mmuops
> code.
Well that function needs fixing w.r.t. srcu. Are you sure you want to
search for mn->ops == gru_mmuops and not for mn == gmn? And if you
search for mn why can't you keep track of the mn being registered or
unregistered outside of the mmu_notifier layer? Set a bitflag in the
container after mmu_notifier_register returns and a clear it after
_unregister returns. I doubt saving one bitflag is worth searching the
list and your approach make it obvious that you've to protect the
bitflag and the register/unregister under write-mmap_sem
yourself. Otherwise the find function will return an object that can
be freed at any time if somebody calls unregister and
kfree. (synchronize_srcu in mmu_notifier_unregister won't wait for
anything but some outstanding srcu_read_lock)
--
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>
next prev parent reply other threads:[~2008-05-06 14:46 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-02 15:05 [PATCH 00 of 11] mmu notifier #v15 Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 01 of 11] mmu-notifier-core Andrea Arcangeli
2008-05-04 19:13 ` Robin Holt
2008-05-04 22:08 ` Andrea Arcangeli
2008-05-05 2:25 ` Robin Holt
2008-05-05 16:21 ` Jack Steiner
2008-05-05 17:14 ` Andrea Arcangeli
2008-05-05 17:25 ` Jack Steiner
2008-05-05 18:34 ` Andrea Arcangeli
2008-05-05 19:46 ` Jack Steiner
2008-05-06 14:46 ` Andrea Arcangeli [this message]
2008-05-06 17:53 ` mmu notifier v15 -> v16 diff Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 02 of 11] get_task_mm Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 03 of 11] invalidate_page outside PT lock Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 04 of 11] free-pgtables Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 05 of 11] unmap vmas tlb flushing Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 06 of 11] rwsem contended Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 07 of 11] i_mmap_rwsem Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 08 of 11] anon-vma-rwsem Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 09 of 11] mm_lock-rwsem Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 10 of 11] export zap_page_range for XPMEM Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 11 of 11] mmap sems Andrea Arcangeli
2008-05-03 11:09 ` [PATCH 00 of 11] mmu notifier #v15 Jack Steiner
-- strict thread matches above, loose matches on Subject: below --
2008-05-07 14:35 [PATCH 00 of 11] mmu notifier #v16 Andrea Arcangeli
2008-05-07 14:35 ` [PATCH 01 of 11] mmu-notifier-core Andrea Arcangeli
2008-05-07 17:35 ` Rik van Riel
2008-05-07 20:02 ` Andrew Morton
2008-05-07 20:05 ` Andrew Morton
2008-05-07 20:30 ` Linus Torvalds
2008-05-07 21:58 ` Andrea Arcangeli
2008-05-07 22:11 ` Linus Torvalds
2008-05-07 22:27 ` Andrea Arcangeli
2008-05-07 22:37 ` Andrea Arcangeli
2008-05-07 23:38 ` Linus Torvalds
2008-05-07 23:00 ` Linus Torvalds
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=20080506144654.GD8471@duo.random \
--to=andrea@qumranet.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=aliguori@us.ibm.com \
--cc=avi@qumranet.com \
--cc=chrisw@redhat.com \
--cc=clameter@sgi.com \
--cc=dada1@cosmosbay.com \
--cc=general@lists.openfabrics.org \
--cc=holt@sgi.com \
--cc=hugh@veritas.com \
--cc=kanojsarcar@yahoo.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=marcelo@kvack.org \
--cc=npiggin@suse.de \
--cc=paulmck@us.ibm.com \
--cc=rdreier@cisco.com \
--cc=rusty@rustcorp.com.au \
--cc=steiner@sgi.com \
--cc=swise@opengridcomputing.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;
as well as URLs for NNTP newsgroup(s).