Skip to contentSkip to conversation

linux: Add a hook before a page table entry is cleared, for use with

Xen-staging Alex Williamson 2 participants 2 messages Mar 31, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

This doesn't work very well for archs that don't define
__HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL as ptep_get_and_clear_full is then defined as a macro. I'd suggest a different name to avoid conflicts. Thanks,

Alex

Quoted 64 lines · Xen staging patchbot-unstable

# HG changeset patch
# User Keir Fraser <[email protected]>
# Date 1175341322 -3600
# Node ID 7180d2e61f926023e24750c53fd4203a71f2a3ae
# Parent 2de267ba9a76e1358601505e16786969f317aa7d
linux: Add a hook before a page table entry is cleared, for use with the grant-table device.

---
 linux-2.6-xen-sparse/include/linux/mm.h |    5 +++++
 linux-2.6-xen-sparse/mm/memory.c        |   12 ++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff -r 2de267ba9a76 -r 7180d2e61f92 linux-2.6-xen-sparse/include/linux/mm.h

linux-2.6-xen-sparse/include/linux/mm.h +5 -0
@@ -205,6 +205,11 @@ struct vm_operations_struct {
 	/* notification that a previously read-only page is about to become
 	 * writable, if an error is returned it will cause a SIGBUS */
 	int (*page_mkwrite)(struct vm_area_struct *vma, struct page *page);
+	/* Area-specific function for clearing the PTE at @ptep. Returns the
+	 * original value of @ptep. */
+	pte_t (*ptep_get_and_clear_full)(struct vm_area_struct *vma, 
+					 unsigned long addr, pte_t *ptep, 
+					 int is_fullmm);
 #ifdef CONFIG_NUMA
 	int (*set_policy)(struct vm_area_struct *vma, struct mempolicy *new);
 	struct mempolicy *(*get_policy)(struct vm_area_struct *vma,

diff -r 2de267ba9a76 -r 7180d2e61f92 linux-2.6-xen-sparse/mm/memory.c

linux-2.6-xen-sparse/mm/memory.c +10 -2
@@ -659,8 +659,15 @@ static unsigned long zap_pte_range(struc
 				     page->index > details->last_index))
 					continue;
 			}
-			ptent = ptep_get_and_clear_full(mm, addr, pte,
-							tlb->fullmm);
+			if (unlikely(vma->vm_ops && 
+				     vma->vm_ops->ptep_get_and_clear_full))
+				ptent = vma->vm_ops->
+					ptep_get_and_clear_full(vma, addr,
+								pte,
+								tlb->fullmm);
+			else
+				ptent = ptep_get_and_clear_full(mm, addr, pte,
+								tlb->fullmm);
 			tlb_remove_tlb_entry(tlb, pte, addr);
 			if (unlikely(!page))
 				continue;
@@ -755,6 +762,7 @@ static unsigned long unmap_page_range(st
 		details = NULL;
 
 	BUG_ON(addr >= end);
+
 	tlb_start_vma(tlb, vma);
 	pgd = pgd_offset(vma->vm_mm, addr);
 	do {

_______________________________________________
Xen-staging mailing list
[email protected]
http://lists.xensource.com/xen-staging

Signature · 1 line
Alex Williamson                             HP Open Source & Linux Org.
#2 lore raw
Quoted 3 lines · Alex Williamson

This doesn't work very well for archs that don't define
__HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL as ptep_get_and_clear_full is then defined as a macro. I'd suggest a different name to avoid conflicts.

That's a bit of a pain. I'll change to zap_pte.

-- Keir