dlg@ removed MALLOC_DEBUG about two weeks ago but malloc(9) still
has it, I see no point in documenting absent features so let's remove 
those bits until reimplemented.

I stripped another usage in ddb(4) but left the remaining two users in
tree unchanged as they haven't been touched since their initial import:

        gnu/usr.bin/gcc/gcc/f/malloc.{c,h}
        regress/usr.bin/diff/t8.2 

Feedback?

 share/man/man9/malloc.9 | 66 -------------------------------------------------
 sys/ddb/db_command.c    |  9 -------
 sys/sys/malloc.h        | 15 ++---------
 3 files changed, 2 insertions(+), 88 deletions(-)

diff --git a/share/man/man9/malloc.9 b/share/man/man9/malloc.9
index 0988669d535..ba00f8bff9e 100644
--- a/share/man/man9/malloc.9
+++ b/share/man/man9/malloc.9
@@ -152,9 +152,6 @@ The following types are currently defined:
 Should be on free list.
 .It Dv M_DEVBUF
 Device driver memory.
-.It Dv M_DEBUG
-.Nm malloc
-debug structures.
 .It Dv M_PCB
 Protocol control blocks.
 .It Dv M_RTABLE
@@ -395,69 +392,6 @@ panic:
 .It
 .Dq Data modified on freelist: Aq data object description
 .El
-.Sh DEBUGGING
-A kernel compiled with the
-.Cm MALLOC_DEBUG
-option allows for more extensive debugging of memory allocations.
-The
-.Va debug_malloc_type ,
-.Va debug_malloc_size ,
-.Va debug_malloc_size_lo
-and
-.Va debug_malloc_size_hi
-variables choose which allocation to debug.
-.Va debug_malloc_type
-should be set to the memory type and
-.Va debug_malloc_size
-should be set to the memory size to debug.
-0 can be used as a wildcard.
-.Va debug_malloc_size_lo
-and
-.Va debug_malloc_size_hi
-can be used to specify a range of sizes if the exact size to debug is not
-known.
-When those are used,
-.Va debug_malloc_size
-needs to be set to the wildcard.
-.Dv M_DEBUG
-can also be specified as an allocation type to force allocation with
-debugging.
-.Pp
-Every call to
-.Fn malloc
-or
-.Fn mallocarray
-with a memory type and size that matches the debugged type and size will
-allocate two virtual pages.
-The pointer returned will be aligned so that
-the requested area will end at the page boundary and the second virtual page
-will be left unmapped.
-This way we can catch reads and writes outside the allocated area.
-.Pp
-Every call to
-.Fn free
-with memory that was returned by the debugging allocators will cause the memory
-area to become unmapped so that we can catch dangling reads and writes to
-freed memory.
-.Pp
-There are no special diagnostics if any errors are caught by the debugging
-malloc.
-The errors will look like normal access to unmapped memory.
-On a memory access error, the
-.Ic show malloc
-command in
-.Xr ddb 4
-can be invoked to see what memory areas are allocated and freed.
-If the faulting address is within two pages from an address on the allocated
-list, there was an access outside the allocated area.
-If the faulting address is within two pages from an address on the free list,
-there was an access to freed memory.
-.Pp
-Care needs to be taken when using the
-.Cm MALLOC_DEBUG
-option:  the memory consumption can run away pretty quickly and there is
-a severe performance degradation when allocating and freeing debugged memory
-types.
 .Sh SEE ALSO
 .Xr systat 1 ,
 .Xr vmstat 8
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index 53ab733dd0c..957bbeff456 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -352,16 +352,7 @@ db_map_print_cmd(db_expr_t addr, int have_addr, db_expr_t 
count, char *modif)
 void
 db_malloc_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char 
*modif)
 {
-#if defined(MALLOC_DEBUG)
-       extern void debug_malloc_printit(int (*)(const char *, ...), vaddr_t);
-
-       if (!have_addr)
-               addr = 0;
-
-       debug_malloc_printit(db_printf, (vaddr_t)addr);
-#else
        malloc_printit(db_printf);
-#endif
 }
 
 /*ARGSUSED*/
diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h
index 959b9addbb8..fd84b2c28c0 100644
--- a/sys/sys/malloc.h
+++ b/sys/sys/malloc.h
@@ -65,7 +65,7 @@
 #define        M_FREE          0       /* should be on free list */
 /* 1 - free */
 #define        M_DEVBUF        2       /* device driver memory */
-#define M_DEBUG                3       /* debug chunk */
+/* 3 - free */
 #define        M_PCB           4       /* protocol control block */
 #define        M_RTABLE        5       /* routing tables */
 /* 6 - free */
@@ -187,7 +187,7 @@
        "free",         /* 0 M_FREE */ \
        NULL, \
        "devbuf",       /* 2 M_DEVBUF */ \
-       "debug",        /* 3 M_DEBUG */ \
+       NULL, \
        "pcb",          /* 4 M_PCB */ \
        "rtable",       /* 5 M_RTABLE */ \
        NULL,           /* 6 */ \
@@ -403,16 +403,5 @@ void       poison_mem(void *, size_t);
 int    poison_check(void *, size_t, size_t *, uint32_t *);
 uint32_t poison_value(void *);
 
-#ifdef MALLOC_DEBUG
-int    debug_malloc(unsigned long, int, int, void **);
-int    debug_free(void *, int);
-void   debug_malloc_init(void);
-void   debug_malloc_assert_allocated(void *, const char *);
-#define DEBUG_MALLOC_ASSERT_ALLOCATED(addr)                    \
-       debug_malloc_assert_allocated(addr, __func__)
-
-void   debug_malloc_print(void);
-void   debug_malloc_printit(int (*)(const char *, ...), vaddr_t);
-#endif /* MALLOC_DEBUG */
 #endif /* _KERNEL */
 #endif /* !_SYS_MALLOC_H_ */

Reply via email to