* [PATCH v1] mm/slub.c: Switch to bitmap_zalloc()
@ 2018-08-30 10:43 Andy Shevchenko
2018-08-30 15:33 ` Christopher Lameter
2018-08-31 21:32 ` David Rientjes
0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2018-08-30 10:43 UTC (permalink / raw)
To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
linux-mm, Andrew Morton
Cc: Andy Shevchenko
Switch to bitmap_zalloc() to show clearly what we are allocating.
Besides that it returns pointer of bitmap type instead of opaque void *.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
mm/slub.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index ce2b9e5cea77..8d85a38425fd 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3622,9 +3622,7 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,
#ifdef CONFIG_SLUB_DEBUG
void *addr = page_address(page);
void *p;
- unsigned long *map = kcalloc(BITS_TO_LONGS(page->objects),
- sizeof(long),
- GFP_ATOMIC);
+ unsigned long *map = bitmap_zalloc(page->objects, GFP_ATOMIC);
if (!map)
return;
slab_err(s, page, text, s->name);
@@ -3639,7 +3637,7 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,
}
}
slab_unlock(page);
- kfree(map);
+ bitmap_free(map);
#endif
}
@@ -4412,10 +4410,8 @@ static long validate_slab_cache(struct kmem_cache *s)
{
int node;
unsigned long count = 0;
- unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)),
- sizeof(unsigned long),
- GFP_KERNEL);
struct kmem_cache_node *n;
+ unsigned long *map = bitmap_alloc(oo_objects(s->max), GFP_KERNEL);
if (!map)
return -ENOMEM;
@@ -4423,7 +4419,7 @@ static long validate_slab_cache(struct kmem_cache *s)
flush_all(s);
for_each_kmem_cache_node(s, node, n)
count += validate_slab_node(s, n, map);
- kfree(map);
+ bitmap_free(map);
return count;
}
/*
@@ -4574,14 +4570,12 @@ static int list_locations(struct kmem_cache *s, char *buf,
unsigned long i;
struct loc_track t = { 0, 0, NULL };
int node;
- unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)),
- sizeof(unsigned long),
- GFP_KERNEL);
struct kmem_cache_node *n;
+ unsigned long *map = bitmap_alloc(oo_objects(s->max), GFP_KERNEL);
if (!map || !alloc_loc_track(&t, PAGE_SIZE / sizeof(struct location),
GFP_KERNEL)) {
- kfree(map);
+ bitmap_free(map);
return sprintf(buf, "Out of memory\n");
}
/* Push back cpu slabs */
@@ -4647,7 +4641,7 @@ static int list_locations(struct kmem_cache *s, char *buf,
}
free_loc_track(&t);
- kfree(map);
+ bitmap_free(map);
if (!t.count)
len += sprintf(buf, "No data\n");
return len;
--
2.18.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] mm/slub.c: Switch to bitmap_zalloc()
2018-08-30 10:43 [PATCH v1] mm/slub.c: Switch to bitmap_zalloc() Andy Shevchenko
@ 2018-08-30 15:33 ` Christopher Lameter
2018-08-31 21:32 ` David Rientjes
1 sibling, 0 replies; 3+ messages in thread
From: Christopher Lameter @ 2018-08-30 15:33 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Pekka Enberg, David Rientjes, Joonsoo Kim, linux-mm, Andrew Morton
Acked-by: Christoph Lameter <cl@linux.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] mm/slub.c: Switch to bitmap_zalloc()
2018-08-30 10:43 [PATCH v1] mm/slub.c: Switch to bitmap_zalloc() Andy Shevchenko
2018-08-30 15:33 ` Christopher Lameter
@ 2018-08-31 21:32 ` David Rientjes
1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2018-08-31 21:32 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Christoph Lameter, Pekka Enberg, Joonsoo Kim, linux-mm, Andrew Morton
On Thu, 30 Aug 2018, Andy Shevchenko wrote:
> Switch to bitmap_zalloc() to show clearly what we are allocating.
> Besides that it returns pointer of bitmap type instead of opaque void *.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: David Rientjes <rientjes@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-31 21:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-30 10:43 [PATCH v1] mm/slub.c: Switch to bitmap_zalloc() Andy Shevchenko
2018-08-30 15:33 ` Christopher Lameter
2018-08-31 21:32 ` David Rientjes
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.