From: Robin Holt <holt@sgi.com>
To: Andrea Arcangeli <andrea@qumranet.com>
Cc: Avi Kivity <avi@qumranet.com>, Izik Eidus <izike@qumranet.com>,
Andrew Morton <akpm@osdl.org>, Nick Piggin <npiggin@suse.de>,
kvm-devel@lists.sourceforge.net,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
steiner@sgi.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, daniel.blueman@quadrics.com, holt@sgi.com,
Hugh Dickins <hugh@veritas.com>,
clameter@sgi.com, Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: Enhance mmu notifiers to accomplish a lockless implementation (incomplete).
Date: Wed, 23 Jan 2008 22:05:25 -0600 [thread overview]
Message-ID: <20080124040525.GM26420@sgi.com> (raw)
In-Reply-To: <20080124020007.GL26420@sgi.com>
Expand the mmu_notifiers to allow for lockless callers. To accomplish
this, the function receiving notifications needs to implement an rmap
equivalent. The notification function is also responsible for tracking
page dirty state.
Version 2 brings with it __xip_unmap and do_wp_page so this is getting
to the point where we can start testing. It does compile now.
I am traveling tomorrow but should be able to get back to this tomorrow
evening or early Friday.
Thank you for your attention,
Robin Holt
Index: mmu_notifiers/include/linux/export_notifier.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ mmu_notifiers/include/linux/export_notifier.h 2008-01-23 21:24:33.000000000 -0600
@@ -0,0 +1,50 @@
+#ifndef _LINUX_EXPORT_NOTIFIER_H
+#define _LINUX_EXPORT_NOTIFIER_H
+
+#include <linux/list.h>
+#include <linux/mm_types.h>
+
+struct export_notifier {
+ struct hlist_node hlist;
+ const struct export_notifier_ops *ops;
+};
+
+struct export_notifier_ops {
+ /*
+ * Called with the page lock held after ptes are modified or removed.
+ *
+ * Must clear PageExported()
+ */
+ void (*invalidate_page)(struct export_notifier *em, struct page *page);
+};
+
+#ifdef CONFIG_EXPORT_NOTIFIER
+
+extern void export_notifier_register(struct export_notifier *em);
+extern void export_notifier_unregister(struct export_notifier *em);
+
+extern struct hlist_head export_notifier_list;
+
+#define export_notifier(function, args...) \
+ do { \
+ struct export_notifier *__em; \
+ struct hlist_node *__n; \
+ \
+ rcu_read_lock(); \
+ hlist_for_each_entry_rcu(__em, __n, &export_notifier_list, \
+ hlist) \
+ if (__em->ops->function) \
+ __em->ops->function(__em, args); \
+ rcu_read_unlock(); \
+ } while (0);
+
+#else
+
+#define export_notifier(function, args...)
+
+static inline void export_notifier_register(struct export_notifier *em) {}
+static inline void export_notifier_unregister(struct export_notifier *em) {}
+
+#endif
+
+#endif /* _LINUX_EXPORT_NOTIFIER_H */
Index: mmu_notifiers/include/linux/page-flags.h
===================================================================
--- mmu_notifiers.orig/include/linux/page-flags.h 2008-01-23 21:24:27.000000000 -0600
+++ mmu_notifiers/include/linux/page-flags.h 2008-01-23 21:57:58.000000000 -0600
@@ -105,6 +105,7 @@
* 64 bit | FIELDS | ?????? FLAGS |
* 63 32 0
*/
+#define PG_exported 30 /* Page is referenced by something not in the rmaps */
#define PG_uncached 31 /* Page has been mapped as uncached */
#endif
@@ -260,6 +261,14 @@ static inline void __ClearPageTail(struc
#define SetPageUncached(page) set_bit(PG_uncached, &(page)->flags)
#define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->flags)
+#ifdef CONFIG_EXPORT_NOTIFIER
+#define PageExported(page) test_bit(PG_exported, &(page)->flags)
+#define SetPageExported(page) set_bit(PG_exported, &(page)->flags)
+#define ClearPageExported(page) clear_bit(PG_exported, &(page)->flags)
+#else
+#define PageExported(page) 0
+#endif
+
struct page; /* forward declaration */
extern void cancel_dirty_page(struct page *page, unsigned int account_size);
Index: mmu_notifiers/mm/Kconfig
===================================================================
--- mmu_notifiers.orig/mm/Kconfig 2008-01-23 21:24:27.000000000 -0600
+++ mmu_notifiers/mm/Kconfig 2008-01-23 21:57:58.000000000 -0600
@@ -197,3 +197,8 @@ config VIRT_TO_BUS
config MMU_NOTIFIER
def_bool y
bool "MMU notifier, for paging KVM/RDMA"
+
+config EXPORT_NOTIFIER
+ def_bool y
+ depends on 64BIT
+ bool "Export Notifier for notifying subsystems about changes to page mappings"
Index: mmu_notifiers/mm/Makefile
===================================================================
--- mmu_notifiers.orig/mm/Makefile 2008-01-23 21:24:27.000000000 -0600
+++ mmu_notifiers/mm/Makefile 2008-01-23 21:24:33.000000000 -0600
@@ -31,4 +31,4 @@ obj-$(CONFIG_MIGRATION) += migrate.o
obj-$(CONFIG_SMP) += allocpercpu.o
obj-$(CONFIG_QUICKLIST) += quicklist.o
obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o
-
+obj-$(CONFIG_EXPORT_NOTIFIER) += export_notifier.o
Index: mmu_notifiers/mm/export_notifier.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ mmu_notifiers/mm/export_notifier.c 2008-01-23 21:57:27.000000000 -0600
@@ -0,0 +1,20 @@
+#include <linux/export_notifier.h>
+
+HLIST_HEAD(export_notifier_list);
+DEFINE_SPINLOCK(export_notifier_list_lock);
+
+void export_notifier_register(struct export_notifier *en)
+{
+ spin_lock(&export_notifier_list_lock);
+ hlist_add_head_rcu(&en->hlist, &export_notifier_list);
+ spin_unlock(&export_notifier_list_lock);
+}
+
+void export_notifier_unregister(struct export_notifier *en)
+{
+ spin_lock(&export_notifier_list_lock);
+ hlist_del_rcu(&en->hlist);
+ spin_unlock(&export_notifier_list_lock);
+}
+
+
Index: mmu_notifiers/mm/rmap.c
===================================================================
--- mmu_notifiers.orig/mm/rmap.c 2008-01-23 21:24:27.000000000 -0600
+++ mmu_notifiers/mm/rmap.c 2008-01-23 21:57:27.000000000 -0600
@@ -49,6 +49,7 @@
#include <linux/rcupdate.h>
#include <linux/module.h>
#include <linux/kallsyms.h>
+#include <linux/export_notifier.h>
#include <asm/tlbflush.h>
@@ -473,6 +474,8 @@ int page_mkclean(struct page *page)
struct address_space *mapping = page_mapping(page);
if (mapping) {
ret = page_mkclean_file(mapping, page);
+ if (unlikely(PageExported(page)))
+ export_notifier(invalidate_page, page);
if (page_test_dirty(page)) {
page_clear_dirty(page);
ret = 1;
@@ -971,6 +974,9 @@ int try_to_unmap(struct page *page, int
else
ret = try_to_unmap_file(page, migration);
+ if (unlikely(PageExported(page)))
+ export_notifier(invalidate_page, page);
+
if (!page_mapped(page))
ret = SWAP_SUCCESS;
return ret;
Index: mmu_notifiers/mm/fremap.c
===================================================================
--- mmu_notifiers.orig/mm/fremap.c 2008-01-23 21:24:27.000000000 -0600
+++ mmu_notifiers/mm/fremap.c 2008-01-23 21:57:27.000000000 -0600
@@ -211,6 +211,7 @@ asmlinkage long sys_remap_file_pages(uns
spin_unlock(&mapping->i_mmap_lock);
}
+ mmu_notifier(invalidate_range, mm, start, start + size);
err = populate_range(mm, vma, start, size, pgoff);
if (!err && !(flags & MAP_NONBLOCK)) {
if (unlikely(has_write_lock)) {
Index: mmu_notifiers/mm/memory.c
===================================================================
--- mmu_notifiers.orig/mm/memory.c 2008-01-23 21:24:27.000000000 -0600
+++ mmu_notifiers/mm/memory.c 2008-01-23 21:57:27.000000000 -0600
@@ -1637,6 +1637,7 @@ gotten:
/*
* Re-check the pte - we dropped the lock
*/
+ mmu_notifier(invalidate_range, mm, address, address + PAGE_SIZE - 1);
page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
if (likely(pte_same(*page_table, orig_pte))) {
if (old_page) {
Index: mmu_notifiers/mm/filemap_xip.c
===================================================================
--- mmu_notifiers.orig/mm/filemap_xip.c 2008-01-23 21:33:21.000000000 -0600
+++ mmu_notifiers/mm/filemap_xip.c 2008-01-23 21:57:27.000000000 -0600
@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/uio.h>
#include <linux/rmap.h>
+#include <linux/export_notifier.h>
#include <linux/sched.h>
#include <asm/tlbflush.h>
@@ -183,6 +184,7 @@ __xip_unmap (struct address_space * mapp
if (!page)
return;
+ export_notifier(invalidate_page, page);
spin_lock(&mapping->i_mmap_lock);
vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
mm = vma->vm_mm;
next prev parent reply other threads:[~2008-01-24 4:05 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-13 16:24 [PATCH] mmu notifiers #v2 Andrea Arcangeli
2008-01-13 21:11 ` Benjamin Herrenschmidt
2008-01-14 20:02 ` Christoph Lameter
2008-01-15 4:28 ` Benjamin Herrenschmidt
2008-01-15 12:44 ` Andrea Arcangeli
2008-01-15 20:18 ` Benjamin Herrenschmidt
2008-01-16 1:06 ` Andrea Arcangeli
2008-01-16 9:01 ` Brice Goglin
2008-01-16 10:19 ` Andrea Arcangeli
2008-01-16 17:42 ` Rik van Riel
2008-01-16 17:48 ` Izik Eidus
2008-01-17 16:23 ` Andrea Arcangeli
2008-01-17 18:21 ` Izik Eidus
2008-01-17 19:32 ` Andrea Arcangeli
2008-01-21 12:52 ` [PATCH] mmu notifiers #v3 Andrea Arcangeli
2008-01-22 2:21 ` Rik van Riel
2008-01-22 14:12 ` [kvm-devel] " Avi Kivity
2008-01-22 14:43 ` Andrea Arcangeli
2008-01-22 20:08 ` [kvm-devel] [PATCH] mmu notifiers #v4 Andrea Arcangeli
2008-01-22 20:34 ` [kvm-devel] [PATCH] export notifier #1 Christoph Lameter
2008-01-22 22:31 ` Andrea Arcangeli
2008-01-22 22:53 ` Christoph Lameter
2008-01-23 10:27 ` Avi Kivity
2008-01-23 10:52 ` Robin Holt
2008-01-23 12:04 ` Andrea Arcangeli
2008-01-23 12:34 ` Robin Holt
2008-01-23 19:48 ` Christoph Lameter
2008-01-23 19:58 ` Robin Holt
2008-01-23 19:47 ` Christoph Lameter
2008-01-24 5:56 ` Avi Kivity
2008-01-24 12:26 ` Andrea Arcangeli
2008-01-24 12:34 ` Avi Kivity
2008-01-23 11:41 ` Andrea Arcangeli
2008-01-23 12:32 ` Robin Holt
2008-01-23 17:33 ` Andrea Arcangeli
2008-01-23 20:27 ` Christoph Lameter
2008-01-24 15:42 ` Andrea Arcangeli
2008-01-24 20:07 ` Christoph Lameter
2008-01-25 6:35 ` Avi Kivity
2008-01-23 20:18 ` Christoph Lameter
2008-01-24 14:34 ` Andrea Arcangeli
2008-01-24 14:41 ` Andrea Arcangeli
2008-01-24 15:15 ` Avi Kivity
2008-01-24 15:18 ` Avi Kivity
2008-01-24 20:01 ` Christoph Lameter
2008-01-22 23:36 ` Benjamin Herrenschmidt
2008-01-23 0:40 ` Christoph Lameter
2008-01-23 1:21 ` Robin Holt
2008-01-23 12:51 ` Gerd Hoffmann
2008-01-23 13:19 ` Robin Holt
2008-01-23 14:12 ` Gerd Hoffmann
2008-01-23 14:18 ` Robin Holt
2008-01-23 14:35 ` Gerd Hoffmann
2008-01-23 15:48 ` Robin Holt
2008-01-23 14:17 ` Avi Kivity
2008-01-24 4:03 ` Benjamin Herrenschmidt
2008-01-23 15:41 ` Andrea Arcangeli
2008-01-23 17:47 ` Gerd Hoffmann
2008-01-24 6:01 ` Avi Kivity
2008-01-24 6:45 ` Jeremy Fitzhardinge
2008-01-23 20:40 ` Christoph Lameter
2008-01-24 2:00 ` Enhance mmu notifiers to accomplish a lockless implementation (incomplete) Robin Holt
2008-01-24 4:05 ` Robin Holt [this message]
2008-01-22 19:28 ` [PATCH] mmu notifiers #v3 Peter Zijlstra
2008-01-22 20:31 ` Christoph Lameter
2008-01-22 20:31 ` Andrea Arcangeli
2008-01-22 22:10 ` Hugh Dickins
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=20080124040525.GM26420@sgi.com \
--to=holt@sgi.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@osdl.org \
--cc=andrea@qumranet.com \
--cc=avi@qumranet.com \
--cc=benh@kernel.crashing.org \
--cc=clameter@sgi.com \
--cc=daniel.blueman@quadrics.com \
--cc=hugh@veritas.com \
--cc=izike@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@suse.de \
--cc=steiner@sgi.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).