Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/xen/xen balloon(4) can now use uvm_hotplug(9)



details:   https://anonhg.NetBSD.org/src/rev/356e6840808f
branches:  trunk
changeset: 819931:356e6840808f
user:      cherry <cherry%NetBSD.org@localhost>
date:      Fri Dec 23 17:01:10 2016 +0000

description:
balloon(4) can now use uvm_hotplug(9)

Do this.

diffstat:

 sys/arch/xen/xen/balloon.c |  37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diffs (88 lines):

diff -r d8a8cf4938a4 -r 356e6840808f sys/arch/xen/xen/balloon.c
--- a/sys/arch/xen/xen/balloon.c        Fri Dec 23 11:27:10 2016 +0000
+++ b/sys/arch/xen/xen/balloon.c        Fri Dec 23 17:01:10 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: balloon.c,v 1.17 2016/07/07 06:55:40 msaitoh Exp $ */
+/* $NetBSD: balloon.c,v 1.18 2016/12/23 17:01:10 cherry Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -70,8 +70,12 @@
 
 #define BALLOONDEBUG 0
 
+#if defined(_KERNEL_OPT)
+#include "opt_uvm_hotplug.h"
+#endif
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.17 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.18 2016/12/23 17:01:10 cherry Exp $");
 
 #include <sys/inttypes.h>
 #include <sys/device.h>
@@ -93,6 +97,7 @@
 
 #include <uvm/uvm.h>
 #include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>
 #include <xen/xenpmap.h>
 
 #include "locators.h"
@@ -454,6 +459,7 @@
        
        memset(mfn_list, 0, BALLOON_DELTA * sizeof(*mfn_list));
 
+#ifndef UVM_HOTPLUG
        /* 
         * If the list is empty, we are deflating balloon beyond empty. This
         * is currently unsupported as this would require to dynamically add
@@ -469,6 +475,7 @@
                    tpages, sc->balloon_num_page_entries);
                tpages = sc->balloon_num_page_entries;
        }
+#endif
 
        /* reclaim pages from balloon */
        set_xen_guest_handle(reservation.extent_start, mfn_list);
@@ -491,8 +498,31 @@
 
        /* plug pages back into memory through bpge entries */
        for (rpages = 0; rpages < ret; rpages++) {
+#ifdef UVM_HOTPLUG
+               extern paddr_t pmap_pa_end;
+               if (sc->balloon_num_page_entries == 0) { /*XXX: consolidate */
+                       /* "hot-plug": Stick it at the end of memory */
+                       pa = pmap_pa_end;
 
-#ifdef noyet
+                       /* P2M update */
+                       s = splvm();
+                       pmap_pa_end += PAGE_SIZE; /* XXX: TLB flush ?*/
+                       xpmap_ptom_map(pa, ptoa(mfn_list[rpages]));
+                       xpq_queue_machphys_update(ptoa(mfn_list[rpages]), pa);
+                       splx(s);
+
+                       if (uvm_physseg_plug(atop(pa), 1, NULL) == false) {
+                               /* Undo P2M */
+                               s = splvm();
+                               xpmap_ptom_unmap(pa);
+                               xpq_queue_machphys_update(ptoa(mfn_list[rpages]), 0);
+                               pmap_pa_end -= PAGE_SIZE; /* XXX: TLB flush ?*/
+                               splx(s);
+                               break;
+                       }
+                       continue;
+               }
+#else
                if (sc->balloon_num_page_entries == 0) {
                        /*
                         * XXX This is the case where extra "hot-plug"
@@ -503,7 +533,6 @@
                        break;
                }
 #endif
-
                bpg_entry = SLIST_FIRST(&balloon_sc->balloon_page_entries);
                SLIST_REMOVE_HEAD(&balloon_sc->balloon_page_entries, entry);
                balloon_sc->balloon_num_page_entries--;



Home | Main Index | Thread Index | Old Index