Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys/kern Rather than allocating and freeing the re...



details:   https://anonhg.NetBSD.org/src/rev/4729c40d5b61
branches:  pgoyette-compat
changeset: 321137:4729c40d5b61
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat Mar 31 08:34:17 2018 +0000

description:
Rather than allocating and freeing the recursion stack entry from the pool,
just use an entry allocated on the procedure's stack.  The recursion entry
is very short-lived anyway, and always gets freed before the procedure
exits.

diffstat:

 sys/kern/kern_module.c |  18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)

diffs (91 lines):

diff -r f275a72e81aa -r 4729c40d5b61 sys/kern/kern_module.c
--- a/sys/kern/kern_module.c    Sat Mar 31 01:20:44 2018 +0000
+++ b/sys/kern/kern_module.c    Sat Mar 31 08:34:17 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_module.c,v 1.130.2.5 2018/03/30 23:49:42 pgoyette Exp $   */
+/*     $NetBSD: kern_module.c,v 1.130.2.6 2018/03/31 08:34:17 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.5 2018/03/30 23:49:42 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.6 2018/03/31 08:34:17 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -913,7 +913,7 @@
        struct pend_entry {
                SLIST_ENTRY(pend_entry) pe_entry;
                struct pending_t *pe_pending;
-       } *my_pend_entry;
+       } my_pend_entry;
 
        modinfo_t *mi;
        module_t *mod, *mod2, *prev_active;
@@ -942,9 +942,8 @@
                pending = SLIST_FIRST(&pend_stack)->pe_pending;
        } else
                pending = &new_pending;
-       my_pend_entry = kmem_zalloc(sizeof(*my_pend_entry), KM_SLEEP);
-       my_pend_entry->pe_pending = pending;
-       SLIST_INSERT_HEAD(&pend_stack, my_pend_entry, pe_entry);
+       my_pend_entry.pe_pending = pending;
+       SLIST_INSERT_HEAD(&pend_stack, &my_pend_entry, pe_entry);
 
        /*
         * Search the list of disabled builtins first.
@@ -962,11 +961,9 @@
                                    "builtin module `%s'", name);
                        }
                        SLIST_REMOVE_HEAD(&pend_stack, pe_entry);
-                       kmem_free(my_pend_entry, sizeof(*my_pend_entry));
                        return EPERM;
                } else {
                        SLIST_REMOVE_HEAD(&pend_stack, pe_entry);
-                       kmem_free(my_pend_entry, sizeof(*my_pend_entry));
                        error = module_do_builtin(mod, name, modp, props);
                        return error;
                }
@@ -996,7 +993,6 @@
                        module_print("%s module `%s' already loaded",
                            isdep ? "dependent" : "requested", name);
                        SLIST_REMOVE_HEAD(&pend_stack, pe_entry);
-                       kmem_free(my_pend_entry, sizeof(*my_pend_entry));
                        return EEXIST;
                }
 
@@ -1004,7 +1000,6 @@
                if (mod == NULL) {
                        module_error("out of memory for `%s'", name);
                        SLIST_REMOVE_HEAD(&pend_stack, pe_entry);
-                       kmem_free(my_pend_entry, sizeof(*my_pend_entry));
                        return ENOMEM;
                }
 
@@ -1025,7 +1020,6 @@
 #endif
                        kmem_free(mod, sizeof(*mod));
                        SLIST_REMOVE_HEAD(&pend_stack, pe_entry);
-                       kmem_free(my_pend_entry, sizeof(*my_pend_entry));
                        return error;
                }
                TAILQ_INSERT_TAIL(pending, mod, mod_chain);
@@ -1241,7 +1235,6 @@
                module_thread_kick();
        }
        SLIST_REMOVE_HEAD(&pend_stack, pe_entry);
-       kmem_free(my_pend_entry, sizeof(*my_pend_entry));
        module_print("module `%s' loaded successfully", mi->mi_name);
        return 0;
 
@@ -1257,7 +1250,6 @@
        TAILQ_REMOVE(pending, mod, mod_chain);
        kmem_free(mod, sizeof(*mod));
        SLIST_REMOVE_HEAD(&pend_stack, pe_entry);
-       kmem_free(my_pend_entry, sizeof(*my_pend_entry));
        return error;
 }
 



Home | Main Index | Thread Index | Old Index