Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern __predict_false() the check for bogus malloc type, ...
details: https://anonhg.NetBSD.org/src/rev/5d588cd83e4e
branches: trunk
changeset: 485920:5d588cd83e4e
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon May 08 20:02:21 2000 +0000
description:
__predict_false() the check for bogus malloc type, running out of space
in kmem_map, and the DIAGNOSTIC error checks.
diffstat:
sys/kern/kern_malloc.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diffs (75 lines):
diff -r d260f5bb30a6 -r 5d588cd83e4e sys/kern/kern_malloc.c
--- a/sys/kern/kern_malloc.c Mon May 08 20:01:05 2000 +0000
+++ b/sys/kern/kern_malloc.c Mon May 08 20:02:21 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_malloc.c,v 1.50 2000/03/30 09:27:11 augustss Exp $ */
+/* $NetBSD: kern_malloc.c,v 1.51 2000/05/08 20:02:21 thorpej Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -227,7 +227,7 @@
#ifdef KMEMSTATS
struct kmemstats *ksp = &kmemstats[type];
- if (((unsigned long)type) > M_LAST)
+ if (__predict_false(((unsigned long)type) > M_LAST))
panic("malloc - bogus type");
#endif
indx = BUCKETINDX(size);
@@ -258,7 +258,7 @@
va = (caddr_t) uvm_km_kmemalloc(kmem_map, uvmexp.kmem_object,
(vsize_t)ctob(npg),
(flags & M_NOWAIT) ? UVM_KMF_NOWAIT : 0);
- if (va == NULL) {
+ if (__predict_false(va == NULL)) {
/*
* Kmem_malloc() can return NULL, even if it can
* wait, if there is no map space avaiable, because
@@ -334,8 +334,7 @@
VM_PROT_WRITE);
vm_map_unlock(kmem_map);
- if (!rv)
- {
+ if (__predict_false(rv == 0)) {
printf(
"%s %ld of object %p size %ld %s %s (invalid addr %p)\n",
"Data modified on freelist: word",
@@ -363,7 +362,7 @@
/* and check that the data hasn't been modified. */
end = (int32_t *)&va[copysize];
for (lp = (int32_t *)va; lp < end; lp++) {
- if (*lp == WEIRD_ADDR)
+ if (__predict_true(*lp == WEIRD_ADDR))
continue;
printf("%s %ld of object %p size %ld %s %s (0x%x != 0x%x)\n",
"Data modified on freelist: word",
@@ -439,8 +438,8 @@
* have allocated in the first place. That is, check
* to see that the address is within kmem_map.
*/
- if ((vaddr_t)addr < kmem_map->header.start ||
- (vaddr_t)addr >= kmem_map->header.end)
+ if (__predict_false((vaddr_t)addr < kmem_map->header.start ||
+ (vaddr_t)addr >= kmem_map->header.end))
panic("free: addr %p not within kmem_map", addr);
#endif
@@ -486,7 +485,7 @@
* Check for multiple frees. Use a quick check to see if
* it looks free before laboriously searching the freelist.
*/
- if (freep->spare0 == WEIRD_ADDR) {
+ if (__predict_false(freep->spare0 == WEIRD_ADDR)) {
for (cp = kbp->kb_next; cp;
cp = ((struct freelist *)cp)->next) {
if (addr != cp)
@@ -605,7 +604,7 @@
* Allocate a new one and copy the data.
*/
newaddr = malloc(newsize, type, flags);
- if (newaddr == NULL) {
+ if (__predict_false(newaddr == NULL)) {
/*
* Malloc() failed, because flags included M_NOWAIT.
* Return NULL to indicate that failure. The old
Home |
Main Index |
Thread Index |
Old Index