All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: kfence: Use PAGE_ALIGNED helper
@ 2022-05-20  2:18 Kefeng Wang
  2022-05-20  7:43 ` Marco Elver
  2022-05-20 10:26 ` Muchun Song
  0 siblings, 2 replies; 6+ messages in thread
From: Kefeng Wang @ 2022-05-20  2:18 UTC (permalink / raw)
  To: Marco Elver, Alexander Potapenko, Dmitry Vyukov, Andrew Morton,
	linux-mm, kasan-dev
  Cc: Kefeng Wang

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(-)

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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: kfence: Use PAGE_ALIGNED helper
  2022-05-20  2:18 [PATCH] mm: kfence: Use PAGE_ALIGNED helper Kefeng Wang
@ 2022-05-20  7:43 ` Marco Elver
  2022-05-20 10:26 ` Muchun Song
  1 sibling, 0 replies; 6+ messages in thread
From: Marco Elver @ 2022-05-20  7:43 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Alexander Potapenko, Dmitry Vyukov, Andrew Morton, linux-mm, kasan-dev

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: kfence: Use PAGE_ALIGNED helper
  2022-05-20  2:18 [PATCH] mm: kfence: Use PAGE_ALIGNED helper Kefeng Wang
  2022-05-20  7:43 ` Marco Elver
@ 2022-05-20 10:26 ` Muchun Song
  2022-05-23  6:32   ` Kefeng Wang
  1 sibling, 1 reply; 6+ messages in thread
From: Muchun Song @ 2022-05-20 10:26 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Marco Elver, Alexander Potapenko, Dmitry Vyukov, Andrew Morton,
	linux-mm, kasan-dev

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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: kfence: Use PAGE_ALIGNED helper
  2022-05-20 10:26 ` Muchun Song
@ 2022-05-23  6:32   ` Kefeng Wang
  2022-05-23  6:46     ` Muchun Song
  0 siblings, 1 reply; 6+ messages in thread
From: Kefeng Wang @ 2022-05-23  6:32 UTC (permalink / raw)
  To: Muchun Song
  Cc: Marco Elver, Alexander Potapenko, Dmitry Vyukov, Andrew Morton,
	linux-mm, kasan-dev


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.
>
> .


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: kfence: Use PAGE_ALIGNED helper
  2022-05-23  6:32   ` Kefeng Wang
@ 2022-05-23  6:46     ` Muchun Song
  2022-05-23  7:13       ` Kefeng Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Muchun Song @ 2022-05-23  6:46 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Marco Elver, Alexander Potapenko, Dmitry Vyukov, Andrew Morton,
	linux-mm, kasan-dev

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: kfence: Use PAGE_ALIGNED helper
  2022-05-23  6:46     ` Muchun Song
@ 2022-05-23  7:13       ` Kefeng Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Kefeng Wang @ 2022-05-23  7:13 UTC (permalink / raw)
  To: Muchun Song
  Cc: Marco Elver, Alexander Potapenko, Dmitry Vyukov, Andrew Morton,
	linux-mm, kasan-dev


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.
> .


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-23  7:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20  2:18 [PATCH] mm: kfence: Use PAGE_ALIGNED helper Kefeng Wang
2022-05-20  7:43 ` Marco Elver
2022-05-20 10:26 ` Muchun Song
2022-05-23  6:32   ` Kefeng Wang
2022-05-23  6:46     ` Muchun Song
2022-05-23  7:13       ` Kefeng Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.