Skip to content

Commit

Permalink
Limit maximum object size in kmem tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
behlendorf committed Nov 16, 2015
1 parent 31f2493 commit e7b75d9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion module/splat/splat-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e7b75d9

Please sign in to comment.