From 8a3ee72648c6aa4fb88acdeffa5fcdd288e4bbe3 Mon Sep 17 00:00:00 2001 From: jdolecek Date: Tue, 7 Apr 2020 08:14:42 +0000 Subject: [PATCH] switch KERNFS_ALLOCENTRY() to use kmem_zalloc() instead of malloc() --- sys/arch/xen/xen/hypervisor.c | 9 ++++----- sys/arch/xen/xen/pciback.c | 8 ++++---- sys/arch/xen/xen/privcmd.c | 7 +++---- sys/arch/xen/xenbus/xenbus_dev.c | 8 ++++---- sys/miscfs/kernfs/kernfs.h | 8 ++++---- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/sys/arch/xen/xen/hypervisor.c b/sys/arch/xen/xen/hypervisor.c index f4f1d9d56e96..534b63f666e1 100644 --- a/sys/arch/xen/xen/hypervisor.c +++ b/sys/arch/xen/xen/hypervisor.c @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.72 2019/02/14 08:18:26 cherry Exp $ */ +/* $NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -53,12 +53,11 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.72 2019/02/14 08:18:26 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $"); #include #include #include -#include #include #include "xenbus.h" @@ -416,7 +415,7 @@ hypervisor_match(device_t parent, cfdata_t match, void *aux) bi.common.len = sizeof(struct btinfo_rootdevice); /* From i386/multiboot.c */ - /* $NetBSD: hypervisor.c,v 1.72 2019/02/14 08:18:26 cherry Exp $ */ + /* $NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $ */ int i, len; vaddr_t data; extern struct bootinfo bootinfo; @@ -671,7 +670,7 @@ xenkernfs_init(void) { kernfs_entry_t *dkt; - KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK); + KERNFS_ALLOCENTRY(dkt, KM_SLEEP); KERNFS_INITENTRY(dkt, DT_DIR, "xen", NULL, KFSsubdir, VDIR, DIR_MODE); kernfs_addentry(NULL, dkt); kernxen_pkt = KERNFS_ENTOPARENTDIR(dkt); diff --git a/sys/arch/xen/xen/pciback.c b/sys/arch/xen/xen/pciback.c index 4fb7445a475a..1dccb8dff1eb 100644 --- a/sys/arch/xen/xen/pciback.c +++ b/sys/arch/xen/xen/pciback.c @@ -1,4 +1,4 @@ -/* $NetBSD: pciback.c,v 1.19 2019/02/02 12:32:55 cherry Exp $ */ +/* $NetBSD: pciback.c,v 1.20 2020/04/07 08:14:42 jdolecek Exp $ */ /* * Copyright (c) 2009 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.19 2019/02/02 12:32:55 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.20 2020/04/07 08:14:42 jdolecek Exp $"); #include "opt_xen.h" @@ -290,7 +290,7 @@ pciback_pci_attach(device_t parent, device_t self, void *aux) snprintf(sc->sc_kernfsname, sizeof(sc->sc_kernfsname), "0000:%02x:%02x.%x", pa->pa_bus, pa->pa_device, pa->pa_function); kfst = KERNFS_ALLOCTYPE(pciback_dev_fileops); - KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK); + KERNFS_ALLOCENTRY(dkt, KM_SLEEP); KERNFS_INITENTRY(dkt, DT_REG, sc->sc_kernfsname, sc, kfst, VREG, FILE_MODE); kernfs_addentry(pciback_kern_pkt, dkt); @@ -405,7 +405,7 @@ pciback_pci_init(void) xenbus_backend_register(&pci_backend_driver); - KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK); + KERNFS_ALLOCENTRY(dkt, KM_SLEEP); KERNFS_INITENTRY(dkt, DT_DIR, "pci", NULL, KFSsubdir, VDIR, DIR_MODE); kernfs_addentry(kernxen_pkt, dkt); pciback_kern_pkt = KERNFS_ENTOPARENTDIR(dkt); diff --git a/sys/arch/xen/xen/privcmd.c b/sys/arch/xen/xen/privcmd.c index 62643a269cd5..c0e7e504bec9 100644 --- a/sys/arch/xen/xen/privcmd.c +++ b/sys/arch/xen/xen/privcmd.c @@ -1,4 +1,4 @@ -/* $NetBSD: privcmd.c,v 1.53 2020/02/23 15:46:39 ad Exp $ */ +/* $NetBSD: privcmd.c,v 1.54 2020/04/07 08:14:42 jdolecek Exp $ */ /*- * Copyright (c) 2004 Christian Limpach. @@ -27,12 +27,11 @@ #include -__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.53 2020/02/23 15:46:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.54 2020/04/07 08:14:42 jdolecek Exp $"); #include #include #include -#include #include #include #include @@ -572,7 +571,7 @@ xenprivcmd_init(void) kfst = KERNFS_ALLOCTYPE(privcmd_fileops); - KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK); + KERNFS_ALLOCENTRY(dkt, KM_SLEEP); KERNFS_INITENTRY(dkt, DT_REG, "privcmd", NULL, kfst, VREG, PRIVCMD_MODE); kernfs_addentry(kernxen_pkt, dkt); diff --git a/sys/arch/xen/xenbus/xenbus_dev.c b/sys/arch/xen/xenbus/xenbus_dev.c index 1f96e2b0598b..9b0789a8fd1b 100644 --- a/sys/arch/xen/xenbus/xenbus_dev.c +++ b/sys/arch/xen/xenbus/xenbus_dev.c @@ -1,4 +1,4 @@ -/* $NetBSD: xenbus_dev.c,v 1.14 2017/03/27 18:39:55 bouyer Exp $ */ +/* $NetBSD: xenbus_dev.c,v 1.15 2020/04/07 08:14:43 jdolecek Exp $ */ /* * xenbus_dev.c * @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenbus_dev.c,v 1.14 2017/03/27 18:39:55 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenbus_dev.c,v 1.15 2020/04/07 08:14:43 jdolecek Exp $"); #include "opt_xen.h" @@ -84,14 +84,14 @@ xenbus_kernfs_init(void) kfstype kfst; kfst = KERNFS_ALLOCTYPE(xenbus_fileops); - KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK); + KERNFS_ALLOCENTRY(dkt, KM_SLEEP); KERNFS_INITENTRY(dkt, DT_REG, "xenbus", NULL, kfst, VREG, PRIVCMD_MODE); kernfs_addentry(kernxen_pkt, dkt); if (xendomain_is_dom0()) { kfst = KERNFS_ALLOCTYPE(xsd_port_fileops); - KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK); + KERNFS_ALLOCENTRY(dkt, KM_SLEEP); KERNFS_INITENTRY(dkt, DT_REG, "xsd_port", NULL, kfst, VREG, XSD_MODE); kernfs_addentry(kernxen_pkt, dkt); diff --git a/sys/miscfs/kernfs/kernfs.h b/sys/miscfs/kernfs/kernfs.h index 729333d98bd6..ebcb717e6949 100644 --- a/sys/miscfs/kernfs/kernfs.h +++ b/sys/miscfs/kernfs/kernfs.h @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs.h,v 1.43 2020/02/04 04:19:24 riastradh Exp $ */ +/* $NetBSD: kernfs.h,v 1.44 2020/04/07 08:14:42 jdolecek Exp $ */ /* * Copyright (c) 1992, 1993 @@ -169,9 +169,9 @@ typedef struct dyn_kern_target kernfs_entry_t; kfstype kernfs_alloctype(int, const struct kernfs_fileop *); #define KERNFS_ALLOCTYPE(kf) kernfs_alloctype(sizeof((kf)) / \ sizeof((kf)[0]), (kf)) -#define KERNFS_ALLOCENTRY(dkt, m_type, m_flags) \ - dkt = (struct dyn_kern_target *)malloc( \ - sizeof(struct dyn_kern_target), (m_type), (m_flags)) +#define KERNFS_ALLOCENTRY(dkt, km_flags) \ + dkt = (kernfs_entry_t *)kmem_zalloc( \ + sizeof(struct dyn_kern_target), (km_flags)) #define KERNFS_INITENTRY(dkt, type, name, data, tag, vtype, mode) do { \ (dkt)->dkt_kt.kt_type = (type); \ (dkt)->dkt_kt.kt_namlen = strlen((name)); \