aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-11-12 20:22:58 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-11-12 20:22:58 +0000
commit9aa6d792b54934b896e3b4a1c21a2cfaa5f88e9d (patch)
treefd849a16d0c89d8cb325d99641a18853eecdc23f
parentd5127d1ae2e13b1d91c0d7f932e7b8753c02852e (diff)
malloc: retire malloc_last_fail
The routine does not serve any practical purpose. Memory can be allocated in many other ways and most consumers pass the M_WAITOK flag, making malloc not fail in the first place. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D27143
Notes
Notes: svn path=/head/; revision=367627
-rw-r--r--sys/kern/kern_malloc.c17
-rw-r--r--sys/sys/malloc.h1
-rw-r--r--sys/sys/param.h2
3 files changed, 1 insertions, 19 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 26ba66577888..57d46b884a0b 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -231,11 +231,6 @@ static int sysctl_kern_mprof(SYSCTL_HANDLER_ARGS);
static int sysctl_kern_malloc_stats(SYSCTL_HANDLER_ARGS);
-/*
- * time_uptime of the last malloc(9) failure (induced or real).
- */
-static time_t t_malloc_fail;
-
#if defined(MALLOC_MAKE_FAILURES) || (MALLOC_DEBUG_MAXZONES > 1)
static SYSCTL_NODE(_debug, OID_AUTO, malloc, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"Kernel malloc debugging options");
@@ -373,13 +368,6 @@ mtp_get_subzone(struct malloc_type *mtp)
}
#endif /* MALLOC_DEBUG_MAXZONES > 1 */
-int
-malloc_last_fail(void)
-{
-
- return (time_uptime - t_malloc_fail);
-}
-
/*
* An allocation has succeeded -- update malloc type statistics for the
* amount of bucket size. Occurs within a critical section so that the
@@ -535,7 +523,6 @@ malloc_dbg(caddr_t *vap, size_t *sizep, struct malloc_type *mtp,
atomic_add_int(&malloc_nowait_count, 1);
if ((malloc_nowait_count % malloc_failure_rate) == 0) {
atomic_add_int(&malloc_failure_count, 1);
- t_malloc_fail = time_uptime;
*vap = NULL;
return (EJUSTRETURN);
}
@@ -662,7 +649,6 @@ void *
if (__predict_false(va == NULL)) {
KASSERT((flags & M_WAITOK) == 0,
("malloc(M_WAITOK) returned NULL"));
- t_malloc_fail = time_uptime;
}
#ifdef DEBUG_REDZONE
if (va != NULL)
@@ -730,7 +716,6 @@ malloc_domainset(size_t size, struct malloc_type *mtp, struct domainset *ds,
if (__predict_false(va == NULL)) {
KASSERT((flags & M_WAITOK) == 0,
("malloc(M_WAITOK) returned NULL"));
- t_malloc_fail = time_uptime;
}
#ifdef DEBUG_REDZONE
if (va != NULL)
@@ -761,7 +746,6 @@ malloc_exec(size_t size, struct malloc_type *mtp, int flags)
if (__predict_false(va == NULL)) {
KASSERT((flags & M_WAITOK) == 0,
("malloc(M_WAITOK) returned NULL"));
- t_malloc_fail = time_uptime;
}
#ifdef DEBUG_REDZONE
if (va != NULL)
@@ -791,7 +775,6 @@ malloc_domainset_exec(size_t size, struct malloc_type *mtp, struct domainset *ds
if (__predict_false(va == NULL)) {
KASSERT((flags & M_WAITOK) == 0,
("malloc(M_WAITOK) returned NULL"));
- t_malloc_fail = time_uptime;
}
#ifdef DEBUG_REDZONE
if (va != NULL)
diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h
index 5b2e6e125018..a00e73fc7672 100644
--- a/sys/sys/malloc.h
+++ b/sys/sys/malloc.h
@@ -252,7 +252,6 @@ void *malloc_domainset_exec(size_t size, struct malloc_type *type,
struct domainset *ds, int flags) __malloc_like __result_use_check
__alloc_size(1);
void malloc_init(void *);
-int malloc_last_fail(void);
void malloc_type_allocated(struct malloc_type *type, unsigned long size);
void malloc_type_freed(struct malloc_type *type, unsigned long size);
void malloc_type_list(malloc_type_list_func_t *, void *);
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 307e5f77ec62..e0a9adb5cc78 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -60,7 +60,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1300128 /* Master, propagated to newvers */
+#define __FreeBSD_version 1300129 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,