summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2021-07-01 03:50:30 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2021-07-01 05:47:28 +0200
commite891f60e28c3e90e2589a7d2147ae192dca11245 (patch)
tree9ad0872bc35d880712d812e1d01a5b3f996ee8e6 /mm
parentmm/z3fold: avoid possible underflow in z3fold_alloc() (diff)
downloadlinux-e891f60e28c3e90e2589a7d2147ae192dca11245.tar.xz
linux-e891f60e28c3e90e2589a7d2147ae192dca11245.zip
mm/z3fold: remove magic number in z3fold_create_pool()
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. Link: https://lkml.kernel.org/r/20210619093151.1492174-4-linmiaohe@huawei.com Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Reviewed-by: Vitaly Wool <vitaly.wool@konsulko.com> Cc: Hillf Danton <hdanton@sina.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/z3fold.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/z3fold.c b/mm/z3fold.c
index 64ddf864d5ee..1b790d02f6f1 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -998,7 +998,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) {