mm: kfence: Use PAGE_ALIGNED helper
Subsystems (2)
PATCH 1/1 mm: kfence: Use PAGE_ALIGNED helper
Use PAGE_ALIGNED macro instead of IS_ALIGNED and passing PAGE_SIZE.
--- mm/kfence/kfence_test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
mm/kfence/kfence_test.c +2 -3
@@ -296,10 +296,9 @@ static void *test_alloc(struct kunit *test, size_t size, gfp_t gfp, enum allocatif (policy ==ALLOCATE_ANY )return alloc; -if (policy ==ALLOCATE_LEFT &&IS_ALIGNED ((unsigned long )alloc,PAGE_SIZE )) +if (policy ==ALLOCATE_LEFT &&PAGE_ALIGNED (alloc))return alloc; -if (policy ==ALLOCATE_RIGHT && - !IS_ALIGNED ((unsigned long )alloc,PAGE_SIZE )) +if (policy ==ALLOCATE_RIGHT && !PAGE_ALIGNED (alloc))return alloc; }else if (policy ==ALLOCATE_NONE )return alloc;
Signature · 1 line
2.35.3
Quoted 3 lines · Kefeng Wang' via kasan-dev
Use
PAGE_ALIGNEDmacro instead ofIS_ALIGNEDand passingPAGE_SIZE.Signed-off-by Kefeng Wang <[email protected]>
Quoted 23 lines
--- mm/kfence/kfence_test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)mm/kfence/kfence_test.c +2
-3@@ -296,10 +296,9 @@ static void *test_alloc(struct kunit *test, size_t size, gfp_t gfp, enum allocatif (policy ==ALLOCATE_ANY )return alloc; -if (policy ==ALLOCATE_LEFT &&IS_ALIGNED ((unsigned long )alloc,PAGE_SIZE )) +if (policy ==ALLOCATE_LEFT &&PAGE_ALIGNED (alloc))return alloc; -if (policy ==ALLOCATE_RIGHT && - !IS_ALIGNED ((unsigned long )alloc,PAGE_SIZE )) +if (policy ==ALLOCATE_RIGHT && !PAGE_ALIGNED (alloc))return alloc; }else if (policy ==ALLOCATE_NONE )return alloc;Signature · 1 line
2.35.3
Quoted 3 lines · Kefeng Wang
Use
PAGE_ALIGNEDmacro instead ofIS_ALIGNEDand passingPAGE_SIZE.Signed-off-by Kefeng Wang <[email protected]>
BTW, there is a similar case in page_fixed_fake_head(), woule you like to improve that as well?
Thanks.
Quoted 5 lines · Muchun Song
Quoted 3 lines · Kefeng Wang
Use
PAGE_ALIGNEDmacro instead ofIS_ALIGNEDand passingPAGE_SIZE.Signed-off-by Kefeng Wang <[email protected]>Acked-by Muchun Song <[email protected]>
Thanks,
Quoted 3 lines
BTW, there is a similar case in
page_fixed_fake_head(), woule you like to improve that as well?
IS_ALIGNED is defined in include/linux/align.h, but PAGE_ALIGNED is in include/linux/mm.h, so better to keep unchanged in include/linux/page-flags.h.
Quoted 4 lines
Thanks.
.
Quoted 6 lines · Kefeng Wang
Quoted 4 lines · Muchun Song
Quoted 3 lines · Kefeng Wang
Use
PAGE_ALIGNEDmacro instead ofIS_ALIGNEDand passingPAGE_SIZE.Signed-off-by Kefeng Wang <[email protected]>
Quoted 9 lines
Quoted 1 line
Acked-by Muchun Song <[email protected]>Thanks,
Quoted 3 lines
BTW, there is a similar case in
page_fixed_fake_head(), woule you like to improve that as well?
IS_ALIGNEDis defined ininclude/linux/align.h, butPAGE_ALIGNEDis ininclude/linux/mm.h, so better to keep unchanged ininclude/linux/page-flags.h.
Maybe we could move this macro to page-flags.h or align.h so that we could reuse it?
Thanks.
Quoted 7 lines · Muchun Song
Quoted 6 lines · Kefeng Wang
Quoted 5 lines · Muchun Song
Quoted 3 lines · Kefeng Wang
Use
PAGE_ALIGNEDmacro instead ofIS_ALIGNEDand passingPAGE_SIZE.Signed-off-by Kefeng Wang <[email protected]>Acked-by Muchun Song <[email protected]>
Quoted 8 lines
Quoted 6 lines
Thanks,
Quoted 2 lines
BTW, there is a similar case in
page_fixed_fake_head(), woule you like to improve that as well?
IS_ALIGNEDis defined ininclude/linux/align.h, butPAGE_ALIGNEDis ininclude/linux/mm.h, so better to keep unchanged ininclude/linux/page-flags.h.Maybe we could move this macro to
page-flags.horalign.hso that we could reuse it?
align.h is inappropriate, could be page-flags.h, but this could affect the include of 'mm.h',so I think it is unnecessary to move the PAGE_ALIGNED(and there is a PAGE_ALIGN too, no need to move both of them).
Quoted 2 lines
Thanks.
.