Module Name: src Committed By: cherry Date: Fri Dec 23 17:01:10 UTC 2016
Modified Files: src/sys/arch/xen/xen: balloon.c Log Message: balloon(4) can now use uvm_hotplug(9) Do this. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/xen/xen/balloon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/xen/xen/balloon.c diff -u src/sys/arch/xen/xen/balloon.c:1.17 src/sys/arch/xen/xen/balloon.c:1.18 --- src/sys/arch/xen/xen/balloon.c:1.17 Thu Jul 7 06:55:40 2016 +++ src/sys/arch/xen/xen/balloon.c Fri Dec 23 17:01:10 2016 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: balloon.c,v #include <uvm/uvm.h> #include <uvm/uvm.h> +#include <uvm/uvm_physseg.h> #include <xen/xenpmap.h> #include "locators.h" @@ -454,6 +459,7 @@ balloon_deflate(struct balloon_xenbus_so 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 @@ balloon_deflate(struct balloon_xenbus_so 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 @@ balloon_deflate(struct balloon_xenbus_so /* plug pages back into memory through bpge entries */ for (rpages = 0; rpages < ret; rpages++) { - -#ifdef noyet +#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; + + /* 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 @@ balloon_deflate(struct balloon_xenbus_so 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--;