Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/kernfs switch to kmem_zalloc() instead of malloc(...



details:   https://anonhg.NetBSD.org/src/rev/43748290e349
branches:  trunk
changeset: 1008964:43748290e349
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue Apr 07 08:35:49 2020 +0000

description:
switch to kmem_zalloc() instead of malloc() for struct kernfs_mount

diffstat:

 sys/miscfs/kernfs/kernfs_vfsops.c |  15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diffs (78 lines):

diff -r 38b7cb2c7540 -r 43748290e349 sys/miscfs/kernfs/kernfs_vfsops.c
--- a/sys/miscfs/kernfs/kernfs_vfsops.c Tue Apr 07 08:14:42 2020 +0000
+++ b/sys/miscfs/kernfs/kernfs_vfsops.c Tue Apr 07 08:35:49 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kernfs_vfsops.c,v 1.99 2020/03/16 21:20:11 pgoyette Exp $      */
+/*     $NetBSD: kernfs_vfsops.c,v 1.100 2020/04/07 08:35:49 jdolecek Exp $     */
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.99 2020/03/16 21:20:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.100 2020/04/07 08:35:49 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -54,7 +54,6 @@
 #include <sys/mount.h>
 #include <sys/namei.h>
 #include <sys/dirent.h>
-#include <sys/malloc.h>
 #include <sys/syslog.h>
 #include <sys/kauth.h>
 #include <sys/module.h>
@@ -65,8 +64,6 @@
 
 MODULE(MODULE_CLASS_VFS, kernfs, NULL);
 
-MALLOC_JUSTDEFINE(M_KERNFSMNT, "kernfs mount", "kernfs mount structures");
-
 dev_t rrootdev = NODEV;
 kmutex_t kfs_lock;
 
@@ -78,7 +75,6 @@
 kernfs_init(void)
 {
 
-       malloc_type_attach(M_KERNFSMNT);
        mutex_init(&kfs_lock, MUTEX_DEFAULT, IPL_NONE);
 }
 
@@ -93,7 +89,6 @@
 {
 
        mutex_destroy(&kfs_lock);
-       malloc_type_detach(M_KERNFSMNT);
 }
 
 void
@@ -141,7 +136,7 @@
        if (mp->mnt_flag & MNT_UPDATE)
                return (EOPNOTSUPP);
 
-       fmp = malloc(sizeof(struct kernfs_mount), M_KERNFSMNT, M_WAITOK|M_ZERO);
+       fmp = kmem_zalloc(sizeof(struct kernfs_mount), KM_SLEEP);
        TAILQ_INIT(&fmp->nodelist);
 
        mp->mnt_stat.f_namemax = KERNFS_MAXNAMLEN;
@@ -151,7 +146,7 @@
 
        if ((error = set_statvfs_info(path, UIO_USERSPACE, "kernfs",
            UIO_SYSSPACE, mp->mnt_op->vfs_name, mp, l)) != 0) {
-               free(fmp, M_KERNFSMNT);
+               kmem_free(fmp, sizeof(struct kernfs_mount));
                return error;
        }
 
@@ -181,7 +176,7 @@
        /*
         * Finally, throw away the kernfs_mount structure
         */
-       free(mp->mnt_data, M_KERNFSMNT);
+       kmem_free(mp->mnt_data, sizeof(struct kernfs_mount));
        mp->mnt_data = NULL;
        return (0);
 }



Home | Main Index | Thread Index | Old Index