Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Nov 2020 20:22:59 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r367627 - in head/sys: kern sys
Message-ID:  <202011122022.0ACKMxXx096165@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Thu Nov 12 20:22:58 2020
New Revision: 367627
URL: https://svnweb.freebsd.org/changeset/base/367627

Log:
  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

Modified:
  head/sys/kern/kern_malloc.c
  head/sys/sys/malloc.h
  head/sys/sys/param.h

Modified: head/sys/kern/kern_malloc.c
==============================================================================
--- head/sys/kern/kern_malloc.c	Thu Nov 12 20:20:57 2020	(r367626)
+++ head/sys/kern/kern_malloc.c	Thu Nov 12 20:22:58 2020	(r367627)
@@ -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_
 		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,
 	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 
 	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 
 	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)

Modified: head/sys/sys/malloc.h
==============================================================================
--- head/sys/sys/malloc.h	Thu Nov 12 20:20:57 2020	(r367626)
+++ head/sys/sys/malloc.h	Thu Nov 12 20:22:58 2020	(r367627)
@@ -252,7 +252,6 @@ void	*malloc_domainset_exec(size_t size, struct malloc
 	    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 *);

Modified: head/sys/sys/param.h
==============================================================================
--- head/sys/sys/param.h	Thu Nov 12 20:20:57 2020	(r367626)
+++ head/sys/sys/param.h	Thu Nov 12 20:22:58 2020	(r367627)
@@ -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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202011122022.0ACKMxXx096165>