WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [Linux PATCH] Mark hugepages to the hypervisor to speed up m

To: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Subject: [Xen-devel] [Linux PATCH] Mark hugepages to the hypervisor to speed up mapping
From: Dave McCracken <dcm@xxxxxxxx>
Date: Wed, 09 Jun 2010 10:49:32 -0500
Cc: Xen Developers List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Wed, 09 Jun 2010 08:50:32 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:date :message-id:subject; bh=gre+4YargCM9AvewlJg/aB3gN50TeigHQXXGSjtn+Ko=; b=rYFTh+cS7p2mLUT5xXUgv1kBBFTUw+XRCTyKYWN2F3jk5r/zNQ2nhwHL607DddJMq4 jrMKJBMdpqHSSrofuQ0lGLM78QXQHl8pQpZVB31BErO/gJHKHYuzYQ9Kaah12vrAMEve tBC1lhPV6oruTlv7TVoC9B2kboQ2+rpsblfQk=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:date:message-id:subject; b=m87PbD4OQ6EyzVjWe5T+TSZ4dIpz6ej/OohYPVAzxkmkZWyYW0KR6qvtO+9mcGCIAF VTNPDCYmRDRUGfLpT+QgxkAOZjAlCAqy5v3Ljh8xLENAy6cCZDc8zZOGcChIa9IaPRDg ySximtti/DJMsKuGJIgZSyDeYvURGd/hoyrEk=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
--- next/arch/x86/xen/mmu.c     2010-06-01 11:41:54.000000000 -0500
+++ next-fh//arch/x86/xen/mmu.c 2010-06-02 08:45:01.000000000 -0500
@@ -2531,3 +2531,51 @@ static int __init xen_mmu_debugfs(void)
 fs_initcall(xen_mmu_debugfs);
 
 #endif /* CONFIG_XEN_DEBUG_FS */
+
+static int mark_ok = 1;
+
+int arch_prepare_hugepage(struct page *page)
+{
+       struct mmuext_op op;
+       unsigned long pfn, mfn, m;
+       int i;
+       int rc;
+
+       pfn = page_to_pfn(page);
+       mfn = pfn_to_mfn(pfn);
+       if (mfn & ((HPAGE_SIZE/PAGE_SIZE)-1)) {
+               printk("Guest pages are not properly aligned to use 
hugepages\n");
+               return 1;
+       }
+       for (i = 0, m = mfn; i < HPAGE_SIZE/PAGE_SIZE; i++, pfn++, m++) {
+               if (pfn_to_mfn(pfn) != m) {
+                       printk("Guest pages are not properly aligned to use 
hugepages\n");
+                       return 1;
+               }
+       }
+       /* It's ok if this fails.  We just fall back to the slow refcounting */
+       if (mark_ok) {
+               op.cmd = MMUEXT_MARK_SUPER;
+               op.arg1.mfn = mfn;
+               rc = HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF);
+               if (rc) {
+                       if (rc == -ENOSYS) {
+                               mark_ok = 0;
+                               return 0;
+                       }
+                       return 1;
+               }
+       }
+       return 0;
+}
+
+void arch_release_hugepage(struct page *page)
+{
+       struct mmuext_op op;
+
+       if (mark_ok) {
+               op.cmd = MMUEXT_UNMARK_SUPER;
+               op.arg1.mfn = pfn_to_mfn(page_to_pfn(page));
+               HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF);
+       }
+}
--- next/arch/x86/include/asm/hugetlb.h 2010-06-01 11:41:54.000000000 -0500
+++ next-fh//arch/x86/include/asm/hugetlb.h     2010-06-02 08:37:58.000000000 
-0500
@@ -95,6 +95,10 @@ static inline int huge_ptep_set_access_f
        return changed;
 }
 
+#ifdef CONFIG_XEN
+int arch_prepare_hugepage(struct page *page);
+void arch_release_hugepage(struct page *page);
+#else
 static inline int arch_prepare_hugepage(struct page *page)
 {
        return 0;
@@ -103,5 +107,6 @@ static inline int arch_prepare_hugepage(
 static inline void arch_release_hugepage(struct page *page)
 {
 }
+#endif
 
 #endif /* _ASM_X86_HUGETLB_H */
--- next/include/xen/interface/xen.h    2010-06-01 11:41:59.000000000 -0500
+++ next-fh//include/xen/interface/xen.h        2010-06-02 08:38:50.000000000 
-0500
@@ -167,6 +167,19 @@
  * cmd: MMUEXT_SET_LDT
  * linear_addr: Linear address of LDT base (NB. must be page-aligned).
  * nr_ents: Number of entries in LDT.
+ *
+ * cmd: MMUEXT_CLEAR_PAGE
+ * mfn: Machine frame number to be cleared.
+ *
+ * cmd: MMUEXT_COPY_PAGE
+ * mfn: Machine frame number of the destination page.
+ * src_mfn: Machine frame number of the source page.
+ *
+ * cmd: MMUEXT_MARK_SUPER
+ * mfn: Machine frame number of head of superpage to be marked.
+ *
+ * cmd: MMUEXT_UNMARK_SUPER
+ * mfn: Machine frame number of head of superpage to be cleared.
  */
 #define MMUEXT_PIN_L1_TABLE      0
 #define MMUEXT_PIN_L2_TABLE      1
@@ -183,6 +196,10 @@
 #define MMUEXT_FLUSH_CACHE      12
 #define MMUEXT_SET_LDT          13
 #define MMUEXT_NEW_USER_BASEPTR 15
+#define MMUEXT_CLEAR_PAGE       16
+#define MMUEXT_COPY_PAGE        17
+#define MMUEXT_MARK_SUPER       19
+#define MMUEXT_UNMARK_SUPER     20
 
 #ifndef __ASSEMBLY__
 #include <linux/types.h>

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [Linux PATCH] Mark hugepages to the hypervisor to speed up mapping, Dave McCracken <=