From: ZhangPeng <[email protected]>
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
From: ZhangPeng <[email protected]>
Use function page_size() to improve code readability. No functional
modification involved.
Signed-off-by: ZhangPeng <[email protected]>
---
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
From: ZhangPeng <[email protected]>
Use helper macro offset_in_page() to improve code readability. No
functional modification involved.
Signed-off-by: ZhangPeng <[email protected]>
---
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
From: ZhangPeng <[email protected]>
Use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN to improve code
readability. No functional modification involved.
Signed-off-by: ZhangPeng <[email protected]>
---
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
On Mon, Jul 31, 2023 at 7:02 PM Alexander Potapenko <[email protected]> wrote:
>
> On Thu, Jul 27, 2023 at 3:16 AM 'Peng Zhang' via kasan-dev
> <[email protected]> wrote:
> >
> > From: ZhangPeng <[email protected]>
> >
> > Use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN to improve code
> > readability. No functional modification involved.
> >
> > Signed-off-by: ZhangPeng <[email protected]>
> Reviewed-by: Alexander Potapenko <[email protected]>
Thanks for the series!
On Thu, Jul 27, 2023 at 3:16 AM 'Peng Zhang' via kasan-dev
<[email protected]> wrote:
>
> From: ZhangPeng <[email protected]>
>
> Use helper macro offset_in_page() to improve code readability. No
> functional modification involved.
>
> Signed-off-by: ZhangPeng <[email protected]>
Reviewed-by: Alexander Potapenko <[email protected]>
On Thu, Jul 27, 2023 at 3:16 AM 'Peng Zhang' via kasan-dev
<[email protected]> wrote:
>
> From: ZhangPeng <[email protected]>
>
> Use function page_size() to improve code readability. No functional
> modification involved.
>
> Signed-off-by: ZhangPeng <[email protected]>
Reviewed-by: Alexander Potapenko <[email protected]>
On Thu, Jul 27, 2023 at 3:16 AM 'Peng Zhang' via kasan-dev
<[email protected]> wrote:
>
> From: ZhangPeng <[email protected]>
>
> Use helper macros PAGE_ALIGN and PAGE_ALIGN_DOWN to improve code
> readability. No functional modification involved.
>
> Signed-off-by: ZhangPeng <[email protected]>
Reviewed-by: Alexander Potapenko <[email protected]>