switch KERNFS_ALLOCENTRY() to use kmem_zalloc() instead of malloc()

This commit is contained in:
jdolecek 2020-04-07 08:14:42 +00:00
parent a6a8f0073d
commit 8a3ee72648
5 changed files with 19 additions and 21 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>
#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);

View File

@ -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 <sys/cdefs.h>
__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);

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
#include <sys/vnode.h>
#include <sys/malloc.h>
#include <sys/dirent.h>
#include <sys/stat.h>
#include <sys/proc.h>
@ -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);

View File

@ -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 <sys/cdefs.h>
__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);

View File

@ -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)); \