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 <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2015-11-16 14:45:42 -08:00
parent 31f24932a4
commit e7b75d9b46

View File

@ -590,6 +590,9 @@ splat_kmem_cache_test(struct file *file, void *arg, char *name,
kmem_cache_data_t **kcd = NULL; kmem_cache_data_t **kcd = NULL;
int i, rc = 0, objs = 0; 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, splat_vprint(file, name,
"Testing size=%d, align=%d, flags=0x%04x\n", "Testing size=%d, align=%d, flags=0x%04x\n",
size, align, flags); 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. * it to a single slab for the purposes of this test.
*/ */
#ifdef _LP64 #ifdef _LP64
objs = SPL_KMEM_CACHE_OBJ_PER_SLAB * 4; objs = kcp->kcp_cache->skc_slab_objs * 4;
#else #else
objs = 1; objs = 1;
#endif #endif