From: Andrew Morton <akpm@linux-foundation.org>
To: Roland Dreier <rdreier@cisco.com>
Cc: linux-kernel@vger.kernel.org, jsquyres@cisco.com, rostedt@goodmis.org
Subject: Re: [PATCH v2] ummunotify: Userspace support for MMU notifications
Date: Mon, 27 Jul 2009 16:53:29 -0700 [thread overview]
Message-ID: <20090727165329.4acfda1c.akpm@linux-foundation.org> (raw)
In-Reply-To: <adaeis53d2m.fsf_-_@cisco.com>
On Fri, 24 Jul 2009 15:56:17 -0700
Roland Dreier <rdreier@cisco.com> wrote:
> As discussed in <http://article.gmane.org/gmane.linux.drivers.openib/61925>
> and follow-up messages, libraries using RDMA would like to track
> precisely when application code changes memory mapping via free(),
> munmap(), etc. Current pure-userspace solutions using malloc hooks
> and other tricks are not robust, and the feeling among experts is that
> the issue is unfixable without kernel help.
>
> We solve this not by implementing the full API proposed in the email
> linked above but rather with a simpler and more generic interface,
> which may be useful in other contexts. Specifically, we implement a
> new character device driver, ummunotify, that creates a /dev/ummunotify
> node. A userspace process can open this node read-only and use the fd
> as follows:
>
> 1. ioctl() to register/unregister an address range to watch in the
> kernel (cf struct ummunotify_register_ioctl in <linux/ummunotify.h>).
>
> 2. read() to retrieve events generated when a mapping in a watched
> address range is invalidated (cf struct ummunotify_event in
> <linux/ummunotify.h>). select()/poll()/epoll() and SIGIO are
> handled for this IO.
>
> 3. mmap() one page at offset 0 to map a kernel page that contains a
> generation counter that is incremented each time an event is
> generated. This allows userspace to have a fast path that checks
> that no events have occurred without a system call.
>
> Thanks to Jason Gunthorpe <jgunthorpe@obsidianresearch.com> for
> suggestions on the interface design. Also thanks to Jeff Squyres
> <jsquyres@cisco.com> for prototyping support for this in Open MPI, which
> helped find several bugs during development.
>
> ...
>
> +config UMMUNOTIFY
> + tristate "Userspace MMU notifications"
> + select MMU_NOTIFIER
> + help
> + The ummunotify (userspace MMU notification) driver creates a
> + character device that can be used by userspace libraries to
> + get notifications when an application's memory mapping
> + changed. This is used, for example, by RDMA libraries to
> + improve the reliability of memory registration caching, since
> + the kernel's MMU notifications can be used to know precisely
> + when to shoot down a cached registration.
Does `select' dtrt here if UMMUNOTIFY=m? I never trust it...
<searches in vain for ummunotify.txt>
Oh well :(
A little test app would be nice - I assume you have one. We could toss
in in the tree as a how-to-use example, and people could perhaps turn
it into a regression test - perhaps the LTP people would take it.
>
> ...
>
> + if (test_bit(UMMUNOTIFY_FLAG_HINT, ®->flags)) {
> + clear_bit(UMMUNOTIFY_FLAG_HINT, ®->flags);
> + } else {
> + set_bit(UMMUNOTIFY_FLAG_HINT, ®->flags);
It's a shame that change_bit() didn't return the old (or new) value.
The overall userspace interface seems a bit klunky, but I can't really
suggest anything better. Netlink delivery?
next prev parent reply other threads:[~2009-07-27 23:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-22 17:47 [PATCH/RFC] ummunot: Userspace support for MMU notifications Roland Dreier
2009-07-22 18:15 ` Andrew Morton
2009-07-22 19:27 ` Roland Dreier
2009-07-22 19:42 ` Andrew Morton
2009-07-23 2:26 ` Steven Rostedt
2009-07-23 20:21 ` Roland Dreier
2009-07-24 0:25 ` Steven Rostedt
2009-07-24 22:56 ` [PATCH v2] ummunotify: " Roland Dreier
2009-07-27 23:53 ` Andrew Morton [this message]
2009-07-28 16:14 ` Roland Dreier
2009-07-31 18:54 ` [PATCH v3] " Roland Dreier
2009-08-02 19:59 ` Brice Goglin
2009-08-03 4:55 ` Roland Dreier
2009-08-03 6:57 ` Brice Goglin
2009-08-04 17:14 ` Roland Dreier
2009-07-23 9:04 ` [PATCH/RFC] ummunot: " Li Zefan
2009-07-23 20:28 ` Roland Dreier
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=20090727165329.4acfda1c.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=jsquyres@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rdreier@cisco.com \
--cc=rostedt@goodmis.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.