| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_malloc_debug.c,v 1.24 2011/01/17 07:13:31 uebayasi Exp $ */ | | 1 | /* $NetBSD: kern_malloc_debug.c,v 1.25 2011/01/19 09:02:52 cegger Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1999, 2000 Artur Grabowski <art@openbsd.org> | | 4 | * Copyright (c) 1999, 2000 Artur Grabowski <art@openbsd.org> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * | | 10 | * |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -46,36 +46,36 @@ | | | @@ -46,36 +46,36 @@ |
46 | * Every free() changes the protection of the first page to VM_PROT_NONE so | | 46 | * Every free() changes the protection of the first page to VM_PROT_NONE so |
47 | * that we can catch any dangling writes to it. | | 47 | * that we can catch any dangling writes to it. |
48 | * To minimize the risk of writes to recycled chunks we keep an LRU of latest | | 48 | * To minimize the risk of writes to recycled chunks we keep an LRU of latest |
49 | * freed chunks. The length of it is controlled by MALLOC_DEBUG_CHUNKS. | | 49 | * freed chunks. The length of it is controlled by MALLOC_DEBUG_CHUNKS. |
50 | * | | 50 | * |
51 | * Don't expect any performance. | | 51 | * Don't expect any performance. |
52 | * | | 52 | * |
53 | * TODO: | | 53 | * TODO: |
54 | * - support for size >= PAGE_SIZE | | 54 | * - support for size >= PAGE_SIZE |
55 | * - add support to the fault handler to give better diagnostics if we fail. | | 55 | * - add support to the fault handler to give better diagnostics if we fail. |
56 | */ | | 56 | */ |
57 | | | 57 | |
58 | #include <sys/cdefs.h> | | 58 | #include <sys/cdefs.h> |
59 | __KERNEL_RCSID(0, "$NetBSD: kern_malloc_debug.c,v 1.24 2011/01/17 07:13:31 uebayasi Exp $"); | | 59 | __KERNEL_RCSID(0, "$NetBSD: kern_malloc_debug.c,v 1.25 2011/01/19 09:02:52 cegger Exp $"); |
60 | | | 60 | |
61 | #include <sys/param.h> | | 61 | #include <sys/param.h> |
62 | #include <sys/proc.h> | | 62 | #include <sys/proc.h> |
63 | #include <sys/kernel.h> | | 63 | #include <sys/kernel.h> |
64 | #include <sys/malloc.h> | | 64 | #include <sys/malloc.h> |
65 | #include <sys/systm.h> | | 65 | #include <sys/systm.h> |
66 | #include <sys/pool.h> | | 66 | #include <sys/pool.h> |
67 | | | 67 | |
68 | #include <uvm/uvm_extern.h> | | 68 | #include <uvm/uvm.h> |
69 | | | 69 | |
70 | /* | | 70 | /* |
71 | * debug_malloc_type and debug_malloc_size define the type and size of | | 71 | * debug_malloc_type and debug_malloc_size define the type and size of |
72 | * memory to be debugged. Use 0 for a wildcard. debug_malloc_size_lo | | 72 | * memory to be debugged. Use 0 for a wildcard. debug_malloc_size_lo |
73 | * is the lower limit and debug_malloc_size_hi the upper limit of sizes | | 73 | * is the lower limit and debug_malloc_size_hi the upper limit of sizes |
74 | * being debugged; 0 will not work as a wildcard for the upper limit. | | 74 | * being debugged; 0 will not work as a wildcard for the upper limit. |
75 | * For any debugging to take place, type must be != NULL, size must be >= 0, | | 75 | * For any debugging to take place, type must be != NULL, size must be >= 0, |
76 | * and if the limits are being used, size must be set to 0. | | 76 | * and if the limits are being used, size must be set to 0. |
77 | * See /usr/src/sys/sys/malloc.h and malloc(9) for a list of types. | | 77 | * See /usr/src/sys/sys/malloc.h and malloc(9) for a list of types. |
78 | * | | 78 | * |
79 | * Although those are variables, it's a really bad idea to change the type | | 79 | * Although those are variables, it's a really bad idea to change the type |
80 | * if any memory chunks of this type are used. It's ok to change the size | | 80 | * if any memory chunks of this type are used. It's ok to change the size |
81 | * in runtime. | | 81 | * in runtime. |