From e7b75d9b46fcfea149bf7fd1f53d40379e3c7b5d Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 16 Nov 2015 14:45:42 -0800 Subject: [PATCH] Limit maximum object size in kmem tests Limit the maximum object size to 1/128 of total system memory for the kmem cache tests. Large values can result in out of memory errors for systems with less the 512M of memory. Additionally, use the known number of objects per-slab for calculating the number of objects to use for a test. Signed-off-by: Brian Behlendorf --- module/splat/splat-kmem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/splat/splat-kmem.c b/module/splat/splat-kmem.c index b3fd1a84d..288112278 100644 --- a/module/splat/splat-kmem.c +++ b/module/splat/splat-kmem.c @@ -590,6 +590,9 @@ splat_kmem_cache_test(struct file *file, void *arg, char *name, kmem_cache_data_t **kcd = NULL; int i, rc = 0, objs = 0; + /* Limit size for low memory machines (1/128 of memory) */ + size = MIN(size, (physmem * PAGE_SIZE) >> 7); + splat_vprint(file, name, "Testing size=%d, align=%d, flags=0x%04x\n", size, align, flags); @@ -619,7 +622,7 @@ splat_kmem_cache_test(struct file *file, void *arg, char *name, * it to a single slab for the purposes of this test. */ #ifdef _LP64 - objs = SPL_KMEM_CACHE_OBJ_PER_SLAB * 4; + objs = kcp->kcp_cache->skc_slab_objs * 4; #else objs = 1; #endif