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 Attempts to make MP-safe:



details:   https://anonhg.NetBSD.org/src/rev/ee1709488da0
branches:  trunk
changeset: 971862:ee1709488da0
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed May 06 19:52:19 2020 +0000

description:
Attempts to make MP-safe:
xpmap_ptom_unmap() doens't need to be called at splvm; we own the pa.
Use atomic ops to change pmap_pa_end
Make sure the ptom/mtop are up to date before giving the pages back to the
pool.

diffstat:

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

diffs (93 lines):

diff -r 00a956a0bafb -r ee1709488da0 sys/arch/xen/xen/balloon.c
--- a/sys/arch/xen/xen/balloon.c        Wed May 06 19:50:26 2020 +0000
+++ b/sys/arch/xen/xen/balloon.c        Wed May 06 19:52:19 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: balloon.c,v 1.22 2020/05/06 17:27:39 bouyer Exp $ */
+/* $NetBSD: balloon.c,v 1.23 2020/05/06 19:52:19 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.22 2020/05/06 17:27:39 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.23 2020/05/06 19:52:19 bouyer Exp $");
 
 #include <sys/inttypes.h>
 #include <sys/device.h>
@@ -366,7 +366,7 @@
 static size_t
 balloon_inflate(struct balloon_xenbus_softc *sc, size_t tpages)
 {
-       int rpages, s, ret;
+       int rpages, ret;
        paddr_t pa;
        struct balloon_page_entry *bpg_entry;
        xen_pfn_t *mfn_list = sc->sc_mfn_list;
@@ -395,10 +395,8 @@
 
                mfn_list[rpages] = xpmap_ptom(pa) >> PAGE_SHIFT;
 
-               s = splvm(); /* XXXSMP */
                /* Invalidate pg */
                xpmap_ptom_unmap(pa);
-               splx(s);
 
                SLIST_INSERT_HEAD(&balloon_sc->balloon_page_entries, 
                                  bpg_entry, entry);
@@ -494,19 +492,29 @@
                        pa = pmap_pa_end;
 
                        /* P2M update */
-                       s = splvm(); /* XXXSMP */
-                       pmap_pa_end += PAGE_SIZE; /* XXX: TLB flush ?*/
+#if defined(_LP64) || defined(PAE)
+                       atomic_add_64(&pmap_pa_end, PAGE_SIZE);
+#else
+                       atomic_add_32(&pmap_pa_end, PAGE_SIZE);
+#endif
+                       s = splvm();
                        xpmap_ptom_map(pa, ptoa(mfn_list[rpages]));
                        xpq_queue_machphys_update(ptoa(mfn_list[rpages]), pa);
+                       xpq_flush_queue();
                        splx(s);
 
                        if (uvm_physseg_plug(atop(pa), 1, NULL) == false) {
                                /* Undo P2M */
-                               s = splvm(); /* XXXSMP */
+                               s = splvm();
                                xpmap_ptom_unmap(pa);
                                xpq_queue_machphys_update(ptoa(mfn_list[rpages]), 0);
-                               pmap_pa_end -= PAGE_SIZE; /* XXX: TLB flush ?*/
+                               xpq_flush_queue();
                                splx(s);
+#if defined(_LP64) || defined(PAE)
+                               atomic_add_64(&pmap_pa_end, -PAGE_SIZE);
+#else
+                               atomic_add_32(&pmap_pa_end, -PAGE_SIZE);
+#endif
                                break;
                        }
                        continue;
@@ -529,18 +537,15 @@
                /* Update P->M */
                pa = VM_PAGE_TO_PHYS(bpg_entry->pg);
 
-               s = splvm(); /* XXXSMP */
-
+               s = splvm();
                xpmap_ptom_map(pa, ptoa(mfn_list[rpages]));
                xpq_queue_machphys_update(ptoa(mfn_list[rpages]), pa);
-
+               xpq_flush_queue();
                splx(s);
 
                pool_cache_put(sc->bpge_pool, bpg_entry);
        }
 
-       xpq_flush_queue();
-
 #if BALLOONDEBUG
        device_printf(sc->sc_dev, "deflate %zu => deflated by %d\n",
            tpages, rpages);



Home | Main Index | Thread Index | Old Index