diff mbox series

[1/2] mm/damon/vaddr: constify static mm_walk_ops

Message ID 20211014075042.17174-2-rikard.falkeborn@gmail.com (mailing list archive)
State New
Headers show
Series mm: constify static mm_walk_ops | expand

Commit Message

Rikard Falkeborn Oct. 14, 2021, 7:50 a.m. UTC
The only usage of these structs is to pass their addresses to
walk_page_range(), which takes a pointer to const mm_walk_ops as
argument. Make them const to allow the compiler to put them in
read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 mm/damon/vaddr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

SeongJae Park Oct. 14, 2021, 10:29 a.m. UTC | #1
On Thu, 14 Oct 2021 09:50:41 +0200 Rikard Falkeborn <rikard.falkeborn@gmail.com> wrote:

> The only usage of these structs is to pass their addresses to
> walk_page_range(), which takes a pointer to const mm_walk_ops as
> argument. Make them const to allow the compiler to put them in
> read-only memory.
> 
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]
Anshuman Khandual Oct. 18, 2021, 6:49 a.m. UTC | #2
On 10/14/21 1:20 PM, Rikard Falkeborn wrote:
> The only usage of these structs is to pass their addresses to
> walk_page_range(), which takes a pointer to const mm_walk_ops as
> argument. Make them const to allow the compiler to put them in
> read-only memory.
> 
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> ---
>  mm/damon/vaddr.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index 953c145b4f08..65d4f115fa66 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -476,7 +476,7 @@ static int damon_mkold_pmd_entry(pmd_t *pmd, unsigned long addr,
>  	return 0;
>  }
>  
> -static struct mm_walk_ops damon_mkold_ops = {
> +static const struct mm_walk_ops damon_mkold_ops = {
>  	.pmd_entry = damon_mkold_pmd_entry,
>  };
>  
> @@ -572,7 +572,7 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr,
>  	return 0;
>  }
>  
> -static struct mm_walk_ops damon_young_ops = {
> +static const struct mm_walk_ops damon_young_ops = {
>  	.pmd_entry = damon_young_pmd_entry,
>  };
>  
> 

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
diff mbox series

Patch

diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index 953c145b4f08..65d4f115fa66 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -476,7 +476,7 @@  static int damon_mkold_pmd_entry(pmd_t *pmd, unsigned long addr,
 	return 0;
 }
 
-static struct mm_walk_ops damon_mkold_ops = {
+static const struct mm_walk_ops damon_mkold_ops = {
 	.pmd_entry = damon_mkold_pmd_entry,
 };
 
@@ -572,7 +572,7 @@  static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr,
 	return 0;
 }
 
-static struct mm_walk_ops damon_young_ops = {
+static const struct mm_walk_ops damon_young_ops = {
 	.pmd_entry = damon_young_pmd_entry,
 };