Re: [kvm-devel] [PATCH] export notifier #1

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Gerd Hoffmann <kraxel@...>
Cc: Christoph Lameter <clameter@...>, Andrew Morton <akpm@...>, Nick Piggin <npiggin@...>, <kvm-devel@...>, Benjamin Herrenschmidt <benh@...>, <steiner@...>, <linux-kernel@...>, Avi Kivity <avi@...>, <linux-mm@...>, <daniel.blueman@...>, <holt@...>, Hugh Dickins <hugh@...>
Date: Wednesday, January 23, 2008 - 11:41 am

Hi Kraxel,

On Wed, Jan 23, 2008 at 01:51:23PM +0100, Gerd Hoffmann wrote:

I think it has yet to be demonstrated that doing the invalidate
_before_ clearing the linux pte is workable at all for
shadow-pte/RDMA. Infact even doing it _after_ still requires some form
of serialization but it's less obviously broken and perhaps more
fixable unlike doing it before that seems hardly fixable given the
refill event running in the remote node is supposed to wait on a
bitflag of a page in the master node to return ON. What Christoph
didn't specify after hinting you have to wait for the PageExported
bitflag to return on, is that such page may be back in the freelist by
the time the secondary-tlb page fault starts checking that bit. And
nobody is setting that bit anyway in the VM so good luck waiting that
bit to return on in a page in the freelist (nothing keeps that page
pinned anymore by the time the ->invalidate_page returns: the whole
point of the invalidate is so the VM code can finally free it and put
it in the freelist).

Until there's some more reasonable theory of how invalidating the
remote tlbs/ptes _before_ the main linux pte can remotely work, I'm
"quite" skeptical it's the way to go for the invalidate_page callback.

Like Avi said, Xen is dealing with the linux pte only, so there's no
racy smp page fault to serialize against. Perhaps we can add another
notifier for Xen though.

But I think it's still not enough for Xen to have a method called
before the ptep_clear_flush: rmap.c would get confused in
page_mkclean_one for example. It might be possible that vm_ops is the
right way for you even if it further clutters the VM. Like Avi pointed
me out once, with our current mmu_notifiers we can export the KVM
address space with remote dma and keep swapping the whole KVM asset
just fine despite the triple MMU running the system (qemu using linux
pte, KVM using spte, quadrics using pcimmu). And the core Linux VM
code (not some obscure hypervisor) will deal with all aging and VM
issues like a normal task (especially with my last patch that reflects
the accessed bitflag in the spte the same way the accessed bitflag is
reflected for the regular ptes).

Nevertheless if you've any idea on how to use the notifiers for Xen
I'd be glad to help. Perhaps one workable way to change my patch to
work for you could be to pass the retval of ptep_clear_flush to the
notifiers themself. something like:

#define ptep_clear_flush(__vma, __address, __ptep)			\
({									\
	pte_t __pte;							\
	__pte = ptep_get_and_clear((__vma)->vm_mm, __address, __ptep);	\
	flush_tlb_page(__vma, __address);				\
	__pte = mmu_notifier(invalidate_page, (__vma)->vm_mm, __address, __pte, __ptep);	\
	__pte;								\
})

But this would kind of need an exclusive registration or this loop
wouldn't work well if everyone pretends to overwrite the memory
pointed by __ptep with its own value calculated in function of __pte.

    for_each_notifier(mn,mm)
        mn->invalidate_page(mm, __address, __pte, __ptep);

You could get a pte_none page fault in between the old value and the
new value though. (but you wouldn't need to flush the tlb inside
invalidate_pte, only us need to flush the secondary tlb for the spte
inside the invalidate_page obviously)

Let me know if you're interested in the above.

Thanks!

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

Messages in current thread:
[PATCH] mmu notifiers #v2, Andrea Arcangeli, (Sun Jan 13, 12:24 pm)
Re: [PATCH] mmu notifiers #v2, Rik van Riel, (Wed Jan 16, 1:42 pm)
Re: [PATCH] mmu notifiers #v2, Izik Eidus, (Wed Jan 16, 1:48 pm)
Re: [PATCH] mmu notifiers #v2, Andrea Arcangeli, (Thu Jan 17, 12:23 pm)
Re: [PATCH] mmu notifiers #v2, Izik Eidus, (Thu Jan 17, 2:21 pm)
Re: [PATCH] mmu notifiers #v2, Andrea Arcangeli, (Thu Jan 17, 3:32 pm)
[PATCH] mmu notifiers #v3, Andrea Arcangeli, (Mon Jan 21, 8:52 am)
Re: [PATCH] mmu notifiers #v3, Peter Zijlstra, (Tue Jan 22, 3:28 pm)
Re: [PATCH] mmu notifiers #v3, Andrea Arcangeli, (Tue Jan 22, 4:31 pm)
Re: [PATCH] mmu notifiers #v3, Hugh Dickins, (Tue Jan 22, 6:10 pm)
Re: [PATCH] mmu notifiers #v3, Christoph Lameter, (Tue Jan 22, 4:31 pm)
Re: [kvm-devel] [PATCH] mmu notifiers #v3, Avi Kivity, (Tue Jan 22, 10:12 am)
Re: [kvm-devel] [PATCH] mmu notifiers #v3, Andrea Arcangeli, (Tue Jan 22, 10:43 am)
Re: [kvm-devel] [PATCH] mmu notifiers #v4, Andrea Arcangeli, (Tue Jan 22, 4:08 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Tue Jan 22, 4:34 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Gerd Hoffmann, (Wed Jan 23, 8:51 am)
Re: [kvm-devel] [PATCH] export notifier #1, Andrea Arcangeli, (Wed Jan 23, 11:41 am)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Wed Jan 23, 4:40 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Gerd Hoffmann, (Wed Jan 23, 1:47 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Jeremy Fitzhardinge, (Thu Jan 24, 2:45 am)
Re: [kvm-devel] [PATCH] export notifier #1, Avi Kivity, (Thu Jan 24, 2:01 am)
Re: [kvm-devel] [PATCH] export notifier #1, Robin Holt, (Wed Jan 23, 9:19 am)
Re: [kvm-devel] [PATCH] export notifier #1, Avi Kivity, (Wed Jan 23, 10:17 am)
Re: [kvm-devel] [PATCH] export notifier #1, Benjamin Herrenschmidt, (Thu Jan 24, 12:03 am)
Re: [kvm-devel] [PATCH] export notifier #1, Gerd Hoffmann, (Wed Jan 23, 10:12 am)
Re: [kvm-devel] [PATCH] export notifier #1, Robin Holt, (Wed Jan 23, 10:18 am)
Re: [kvm-devel] [PATCH] export notifier #1, Gerd Hoffmann, (Wed Jan 23, 10:35 am)
Re: [kvm-devel] [PATCH] export notifier #1, Robin Holt, (Wed Jan 23, 11:48 am)
Re: [kvm-devel] [PATCH] export notifier #1, Benjamin Herrenschmidt, (Tue Jan 22, 7:36 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Tue Jan 22, 8:40 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Robin Holt, (Tue Jan 22, 9:21 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Andrea Arcangeli, (Tue Jan 22, 6:31 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Tue Jan 22, 6:53 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Andrea Arcangeli, (Wed Jan 23, 7:41 am)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Wed Jan 23, 4:18 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Andrea Arcangeli, (Thu Jan 24, 10:34 am)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Thu Jan 24, 4:01 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Avi Kivity, (Thu Jan 24, 11:15 am)
Re: [kvm-devel] [PATCH] export notifier #1, Avi Kivity, (Thu Jan 24, 11:18 am)
Re: [kvm-devel] [PATCH] export notifier #1, Andrea Arcangeli, (Thu Jan 24, 10:41 am)
Re: [kvm-devel] [PATCH] export notifier #1, Robin Holt, (Wed Jan 23, 8:32 am)
Re: [kvm-devel] [PATCH] export notifier #1, Andrea Arcangeli, (Wed Jan 23, 1:33 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Wed Jan 23, 4:27 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Andrea Arcangeli, (Thu Jan 24, 11:42 am)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Thu Jan 24, 4:07 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Avi Kivity, (Fri Jan 25, 2:35 am)
Re: [kvm-devel] [PATCH] export notifier #1, Avi Kivity, (Wed Jan 23, 6:27 am)
Re: [kvm-devel] [PATCH] export notifier #1, Robin Holt, (Wed Jan 23, 6:52 am)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Wed Jan 23, 3:47 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Avi Kivity, (Thu Jan 24, 1:56 am)
Re: [kvm-devel] [PATCH] export notifier #1, Andrea Arcangeli, (Thu Jan 24, 8:26 am)
Re: [kvm-devel] [PATCH] export notifier #1, Avi Kivity, (Thu Jan 24, 8:34 am)
Re: [kvm-devel] [PATCH] export notifier #1, Andrea Arcangeli, (Wed Jan 23, 8:04 am)
Re: [kvm-devel] [PATCH] export notifier #1, Christoph Lameter, (Wed Jan 23, 3:48 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Robin Holt, (Wed Jan 23, 3:58 pm)
Re: [kvm-devel] [PATCH] export notifier #1, Robin Holt, (Wed Jan 23, 8:34 am)
Re: [PATCH] mmu notifiers #v3, Rik van Riel, (Mon Jan 21, 10:21 pm)
Re: [PATCH] mmu notifiers #v2, Brice Goglin, (Wed Jan 16, 5:01 am)
Re: [PATCH] mmu notifiers #v2, Andrea Arcangeli, (Wed Jan 16, 6:19 am)
Re: [PATCH] mmu notifiers #v2, Christoph Lameter, (Mon Jan 14, 4:02 pm)
Re: [PATCH] mmu notifiers #v2, Andrea Arcangeli, (Tue Jan 15, 8:44 am)
Re: [PATCH] mmu notifiers #v2, Benjamin Herrenschmidt, (Tue Jan 15, 4:18 pm)
Re: [PATCH] mmu notifiers #v2, Andrea Arcangeli, (Tue Jan 15, 9:06 pm)
Re: [PATCH] mmu notifiers #v2, Benjamin Herrenschmidt, (Tue Jan 15, 12:28 am)
Re: [PATCH] mmu notifiers #v2, Benjamin Herrenschmidt, (Sun Jan 13, 5:11 pm)