Skip to content

Commit 0684e65

Browse files
andy-shevtorvalds
authored andcommitted
mm/slub.c: switch to bitmap_zalloc()
Switch to bitmap_zalloc() to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Christoph Lameter <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Tested-by: David Rientjes <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: Joonsoo Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 253cc22 commit 0684e65

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

mm/slub.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,9 +3621,7 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,
36213621
#ifdef CONFIG_SLUB_DEBUG
36223622
void *addr = page_address(page);
36233623
void *p;
3624-
unsigned long *map = kcalloc(BITS_TO_LONGS(page->objects),
3625-
sizeof(long),
3626-
GFP_ATOMIC);
3624+
unsigned long *map = bitmap_zalloc(page->objects, GFP_ATOMIC);
36273625
if (!map)
36283626
return;
36293627
slab_err(s, page, text, s->name);
@@ -3638,7 +3636,7 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,
36383636
}
36393637
}
36403638
slab_unlock(page);
3641-
kfree(map);
3639+
bitmap_free(map);
36423640
#endif
36433641
}
36443642

@@ -4411,18 +4409,16 @@ static long validate_slab_cache(struct kmem_cache *s)
44114409
{
44124410
int node;
44134411
unsigned long count = 0;
4414-
unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)),
4415-
sizeof(unsigned long),
4416-
GFP_KERNEL);
44174412
struct kmem_cache_node *n;
4413+
unsigned long *map = bitmap_alloc(oo_objects(s->max), GFP_KERNEL);
44184414

44194415
if (!map)
44204416
return -ENOMEM;
44214417

44224418
flush_all(s);
44234419
for_each_kmem_cache_node(s, node, n)
44244420
count += validate_slab_node(s, n, map);
4425-
kfree(map);
4421+
bitmap_free(map);
44264422
return count;
44274423
}
44284424
/*
@@ -4573,14 +4569,12 @@ static int list_locations(struct kmem_cache *s, char *buf,
45734569
unsigned long i;
45744570
struct loc_track t = { 0, 0, NULL };
45754571
int node;
4576-
unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)),
4577-
sizeof(unsigned long),
4578-
GFP_KERNEL);
45794572
struct kmem_cache_node *n;
4573+
unsigned long *map = bitmap_alloc(oo_objects(s->max), GFP_KERNEL);
45804574

45814575
if (!map || !alloc_loc_track(&t, PAGE_SIZE / sizeof(struct location),
45824576
GFP_KERNEL)) {
4583-
kfree(map);
4577+
bitmap_free(map);
45844578
return sprintf(buf, "Out of memory\n");
45854579
}
45864580
/* Push back cpu slabs */
@@ -4646,7 +4640,7 @@ static int list_locations(struct kmem_cache *s, char *buf,
46464640
}
46474641

46484642
free_loc_track(&t);
4649-
kfree(map);
4643+
bitmap_free(map);
46504644
if (!t.count)
46514645
len += sprintf(buf, "No data\n");
46524646
return len;

0 commit comments

Comments
 (0)