Re: [PATCH] mmu notifiers #v8 + xpmem

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andrea Arcangeli
Date: Sunday, March 2, 2008 - 9:03 am

Here an example of the futher orthogonal work to do on top of #v8
during .26-rc to make the whole mmu notifier API sleep capable.

1) Every single ptep_clear_flush_young_notify and
ptep_clear_flush_notify must be converted like the below. The below is
the conversion of a single one. do_wp_page has been converted by
Christoph already but with invalidate_range (should be changed to
invalidate_page by releasing the refcount on the page after calling
invalidate_page). Hope it's clear why I'd rather not depend on these
changes to be merged in .25 in order to have the mmu notifier included
in .25.

2) Then after all this conversion work is finished, it's trivial to
delete ptep_clear_flush_young_notify and ptep_clear_flush_notify from
mmu_notifier.h (they will be unused macros once the conversion is
complete).

3) After that the VM has to be changed to convert anon_vma lock and
i_mmap_lock spinlocks to mutex/rwsemaphore.

4) Then finally the mmu_notifier_unregister must be dropped to make the
mmu notifier sleep capable with RCU in the mmu_notifier() fast path.

It's unclear at this point if 3/4 should be switchable and happening
under a CONFIG_XPMEM or similar or if everyone will benefit from those
spinlock becoming mutex (the only one that is certain to appreciate
such a change is preempt-rt, the rest of the userbase I don't know for
sure and I'd be more confortable with a TPC number comparison before
doing such a chance by default, but I leave the commentary on such a
change to linux-mm in a separate thread).

Signed-off-by: Andrea Arcangeli <andrea@qumranet.com>

diff --git a/mm/rmap.c b/mm/rmap.c
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -274,7 +274,7 @@ static int page_referenced_one(struct pa
 	unsigned long address;
 	pte_t *pte;
 	spinlock_t *ptl;
-	int referenced = 0;
+	int referenced = 0, clear_flush_young = 0;
 
 	address = vma_address(page, vma);
 	if (address == -EFAULT)
@@ -287,8 +287,11 @@ static int page_referenced_one(struct pa
 	if (vma->vm_flags & VM_LOCKED) {
 		referenced++;
 		*mapcount = 1;	/* break early from loop */
-	} else if (ptep_clear_flush_young_notify(vma, address, pte))
-		referenced++;
+	} else {
+		clear_flush_young = 1;
+		if (ptep_clear_flush_young(vma, address, pte))
+			referenced++;
+	}
 
 	/* Pretend the page is referenced if the task has the
 	   swap token and is in the middle of a page fault. */
@@ -298,6 +301,11 @@ static int page_referenced_one(struct pa
 
 	(*mapcount)--;
 	pte_unmap_unlock(pte, ptl);
+
+	if (clear_flush_young)
+		referenced += mmu_notifier_clear_flush_young(vma->vm_mm,
+							     address);
+
 out:
 	return referenced;
 }

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch] my mmu notifiers, Nick Piggin, (Tue Feb 19, 1:43 am)
[patch] my mmu notifier sample driver, Nick Piggin, (Tue Feb 19, 1:44 am)
Re: [patch] my mmu notifiers, Robin Holt, (Tue Feb 19, 4:59 am)
Re: [patch] my mmu notifiers, Andrea Arcangeli, (Tue Feb 19, 6:58 am)
Re: [patch] my mmu notifiers, Jack Steiner, (Tue Feb 19, 7:27 am)
Re: [patch] my mmu notifiers, Nick Piggin, (Tue Feb 19, 3:59 pm)
Re: [patch] my mmu notifiers, Nick Piggin, (Tue Feb 19, 4:04 pm)
Re: [patch] my mmu notifiers, Nick Piggin, (Tue Feb 19, 4:11 pm)
Re: [patch] my mmu notifiers, Jack Steiner, (Tue Feb 19, 4:40 pm)
Re: [patch] my mmu notifiers, Andrea Arcangeli, (Tue Feb 19, 5:46 pm)
Re: [patch] my mmu notifiers, Andrea Arcangeli, (Tue Feb 19, 5:52 pm)
Re: [patch] my mmu notifiers, Andrea Arcangeli, (Tue Feb 19, 6:09 pm)
Re: [patch] my mmu notifiers, Robin Holt, (Tue Feb 19, 7:46 pm)
Re: [patch] my mmu notifiers, Robin Holt, (Tue Feb 19, 7:49 pm)
[PATCH] mmu notifiers #v6, Andrea Arcangeli, (Wed Feb 20, 3:39 am)
[PATCH] KVM swapping (+ seqlock fix) with mmu notifiers #v6, Andrea Arcangeli, (Wed Feb 20, 3:45 am)
Re: [PATCH] mmu notifiers #v6, Robin Holt, (Wed Feb 20, 4:33 am)
Re: [PATCH] mmu notifiers #v6, Andrea Arcangeli, (Wed Feb 20, 5:03 am)
Re: [PATCH] mmu notifiers #v6, Robin Holt, (Wed Feb 20, 5:24 am)
Re: [PATCH] mmu notifiers #v6, Andrea Arcangeli, (Wed Feb 20, 5:32 am)
Re: [PATCH] mmu notifiers #v6, Robin Holt, (Wed Feb 20, 6:15 am)
Re: [PATCH] mmu notifiers #v6, Robin Holt, (Wed Feb 20, 7:41 am)
Re: [PATCH] mmu notifiers #v6, Andrea Arcangeli, (Wed Feb 20, 8:34 am)
Re: [PATCH] mmu notifiers #v6, Jack Steiner, (Wed Feb 20, 2:03 pm)
Re: [patch] my mmu notifiers, Nick Piggin, (Wed Feb 20, 9:42 pm)
Re: [patch] my mmu notifiers, Nick Piggin, (Wed Feb 20, 9:47 pm)
Re: [PATCH] mmu notifiers #v6, Nick Piggin, (Wed Feb 20, 9:54 pm)
Re: [PATCH] mmu notifiers #v6, Nick Piggin, (Wed Feb 20, 10:02 pm)
Re: [PATCH] mmu notifiers #v6, Andrea Arcangeli, (Thu Feb 21, 7:40 am)
Re: [PATCH] mmu notifiers #v6, Jack Steiner, (Thu Feb 21, 9:10 am)
Re: [patch] my mmu notifiers, Jack Steiner, (Fri Feb 22, 9:31 am)
[PATCH] mmu notifiers #v7, Andrea Arcangeli, (Wed Feb 27, 12:26 pm)
Re: [PATCH] mmu notifiers #v7, Peter Zijlstra, (Wed Feb 27, 1:04 pm)
[PATCH] KVM swapping with mmu notifiers #v7, Andrea Arcangeli, (Wed Feb 27, 3:06 pm)
Re: [patch] my mmu notifiers, Christoph Lameter, (Wed Feb 27, 3:50 pm)
Re: [patch] my mmu notifiers, Christoph Lameter, (Wed Feb 27, 3:55 pm)
Re: [patch] my mmu notifiers, Christoph Lameter, (Wed Feb 27, 3:56 pm)
Re: [PATCH] mmu notifiers #v7, Christoph Lameter, (Wed Feb 27, 4:06 pm)
Re: [kvm-devel] [PATCH] mmu notifiers #v7, Andrea Arcangeli, (Wed Feb 27, 4:43 pm)
Re: [kvm-devel] [PATCH] mmu notifiers #v7, Christoph Lameter, (Wed Feb 27, 5:08 pm)
Re: [kvm-devel] [PATCH] mmu notifiers #v7, Andrea Arcangeli, (Wed Feb 27, 5:21 pm)
Re: [kvm-devel] [PATCH] mmu notifiers #v7, Christoph Lameter, (Wed Feb 27, 5:24 pm)
Re: [PATCH] KVM swapping with mmu notifiers #v7, izik eidus, (Thu Feb 28, 1:42 am)
Re: [PATCH] mmu notifiers #v7, Christoph Lameter, (Thu Feb 28, 12:48 pm)
Re: [PATCH] mmu notifiers #v7, Andrea Arcangeli, (Thu Feb 28, 2:52 pm)
Re: [PATCH] mmu notifiers #v7, Christoph Lameter, (Thu Feb 28, 3:00 pm)
Re: [PATCH] mmu notifiers #v7, Christoph Lameter, (Thu Feb 28, 4:05 pm)
Re: [PATCH] mmu notifiers #v7, Jack Steiner, (Thu Feb 28, 4:17 pm)
Re: [PATCH] mmu notifiers #v7, Andrea Arcangeli, (Thu Feb 28, 5:24 pm)
Re: [PATCH] mmu notifiers #v7, Andrea Arcangeli, (Thu Feb 28, 5:40 pm)
Re: [PATCH] mmu notifiers #v7, Andrew Morton, (Thu Feb 28, 5:56 pm)
Re: [PATCH] mmu notifiers #v7, Christoph Lameter, (Thu Feb 28, 6:03 pm)
Re: [PATCH] mmu notifiers #v7, Christoph Lameter, (Thu Feb 28, 6:13 pm)
Re: [PATCH] mmu notifiers #v7, Andrea Arcangeli, (Fri Feb 29, 6:09 am)
Re: [PATCH] mmu notifiers #v7, Christoph Lameter, (Fri Feb 29, 12:46 pm)
[PATCH] mmu notifiers #v8, Andrea Arcangeli, (Sun Mar 2, 8:54 am)
Re: [PATCH] mmu notifiers #v8 + xpmem, Andrea Arcangeli, (Sun Mar 2, 9:03 am)
Re: [PATCH] mmu notifiers #v8 + xpmem, Peter Zijlstra, (Sun Mar 2, 9:23 am)
Re: [PATCH] mmu notifiers #v8, Nick Piggin, (Sun Mar 2, 8:29 pm)
Re: [PATCH] mmu notifiers #v8, Nick Piggin, (Sun Mar 2, 8:33 pm)
Re: [PATCH] mmu notifiers #v8, Nick Piggin, (Sun Mar 2, 8:34 pm)
Re: [PATCH] mmu notifiers #v8, Nick Piggin, (Sun Mar 2, 8:39 pm)
Re: [PATCH] mmu notifiers #v8, Andrea Arcangeli, (Mon Mar 3, 5:51 am)
Re: [PATCH] mmu notifiers #v8, Nick Piggin, (Mon Mar 3, 6:10 am)
Re: [PATCH] mmu notifiers #v8, Andrea Arcangeli, (Mon Mar 3, 6:24 am)
Re: [PATCH] mmu notifiers #v8, Jack Steiner, (Mon Mar 3, 8:18 am)
Re: [PATCH] mmu notifiers #v8, Nick Piggin, (Mon Mar 3, 9:59 am)
Re: [PATCH] mmu notifiers #v8, Jack Steiner, (Mon Mar 3, 11:06 am)
Re: [PATCH] mmu notifiers #v8, Avi Kivity, (Mon Mar 3, 11:09 am)
Re: [PATCH] mmu notifiers #v8, Jack Steiner, (Mon Mar 3, 11:23 am)
Re: [PATCH] mmu notifiers #v8, Nick Piggin, (Mon Mar 3, 11:45 am)
Re: [PATCH] mmu notifiers #v8, Christoph Lameter, (Mon Mar 3, 12:01 pm)
Re: [PATCH] mmu notifiers #v8, Christoph Lameter, (Mon Mar 3, 12:02 pm)
Re: [PATCH] mmu notifiers #v8, Christoph Lameter, (Mon Mar 3, 12:03 pm)
Re: [PATCH] mmu notifiers #v8, Christoph Lameter, (Mon Mar 3, 12:04 pm)
Re: [PATCH] mmu notifiers #v8, Jack Steiner, (Mon Mar 3, 12:15 pm)
Re: [PATCH] mmu notifiers #v8, Andrea Arcangeli, (Mon Mar 3, 2:15 pm)
[PATCH] mmu notifiers #v9, Andrea Arcangeli, (Mon Mar 3, 2:37 pm)
[PATCH] KVM swapping with mmu notifiers #v9, Andrea Arcangeli, (Mon Mar 3, 3:05 pm)
Re: [PATCH] KVM swapping with mmu notifiers #v9, izik eidus, (Mon Mar 3, 5:44 pm)
[RFC] Notifier for Externally Mapped Memory (EMM), Christoph Lameter, (Tue Mar 4, 12:31 am)
[Early draft] Conversion of i_mmap_lock to semaphore, Christoph Lameter, (Tue Mar 4, 12:34 am)
Re: [PATCH] mmu notifiers #v8, Peter Zijlstra, (Tue Mar 4, 3:35 am)
Re: [PATCH] KVM swapping with mmu notifiers #v9, Andrea Arcangeli, (Tue Mar 4, 6:21 am)
Re: [RFC] Notifier for Externally Mapped Memory (EMM), Andrea Arcangeli, (Tue Mar 4, 6:30 am)
Re: [PATCH] mmu notifiers #v8, Jack Steiner, (Tue Mar 4, 7:44 am)
Re: [RFC] Notifier for Externally Mapped Memory (EMM), Christoph Lameter, (Tue Mar 4, 12:00 pm)
Re: [RFC] Notifier for Externally Mapped Memory (EMM), Andrea Arcangeli, (Tue Mar 4, 3:20 pm)
Re: [RFC] Notifier for Externally Mapped Memory (EMM), Christoph Lameter, (Tue Mar 4, 3:35 pm)
Re: [RFC] Notifier for Externally Mapped Memory (EMM), Peter Zijlstra, (Tue Mar 4, 3:42 pm)
Re: [RFC] Notifier for Externally Mapped Memory (EMM), Christoph Lameter, (Tue Mar 4, 4:14 pm)
Re: [RFC] Notifier for Externally Mapped Memory (EMM), Peter Zijlstra, (Tue Mar 4, 4:25 pm)
Re: [RFC] Notifier for Externally Mapped Memory (EMM), Peter Zijlstra, (Tue Mar 4, 4:30 pm)
Re: [PATCH] mmu notifiers #v8, Nick Piggin, (Tue Mar 4, 5:37 pm)
Re: [PATCH] mmu notifiers #v8, Christoph Lameter, (Wed Mar 5, 11:48 am)
Re: [PATCH] mmu notifiers #v8, Nick Piggin, (Wed Mar 5, 7:59 pm)
[PATCH] 4/4 i_mmap_lock spinlock2rwsem (#v9 was 1/4), Andrea Arcangeli, (Fri Mar 7, 8:52 am)
Re: [PATCH] 2/4 move all invalidate_page outside of PT loc ..., Christoph Lameter, (Fri Mar 7, 12:54 pm)
Re: [PATCH] 4/4 i_mmap_lock spinlock2rwsem (#v9 was 1/4), Christoph Lameter, (Fri Mar 7, 1:03 pm)
Re: [PATCH] 4/4 i_mmap_lock spinlock2rwsem (#v9 was 1/4), Christoph Lameter, (Wed Mar 19, 2:27 pm)