mm: constify static mm_walk_ops
Subsystems (3)
cover mm: constify static mm_walk_ops
Constify a few instances of static struct mm_walk_ops that are never modified. The only usage of them is to pass their address to walk_page_range() which has a pointer to const struct mm_walk_ops as argument. Making them const allows the compiler to put them in read-only memory.
Rikard Falkeborn (2):
mm/damon/vaddr: constify static mm_walk_ops
mm/memory_failure: constify static mm_walk_ops
mm/damon/vaddr.c | 4 ++-- mm/memory-failure.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.33.0
PATCH 1/2 mm/damon/vaddr: constify static mm_walk_ops
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.
--- mm/damon/vaddr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/damon/vaddr.c +2 -2
@@ -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, };
Signature · 1 line
2.33.0
Re: [PATCH 1/2] mm/damon/vaddr: constify static mm_walk_ops
Quoted 6 lines · On Thu, 14 Oct 2021 09:50:41 +0200 Rikard Falkeborn…
The only usage of these structs is to pass their addresses to
walk_page_range(), which takes a pointer to constmm_walk_opsas argument. Make them const to allow the compiler to put them in read-only memory.Signed-off-by Rikard Falkeborn <[email protected]>
Thanks,
SJ
[...]
Re: [PATCH 1/2] mm/damon/vaddr: constify static mm_walk_ops
In reply to Rikard FalkebornQuoted 25 lines · Rikard Falkeborn
The only usage of these structs is to pass their addresses to
walk_page_range(), which takes a pointer to constmm_walk_opsas argument. Make them const to allow the compiler to put them in read-only memory.Signed-off-by Rikard Falkeborn <[email protected]>--- mm/damon/vaddr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/damon/vaddr.c +1
-1@@ -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, };
mm/damon/vaddr.c static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, · line 578
Quoted 8 lines
mm/damon/vaddr.c +1
-1@@ -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, };
PATCH 2/2 mm/memory_failure: constify static mm_walk_ops
In reply to Rikard FalkebornThe only usage of hwp_walk_ops is to pass its address to walk_page_range() which takes a pointer to const mm_walk_ops as argument. Make it const to allow the compiler to put it in read-only memory.
--- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory-failure.c +1 -1
@@ -674,7 +674,7 @@ static int hwpoison_hugetlb_range(pte_t *ptep, unsigned long hmask,#define hwpoison_hugetlb_range NULL#endif -static struct mm_walk_ops hwp_walk_ops = { +static const struct mm_walk_ops hwp_walk_ops = { .pmd_entry = hwpoison_pte_range, .hugetlb_entry = hwpoison_hugetlb_range, };
Signature · 1 line
2.33.0
Re: [PATCH 2/2] mm/memory_failure: constify static mm_walk_ops
Quoted 6 lines · Rikard Falkeborn
The only usage of
hwp_walk_opsis to pass its address towalk_page_range()which takes a pointer to constmm_walk_opsas argument. Make it const to allow the compiler to put it in read-only memory.Signed-off-by Rikard Falkeborn <[email protected]>
Re: [PATCH 2/2] mm/memory_failure: constify static mm_walk_ops
In reply to Rikard FalkebornQuoted 16 lines · Rikard Falkeborn
The only usage of
hwp_walk_opsis to pass its address towalk_page_range()which takes a pointer to constmm_walk_opsas argument. Make it const to allow the compiler to put it in read-only memory.Signed-off-by Rikard Falkeborn <[email protected]>--- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/memory-failure.c +0
-0
mm/memory-failure.c static int hwpoison_hugetlb_range(pte_t *ptep, unsigned long hmask, · line 680
Quoted 8 lines
mm/memory-failure.c +1
-1@@ -674,7 +674,7 @@ static int hwpoison_hugetlb_range(pte_t *ptep, unsigned long hmask,#define hwpoison_hugetlb_range NULL#endif -static struct mm_walk_ops hwp_walk_ops = { +static const struct mm_walk_ops hwp_walk_ops = { .pmd_entry = hwpoison_pte_range, .hugetlb_entry = hwpoison_hugetlb_range, };