Source-Changes-HG archive

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

[src/trunk]: src/sys/arch malloc(9) -> kmem(9)



details:   https://anonhg.NetBSD.org/src/rev/9e5fcb86dfc8
branches:  trunk
changeset: 946179:9e5fcb86dfc8
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Nov 20 17:38:05 2020 +0000

description:
malloc(9) -> kmem(9)

diffstat:

 sys/arch/acorn32/mainbus/fd.c           |  11 +++++------
 sys/arch/acorn32/podulebus/podulebus.c  |   8 ++++----
 sys/arch/amd64/amd64/netbsd32_machdep.c |  18 +++++++++++-------
 3 files changed, 20 insertions(+), 17 deletions(-)

diffs (144 lines):

diff -r 6ff20924b34a -r 9e5fcb86dfc8 sys/arch/acorn32/mainbus/fd.c
--- a/sys/arch/acorn32/mainbus/fd.c     Fri Nov 20 13:33:07 2020 +0000
+++ b/sys/arch/acorn32/mainbus/fd.c     Fri Nov 20 17:38:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.61 2019/11/10 21:16:21 chs Exp $      */
+/*     $NetBSD: fd.c,v 1.62 2020/11/20 17:38:05 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.61 2019/11/10 21:16:21 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.62 2020/11/20 17:38:05 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -97,7 +97,7 @@
 #include <sys/disk.h>
 #include <sys/buf.h>
 #include <sys/bufq.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/uio.h>
 #include <sys/syslog.h>
 #include <sys/queue.h>
@@ -1397,8 +1397,7 @@
                        return EINVAL;
                }
 
-               fd_formb = malloc(sizeof(struct ne7_fd_formb), 
-                   M_TEMP, M_WAITOK);
+               fd_formb = kmem_alloc(sizeof(*fd_formb), KM_SLEEP);
                fd_formb->head = form_cmd->head;
                fd_formb->cyl = form_cmd->cylinder;
                fd_formb->transfer_rate = fd->sc_type->rate;
@@ -1422,7 +1421,7 @@
                }
 
                error = fdformat(dev, fd_formb, l);
-               free(fd_formb, M_TEMP);
+               kmem_free(fd_formb, sizeof(*fd_formb));
                return error;
 
        case FDIOCGETOPTS:              /* get drive options */
diff -r 6ff20924b34a -r 9e5fcb86dfc8 sys/arch/acorn32/podulebus/podulebus.c
--- a/sys/arch/acorn32/podulebus/podulebus.c    Fri Nov 20 13:33:07 2020 +0000
+++ b/sys/arch/acorn32/podulebus/podulebus.c    Fri Nov 20 17:38:05 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: podulebus.c,v 1.29 2014/10/25 10:58:12 skrll Exp $ */
+/* $NetBSD: podulebus.c,v 1.30 2020/11/20 17:38:05 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994-1996 Mark Brinicombe.
@@ -43,12 +43,12 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: podulebus.c,v 1.29 2014/10/25 10:58:12 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: podulebus.c,v 1.30 2020/11/20 17:38:05 thorpej Exp $");
 
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/conf.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
 #include <uvm/uvm_extern.h>
 #include <machine/io.h>
@@ -561,7 +561,7 @@
         */
 
        /* XXX never freed, but podules are never detached anyway. */
-        *tagp = malloc(sizeof(struct bus_space), M_DEVBUF, M_WAITOK);
+        *tagp = kmem_alloc(sizeof(struct bus_space), KM_SLEEP);
        **tagp = *tag;
        (*tagp)->bs_cookie = (void *)shift;
 }
diff -r 6ff20924b34a -r 9e5fcb86dfc8 sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c   Fri Nov 20 13:33:07 2020 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c   Fri Nov 20 17:38:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.136 2020/04/25 15:26:16 bouyer Exp $    */
+/*     $NetBSD: netbsd32_machdep.c,v 1.137 2020/11/20 17:44:56 thorpej Exp $   */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.136 2020/04/25 15:26:16 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.137 2020/11/20 17:44:56 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -50,7 +50,7 @@
 #include <sys/exec.h>
 #include <sys/exec_aout.h>
 #include <sys/kmem.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/proc.h>
 #include <sys/signalvar.h>
 #include <sys/systm.h>
@@ -632,14 +632,16 @@
        if (ua.num < 0 || ua.num > MAX_USERLDT_SLOTS)
                return EINVAL;
 
-       descv = malloc(sizeof(*descv) * ua.num, M_TEMP, M_WAITOK);
+       const size_t alloc_size = sizeof(*descv) * ua.num;
+
+       descv = kmem_alloc(alloc_size, KM_SLEEP);
        error = copyin((void *)(uintptr_t)ua32.desc, descv,
            sizeof(*descv) * ua.num);
        if (error == 0)
                error = x86_set_ldt1(l, &ua, descv);
        *retval = ua.start;
 
-       free(descv, M_TEMP);
+       kmem_free(descv, alloc_size);
        return error;
 }
 
@@ -660,14 +662,16 @@
        if (ua.num < 0 || ua.num > MAX_USERLDT_SLOTS)
                return EINVAL;
 
-       cp = malloc(ua.num * sizeof(union descriptor), M_TEMP, M_WAITOK);
+       const size_t alloc_size = ua.num * sizeof(union descriptor);
+
+       cp = kmem_alloc(alloc_size, KM_SLEEP);
        error = x86_get_ldt1(l, &ua, cp);
        *retval = ua.num;
        if (error == 0)
                error = copyout(cp, (void *)(uintptr_t)ua32.desc,
                    ua.num * sizeof(*cp));
 
-       free(cp, M_TEMP);
+       kmem_free(cp, alloc_size);
        return error;
 }
 #endif



Home | Main Index | Thread Index | Old Index