Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Fix 32bit overflow when calculating balloon size.



details:   https://anonhg.NetBSD.org/src/rev/30169de56d94
branches:  trunk
changeset: 374022:30169de56d94
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Mar 25 11:00:35 2023 +0000

description:
Fix 32bit overflow when calculating balloon size.
Don't make uvm_pglistalloc wait, it will wait forever. Instead rely on
the retries by this driver. This also allows to cancel the request.
Increase inflate speed by factor 10 (same as deflate).

diffstat:

 sys/dev/pci/viomb.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (41 lines):

diff -r 9f978425621a -r 30169de56d94 sys/dev/pci/viomb.c
--- a/sys/dev/pci/viomb.c       Sat Mar 25 09:03:47 2023 +0000
+++ b/sys/dev/pci/viomb.c       Sat Mar 25 11:00:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: viomb.c,v 1.15 2023/03/23 03:55:11 yamaguchi Exp $     */
+/*     $NetBSD: viomb.c,v 1.16 2023/03/25 11:00:35 mlelstv Exp $       */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.15 2023/03/23 03:55:11 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.16 2023/03/25 11:00:35 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -286,8 +286,8 @@ inflate(struct viomb_softc *sc)
        nhpages = nvpages * VIRTIO_PAGE_SIZE / PAGE_SIZE;
 
        b = &sc->sc_req;
-       if (uvm_pglistalloc(nhpages*PAGE_SIZE, 0, UINT32_MAX*PAGE_SIZE,
-                           0, 0, &b->bl_pglist, nhpages, 1)) {
+       if (uvm_pglistalloc(nhpages*PAGE_SIZE, 0, UINT32_MAX*(paddr_t)PAGE_SIZE,
+                           0, 0, &b->bl_pglist, nhpages, 0)) {
                printf("%s: %" PRIu64 " pages of physical memory "
                       "could not be allocated, retrying...\n",
                       device_xname(sc->sc_dev), nhpages);
@@ -507,9 +507,9 @@ viomb_thread(void *arg)
                                if (r != 0)
                                        sleeptime = 10000;
                                else
-                                       sleeptime = 1000;
+                                       sleeptime = 100;
                        } else
-                               sleeptime = 100;
+                               sleeptime = 20;
                } else if (sc->sc_npages < sc->sc_actual + sc->sc_inflight) {
                        if (sc->sc_inflight == 0)
                                r = deflate(sc);



Home | Main Index | Thread Index | Old Index