Removed support for generating inline code for MALLOC() and FREE()
in the dysfunctional !KMEMSTATS case. This hasn't compiled since rev.1.31 of kern_malloc.c quietly removed the core of the support for the !KMEMSTATS case. I fixed it to see if it was worth saving and found that (as usual) inlining just wasted space and increased complexity without significantly affecting time, at least for the lmbench2 micro-benchmark on a Celeron. The space bloat was surprisingly large - the text size increased from 1700K to 1840K for a version with the entire malloc() family inlined. Removed even older garbage (kmemxtob() and btokmemx() macros). Attempt to deprecate MALLOC() and FREE(). Given current compilers (gcc-2.x or C99), they don't do anything that (safe) function-like macros or inline functions named malloc() and free() couldn't do. Fixed missing casts of macro args in MALLOC() and FREE().
This commit is contained in:
parent
7652512976
commit
979ab75162
@ -39,8 +39,6 @@
|
||||
|
||||
#define splmem splhigh
|
||||
|
||||
#define KMEMSTATS
|
||||
|
||||
/*
|
||||
* flags to malloc.
|
||||
*/
|
||||
@ -147,55 +145,16 @@ struct kmembuckets {
|
||||
: (MINBUCKET + 15))
|
||||
|
||||
/*
|
||||
* Turn virtual addresses into kmem map indices
|
||||
* Turn virtual addresses into kmemusage pointers.
|
||||
*/
|
||||
#define kmemxtob(alloc) (kmembase + (alloc) * PAGE_SIZE)
|
||||
#define btokmemx(addr) (((caddr_t)(addr) - kmembase) / PAGE_SIZE)
|
||||
#define btokup(addr) (&kmemusage[((caddr_t)(addr) - kmembase) >> PAGE_SHIFT])
|
||||
|
||||
/*
|
||||
* Macro versions for the usual cases of malloc/free
|
||||
* Deprecated macro versions of not-quite-malloc() and free().
|
||||
*/
|
||||
#if defined(KMEMSTATS) || defined(DIAGNOSTIC)
|
||||
#define MALLOC(space, cast, size, type, flags) \
|
||||
(space) = (cast)malloc((u_long)(size), type, flags)
|
||||
#define FREE(addr, type) free((addr), type)
|
||||
|
||||
#else /* do not collect statistics */
|
||||
#define MALLOC(space, cast, size, type, flags) do { \
|
||||
register struct kmembuckets *kbp = &bucket[BUCKETINDX(size)]; \
|
||||
long s = splmem(); \
|
||||
if (kbp->kb_next == NULL) { \
|
||||
(space) = (cast)malloc((u_long)(size), type, flags); \
|
||||
} else { \
|
||||
(space) = (cast)kbp->kb_next; \
|
||||
kbp->kb_next = *(caddr_t *)(space); \
|
||||
} \
|
||||
splx(s); \
|
||||
} while (0)
|
||||
|
||||
#define FREE(addr, type) do { \
|
||||
register struct kmembuckets *kbp; \
|
||||
register struct kmemusage *kup = btokup(addr); \
|
||||
long s = splmem(); \
|
||||
if (1 << kup->ku_indx > MAXALLOCSAVE) { \
|
||||
free((addr), type); \
|
||||
} else { \
|
||||
kbp = &bucket[kup->ku_indx]; \
|
||||
if (kbp->kb_next == NULL) \
|
||||
kbp->kb_next = (caddr_t)(addr); \
|
||||
else \
|
||||
*(caddr_t *)(kbp->kb_last) = (caddr_t)(addr); \
|
||||
*(caddr_t *)(addr) = NULL; \
|
||||
kbp->kb_last = (caddr_t)(addr); \
|
||||
} \
|
||||
splx(s); \
|
||||
} while (0)
|
||||
|
||||
extern struct kmemusage *kmemusage;
|
||||
extern char *kmembase;
|
||||
extern struct kmembuckets bucket[];
|
||||
#endif /* do not collect statistics */
|
||||
(space) = (cast)malloc((u_long)(size), (type), (flags))
|
||||
#define FREE(addr, type) free((addr), (type))
|
||||
|
||||
/*
|
||||
* XXX this should be declared in <sys/uio.h>, but that tends to fail
|
||||
|
Loading…
Reference in New Issue
Block a user