lkml.org 
[lkml]   [2021]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/6] mm/z3fold: remove magic number in z3fold_create_pool()
Date
It's meaningless to pass a magic number 2 to __alloc_percpu() as there is
a minimum alignment size of PCPU_MIN_ALLOC_SIZE (> 2) in it. Also there is
no special alignment requirement for unbuddied. So we could replace this
magic number with nature alignment, i.e. __alignof__(struct list_head), to
improve readability.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/z3fold.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/z3fold.c b/mm/z3fold.c
index e261e14b7753..988d57c143fd 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -1000,7 +1000,8 @@ static struct z3fold_pool *z3fold_create_pool(const char *name, gfp_t gfp,
goto out_c;
spin_lock_init(&pool->lock);
spin_lock_init(&pool->stale_lock);
- pool->unbuddied = __alloc_percpu(sizeof(struct list_head)*NCHUNKS, 2);
+ pool->unbuddied = __alloc_percpu(sizeof(struct list_head) * NCHUNKS,
+ __alignof__(struct list_head));
if (!pool->unbuddied)
goto out_pool;
for_each_possible_cpu(cpu) {
--
2.23.0
\
 
 \ /
  Last update: 2021-06-19 11:33    [W:0.045 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site