Commit f94afee9 authored by Hui Su's avatar Hui Su Committed by Linus Torvalds

mm/z3fold.c: use xx_zalloc instead xx_alloc and memset

alloc_slots() allocates memory for slots using kmem_cache_alloc(), then
memsets it.  We can just use kmem_cache_zalloc().
Signed-off-by: default avatarHui Su <sh_def@163.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Link: https://lkml.kernel.org/r/20200926100834.GA184671@rlkSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 01c4776b
...@@ -212,13 +212,12 @@ static inline struct z3fold_buddy_slots *alloc_slots(struct z3fold_pool *pool, ...@@ -212,13 +212,12 @@ static inline struct z3fold_buddy_slots *alloc_slots(struct z3fold_pool *pool,
{ {
struct z3fold_buddy_slots *slots; struct z3fold_buddy_slots *slots;
slots = kmem_cache_alloc(pool->c_handle, slots = kmem_cache_zalloc(pool->c_handle,
(gfp & ~(__GFP_HIGHMEM | __GFP_MOVABLE))); (gfp & ~(__GFP_HIGHMEM | __GFP_MOVABLE)));
if (slots) { if (slots) {
/* It will be freed separately in free_handle(). */ /* It will be freed separately in free_handle(). */
kmemleak_not_leak(slots); kmemleak_not_leak(slots);
memset(slots->slot, 0, sizeof(slots->slot));
slots->pool = (unsigned long)pool; slots->pool = (unsigned long)pool;
rwlock_init(&slots->lock); rwlock_init(&slots->lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment