Message ID | 20220520021833.121405-1-wangkefeng.wang@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm: kfence: Use PAGE_ALIGNED helper | expand |
On Fri, May 20, 2022 at 10:18AM +0800, 'Kefeng Wang' via kasan-dev wrote: > Use PAGE_ALIGNED macro instead of IS_ALIGNED and passing PAGE_SIZE. > > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Reviewed-by: Marco Elver <elver@google.com> > --- > mm/kfence/kfence_test.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c > index 96206a4ee9ab..a97bffe0cc3e 100644 > --- a/mm/kfence/kfence_test.c > +++ b/mm/kfence/kfence_test.c > @@ -296,10 +296,9 @@ static void *test_alloc(struct kunit *test, size_t size, gfp_t gfp, enum allocat > > if (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; > -- > 2.35.3
On Fri, May 20, 2022 at 10:18:33AM +0800, Kefeng Wang wrote: > Use PAGE_ALIGNED macro instead of IS_ALIGNED and passing PAGE_SIZE. > > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Acked-by: Muchun Song <songmuchun@bytedance.com> BTW, there is a similar case in page_fixed_fake_head(), woule you like to improve that as well? Thanks.
On 2022/5/20 18:26, Muchun Song wrote: > On Fri, May 20, 2022 at 10:18:33AM +0800, Kefeng Wang wrote: >> Use PAGE_ALIGNED macro instead of IS_ALIGNED and passing PAGE_SIZE. >> >> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > Acked-by: Muchun Song <songmuchun@bytedance.com> Thanks, > > 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. > > Thanks. > > .
On Mon, May 23, 2022 at 02:32:59PM +0800, Kefeng Wang wrote: > > On 2022/5/20 18:26, Muchun Song wrote: > > On Fri, May 20, 2022 at 10:18:33AM +0800, Kefeng Wang wrote: > > > Use PAGE_ALIGNED macro instead of IS_ALIGNED and passing PAGE_SIZE. > > > > > > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > > Acked-by: Muchun Song <songmuchun@bytedance.com> > Thanks, > > > > 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. > Maybe we could move this macro to page-flags.h or align.h so that we could reuse it? Thanks.
On 2022/5/23 14:46, Muchun Song wrote: > On Mon, May 23, 2022 at 02:32:59PM +0800, Kefeng Wang wrote: >> On 2022/5/20 18:26, Muchun Song wrote: >>> On Fri, May 20, 2022 at 10:18:33AM +0800, Kefeng Wang wrote: >>>> Use PAGE_ALIGNED macro instead of IS_ALIGNED and passing PAGE_SIZE. >>>> >>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> >>> Acked-by: Muchun Song <songmuchun@bytedance.com> >> Thanks, >>> 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. >> > Maybe we could move this macro to page-flags.h or align.h so 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). > Thanks. > .
diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index 96206a4ee9ab..a97bffe0cc3e 100644 --- a/mm/kfence/kfence_test.c +++ b/mm/kfence/kfence_test.c @@ -296,10 +296,9 @@ static void *test_alloc(struct kunit *test, size_t size, gfp_t gfp, enum allocat if (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;
Use PAGE_ALIGNED macro instead of IS_ALIGNED and passing PAGE_SIZE. Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> --- mm/kfence/kfence_test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)