diff options
author | Bryan Cantrill <bryan@joyent.com> | 2015-07-31 07:14:02 +0000 |
---|---|---|
committer | Bryan Cantrill <bryan@joyent.com> | 2015-07-31 07:14:02 +0000 |
commit | 92d00144d1e2f01ebc15a0099c0a06a8210c7ccb (patch) | |
tree | 99837be542368a26d9213697d282544783534a52 /usr/src/uts | |
parent | 3ba00567d296bc2c7c16b9fe6cb2976af0ec2c0b (diff) | |
download | illumos-joyent-92d00144d1e2f01ebc15a0099c0a06a8210c7ccb.tar.gz |
OS-4297 zero-sized allocations should be logged but not warned about
Diffstat (limited to 'usr/src/uts')
-rw-r--r-- | usr/src/uts/common/os/kmem.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/usr/src/uts/common/os/kmem.c b/usr/src/uts/common/os/kmem.c index 37d28c42de..8872a02327 100644 --- a/usr/src/uts/common/os/kmem.c +++ b/usr/src/uts/common/os/kmem.c @@ -998,20 +998,22 @@ size_t kmem_transaction_log_size; /* transaction log size [2% of memory] */ size_t kmem_content_log_size; /* content log size [2% of memory] */ size_t kmem_failure_log_size; /* failure log [4 pages per CPU] */ size_t kmem_slab_log_size; /* slab create log [4 pages per CPU] */ +size_t kmem_zerosized_log_size; /* zero-sized log [4 pages per CPU] */ size_t kmem_content_maxsave = 256; /* KMF_CONTENTS max bytes to log */ size_t kmem_lite_minsize = 0; /* minimum buffer size for KMF_LITE */ size_t kmem_lite_maxalign = 1024; /* maximum buffer alignment for KMF_LITE */ int kmem_lite_pcs = 4; /* number of PCs to store in KMF_LITE mode */ size_t kmem_maxverify; /* maximum bytes to inspect in debug routines */ size_t kmem_minfirewall; /* hardware-enforced redzone threshold */ -int kmem_warn_zerosized = 1; /* whether to warn on zero-sized KM_SLEEP */ #ifdef DEBUG -int kmem_panic_zerosized = 1; /* whether to panic on zero-sized KM_SLEEP */ +int kmem_warn_zerosized = 1; /* whether to warn on zero-sized KM_SLEEP */ #else -int kmem_panic_zerosized = 0; /* whether to panic on zero-sized KM_SLEEP */ +int kmem_warn_zerosized = 0; /* whether to warn on zero-sized KM_SLEEP */ #endif +int kmem_panic_zerosized = 0; /* whether to panic on zero-sized KM_SLEEP */ + #ifdef _LP64 size_t kmem_max_cached = KMEM_BIG_MAXBUF; /* maximum kmem_alloc cache */ #else @@ -1151,6 +1153,7 @@ kmem_log_header_t *kmem_transaction_log; kmem_log_header_t *kmem_content_log; kmem_log_header_t *kmem_failure_log; kmem_log_header_t *kmem_slab_log; +kmem_log_header_t *kmem_zerosized_log; static int kmem_lite_count; /* # of PCs in kmem_buftag_lite_t */ @@ -2961,18 +2964,20 @@ kmem_alloc(size_t size, int kmflag) * consider it to be deprecated behavior to allocate * 0 bytes. If we have been configured to panic under * this condition, we panic; if to warn, we warn -- and - * regardless, we bump a counter to at least indicate - * that this condition has occurred. + * regardless, we log to the kmem_zerosized_log that + * that this condition has occurred (which gives us + * enough information to be able to debug it). */ if (kmem_panic && kmem_panic_zerosized) panic("attempted to kmem_alloc() size of 0"); if (kmem_warn_zerosized) { cmn_err(CE_WARN, "kmem_alloc(): sleeping " - "allocation with size of 0"); + "allocation with size of 0; " + "see kmem_zerosized_log for details"); } - kmem_zerosized++; + kmem_log_event(kmem_zerosized_log, NULL, NULL, NULL); return (NULL); } @@ -4499,8 +4504,8 @@ kmem_init(void) } kmem_failure_log = kmem_log_init(kmem_failure_log_size); - kmem_slab_log = kmem_log_init(kmem_slab_log_size); + kmem_zerosized_log = kmem_log_init(kmem_zerosized_log_size); /* * Initialize STREAMS message caches so allocb() is available. |