diff options
| author | otto <> | 2023-05-10 07:58:06 +0000 | 
|---|---|---|
| committer | otto <> | 2023-05-10 07:58:06 +0000 | 
| commit | 2571fa44f98869d5490b1fc30fb1ed5868093cdb (patch) | |
| tree | 0a07aa503d5da080782cc75f8016e831cbb37b47 /src/lib/libc/stdlib/malloc.c | |
| parent | 6e7c77af78e6fdcf852347ebed6370240e6fa7aa (diff) | |
| download | openbsd-2571fa44f98869d5490b1fc30fb1ed5868093cdb.tar.gz openbsd-2571fa44f98869d5490b1fc30fb1ed5868093cdb.tar.bz2 openbsd-2571fa44f98869d5490b1fc30fb1ed5868093cdb.zip | |
As mmap(2) is no longer a LOCK syscall, do away with the extra
unlock-lock dance it serves no real purpose any more. Confirmed
by a small performance increase in tests.  ok @tb
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.c | 24 | 
1 files changed, 1 insertions, 23 deletions
| diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 5cd7ff876a..a6728b2606 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: malloc.c,v 1.282 2023/04/21 06:19:40 jsg Exp $ */ | 1 | /* $OpenBSD: malloc.c,v 1.283 2023/05/10 07:58:06 otto Exp $ */ | 
| 2 | /* | 2 | /* | 
| 3 | * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net> | 3 | * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net> | 
| 4 | * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> | 4 | * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> | 
| @@ -264,24 +264,6 @@ static void malloc_exit(void); | |||
| 264 | (sz) = (uintptr_t)(r)->p & MALLOC_PAGEMASK, \ | 264 | (sz) = (uintptr_t)(r)->p & MALLOC_PAGEMASK, \ | 
| 265 | (sz) = ((sz) == 0 ? (r)->size : B2SIZE((sz) - 1)) | 265 | (sz) = ((sz) == 0 ? (r)->size : B2SIZE((sz) - 1)) | 
| 266 | 266 | ||
| 267 | static inline void | ||
| 268 | _MALLOC_LEAVE(struct dir_info *d) | ||
| 269 | { | ||
| 270 | if (d->malloc_mt) { | ||
| 271 | d->active--; | ||
| 272 | _MALLOC_UNLOCK(d->mutex); | ||
| 273 | } | ||
| 274 | } | ||
| 275 | |||
| 276 | static inline void | ||
| 277 | _MALLOC_ENTER(struct dir_info *d) | ||
| 278 | { | ||
| 279 | if (d->malloc_mt) { | ||
| 280 | _MALLOC_LOCK(d->mutex); | ||
| 281 | d->active++; | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 | static inline size_t | 267 | static inline size_t | 
| 286 | hash(void *p) | 268 | hash(void *p) | 
| 287 | { | 269 | { | 
| @@ -879,9 +861,7 @@ map(struct dir_info *d, size_t sz, int zero_fill) | |||
| 879 | return p; | 861 | return p; | 
| 880 | } | 862 | } | 
| 881 | if (psz <= 1) { | 863 | if (psz <= 1) { | 
| 882 | _MALLOC_LEAVE(d); | ||
| 883 | p = MMAP(cache->max * sz, d->mmap_flag); | 864 | p = MMAP(cache->max * sz, d->mmap_flag); | 
| 884 | _MALLOC_ENTER(d); | ||
| 885 | if (p != MAP_FAILED) { | 865 | if (p != MAP_FAILED) { | 
| 886 | STATS_ADD(d->malloc_used, cache->max * sz); | 866 | STATS_ADD(d->malloc_used, cache->max * sz); | 
| 887 | cache->length = cache->max - 1; | 867 | cache->length = cache->max - 1; | 
| @@ -901,9 +881,7 @@ map(struct dir_info *d, size_t sz, int zero_fill) | |||
| 901 | } | 881 | } | 
| 902 | 882 | ||
| 903 | } | 883 | } | 
| 904 | _MALLOC_LEAVE(d); | ||
| 905 | p = MMAP(sz, d->mmap_flag); | 884 | p = MMAP(sz, d->mmap_flag); | 
| 906 | _MALLOC_ENTER(d); | ||
| 907 | if (p != MAP_FAILED) | 885 | if (p != MAP_FAILED) | 
| 908 | STATS_ADD(d->malloc_used, sz); | 886 | STATS_ADD(d->malloc_used, sz); | 
| 909 | /* zero fill not needed */ | 887 | /* zero fill not needed */ | 
