* [PATCH 0/3] minor cleanups for kmsan
@ 2023-07-27 1:16 Peng Zhang
2023-07-27 1:16 ` [PATCH 1/3] mm: kmsan: use helper function page_size() Peng Zhang
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Peng Zhang @ 2023-07-27 1:16 UTC (permalink / raw)
To: linux-mm, linux-kernel
Cc: glider, elver, dvyukov, kasan-dev, akpm, wangkefeng.wang,
sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper function and macros to improve code readability. No
functional modification involved.
ZhangPeng (3):
mm: kmsan: use helper function page_size()
mm: kmsan: use helper macro offset_in_page()
mm: kmsan: use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN
mm/kmsan/hooks.c | 4 ++--
mm/kmsan/shadow.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] mm: kmsan: use helper function page_size()
2023-07-27 1:16 [PATCH 0/3] minor cleanups for kmsan Peng Zhang
@ 2023-07-27 1:16 ` Peng Zhang
2023-07-31 17:00 ` Alexander Potapenko
2023-07-27 1:16 ` [PATCH 2/3] mm: kmsan: use helper macro offset_in_page() Peng Zhang
2023-07-27 1:16 ` [PATCH 3/3] mm: kmsan: use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN Peng Zhang
2 siblings, 1 reply; 8+ messages in thread
From: Peng Zhang @ 2023-07-27 1:16 UTC (permalink / raw)
To: linux-mm, linux-kernel
Cc: glider, elver, dvyukov, kasan-dev, akpm, wangkefeng.wang,
sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use function page_size() to improve code readability. No functional
modification involved.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/kmsan/hooks.c | 2 +-
mm/kmsan/shadow.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c
index ec0da72e65aa..4e3c3e60ba97 100644
--- a/mm/kmsan/hooks.c
+++ b/mm/kmsan/hooks.c
@@ -117,7 +117,7 @@ void kmsan_kfree_large(const void *ptr)
page = virt_to_head_page((void *)ptr);
KMSAN_WARN_ON(ptr != page_address(page));
kmsan_internal_poison_memory((void *)ptr,
- PAGE_SIZE << compound_order(page),
+ page_size(page),
GFP_KERNEL,
KMSAN_POISON_CHECK | KMSAN_POISON_FREE);
kmsan_leave_runtime();
diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c
index b8bb95eea5e3..c7de991f6d7f 100644
--- a/mm/kmsan/shadow.c
+++ b/mm/kmsan/shadow.c
@@ -210,7 +210,7 @@ void kmsan_free_page(struct page *page, unsigned int order)
return;
kmsan_enter_runtime();
kmsan_internal_poison_memory(page_address(page),
- PAGE_SIZE << compound_order(page),
+ page_size(page),
GFP_KERNEL,
KMSAN_POISON_CHECK | KMSAN_POISON_FREE);
kmsan_leave_runtime();
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] mm: kmsan: use helper macro offset_in_page()
2023-07-27 1:16 [PATCH 0/3] minor cleanups for kmsan Peng Zhang
2023-07-27 1:16 ` [PATCH 1/3] mm: kmsan: use helper function page_size() Peng Zhang
@ 2023-07-27 1:16 ` Peng Zhang
2023-07-31 17:01 ` Alexander Potapenko
2023-07-27 1:16 ` [PATCH 3/3] mm: kmsan: use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN Peng Zhang
2 siblings, 1 reply; 8+ messages in thread
From: Peng Zhang @ 2023-07-27 1:16 UTC (permalink / raw)
To: linux-mm, linux-kernel
Cc: glider, elver, dvyukov, kasan-dev, akpm, wangkefeng.wang,
sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper macro offset_in_page() to improve code readability. No
functional modification involved.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/kmsan/hooks.c | 2 +-
mm/kmsan/shadow.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c
index 4e3c3e60ba97..5d6e2dee5692 100644
--- a/mm/kmsan/hooks.c
+++ b/mm/kmsan/hooks.c
@@ -339,7 +339,7 @@ void kmsan_handle_dma(struct page *page, size_t offset, size_t size,
* internal KMSAN checks.
*/
while (size > 0) {
- page_offset = addr % PAGE_SIZE;
+ page_offset = offset_in_page(addr);
to_go = min(PAGE_SIZE - page_offset, (u64)size);
kmsan_handle_dma_page((void *)addr, to_go, dir);
addr += to_go;
diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c
index c7de991f6d7f..966994268a01 100644
--- a/mm/kmsan/shadow.c
+++ b/mm/kmsan/shadow.c
@@ -145,7 +145,7 @@ void *kmsan_get_metadata(void *address, bool is_origin)
return NULL;
if (!page_has_metadata(page))
return NULL;
- off = addr % PAGE_SIZE;
+ off = offset_in_page(addr);
return (is_origin ? origin_ptr_for(page) : shadow_ptr_for(page)) + off;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] mm: kmsan: use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN
2023-07-27 1:16 [PATCH 0/3] minor cleanups for kmsan Peng Zhang
2023-07-27 1:16 ` [PATCH 1/3] mm: kmsan: use helper function page_size() Peng Zhang
2023-07-27 1:16 ` [PATCH 2/3] mm: kmsan: use helper macro offset_in_page() Peng Zhang
@ 2023-07-27 1:16 ` Peng Zhang
2023-07-31 17:02 ` Alexander Potapenko
2 siblings, 1 reply; 8+ messages in thread
From: Peng Zhang @ 2023-07-27 1:16 UTC (permalink / raw)
To: linux-mm, linux-kernel
Cc: glider, elver, dvyukov, kasan-dev, akpm, wangkefeng.wang,
sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN to improve code
readability. No functional modification involved.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/kmsan/shadow.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c
index 966994268a01..87318f9170f1 100644
--- a/mm/kmsan/shadow.c
+++ b/mm/kmsan/shadow.c
@@ -281,8 +281,8 @@ void __init kmsan_init_alloc_meta_for_range(void *start, void *end)
struct page *page;
u64 size;
- start = (void *)ALIGN_DOWN((u64)start, PAGE_SIZE);
- size = ALIGN((u64)end - (u64)start, PAGE_SIZE);
+ start = (void *)PAGE_ALIGN_DOWN((u64)start);
+ size = PAGE_ALIGN((u64)end - (u64)start);
shadow = memblock_alloc(size, PAGE_SIZE);
origin = memblock_alloc(size, PAGE_SIZE);
for (u64 addr = 0; addr < size; addr += PAGE_SIZE) {
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] mm: kmsan: use helper function page_size()
2023-07-27 1:16 ` [PATCH 1/3] mm: kmsan: use helper function page_size() Peng Zhang
@ 2023-07-31 17:00 ` Alexander Potapenko
0 siblings, 0 replies; 8+ messages in thread
From: Alexander Potapenko @ 2023-07-31 17:00 UTC (permalink / raw)
To: Peng Zhang
Cc: linux-mm, linux-kernel, elver, dvyukov, kasan-dev, akpm,
wangkefeng.wang, sunnanyong
On Thu, Jul 27, 2023 at 3:16 AM 'Peng Zhang' via kasan-dev
<kasan-dev@googlegroups.com> wrote:
>
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use function page_size() to improve code readability. No functional
> modification involved.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] mm: kmsan: use helper macro offset_in_page()
2023-07-27 1:16 ` [PATCH 2/3] mm: kmsan: use helper macro offset_in_page() Peng Zhang
@ 2023-07-31 17:01 ` Alexander Potapenko
0 siblings, 0 replies; 8+ messages in thread
From: Alexander Potapenko @ 2023-07-31 17:01 UTC (permalink / raw)
To: Peng Zhang
Cc: linux-mm, linux-kernel, elver, dvyukov, kasan-dev, akpm,
wangkefeng.wang, sunnanyong
On Thu, Jul 27, 2023 at 3:16 AM 'Peng Zhang' via kasan-dev
<kasan-dev@googlegroups.com> wrote:
>
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use helper macro offset_in_page() to improve code readability. No
> functional modification involved.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] mm: kmsan: use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN
2023-07-27 1:16 ` [PATCH 3/3] mm: kmsan: use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN Peng Zhang
@ 2023-07-31 17:02 ` Alexander Potapenko
2023-07-31 17:02 ` Alexander Potapenko
0 siblings, 1 reply; 8+ messages in thread
From: Alexander Potapenko @ 2023-07-31 17:02 UTC (permalink / raw)
To: Peng Zhang
Cc: linux-mm, linux-kernel, elver, dvyukov, kasan-dev, akpm,
wangkefeng.wang, sunnanyong
On Thu, Jul 27, 2023 at 3:16 AM 'Peng Zhang' via kasan-dev
<kasan-dev@googlegroups.com> wrote:
>
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN to improve code
> readability. No functional modification involved.
>
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] mm: kmsan: use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN
2023-07-31 17:02 ` Alexander Potapenko
@ 2023-07-31 17:02 ` Alexander Potapenko
0 siblings, 0 replies; 8+ messages in thread
From: Alexander Potapenko @ 2023-07-31 17:02 UTC (permalink / raw)
To: Peng Zhang
Cc: linux-mm, linux-kernel, elver, dvyukov, kasan-dev, akpm,
wangkefeng.wang, sunnanyong
On Mon, Jul 31, 2023 at 7:02 PM Alexander Potapenko <glider@google.com> wrote:
>
> On Thu, Jul 27, 2023 at 3:16 AM 'Peng Zhang' via kasan-dev
> <kasan-dev@googlegroups.com> wrote:
> >
> > From: ZhangPeng <zhangpeng362@huawei.com>
> >
> > Use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN to improve code
> > readability. No functional modification involved.
> >
> > Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> Reviewed-by: Alexander Potapenko <glider@google.com>
Thanks for the series!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-07-31 17:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-27 1:16 [PATCH 0/3] minor cleanups for kmsan Peng Zhang
2023-07-27 1:16 ` [PATCH 1/3] mm: kmsan: use helper function page_size() Peng Zhang
2023-07-31 17:00 ` Alexander Potapenko
2023-07-27 1:16 ` [PATCH 2/3] mm: kmsan: use helper macro offset_in_page() Peng Zhang
2023-07-31 17:01 ` Alexander Potapenko
2023-07-27 1:16 ` [PATCH 3/3] mm: kmsan: use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN Peng Zhang
2023-07-31 17:02 ` Alexander Potapenko
2023-07-31 17:02 ` Alexander Potapenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).