2021-10-14 07:53:50

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 0/2] 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(-)

--
2.33.0


2021-10-14 07:54:23

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 2/2] mm/memory_failure: constify static mm_walk_ops

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

Signed-off-by: Rikard Falkeborn <[email protected]>
---
mm/memory-failure.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 92eeb317adf4..8d5faf347ed1 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -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,
};
--
2.33.0

2021-10-15 07:51:57

by Naoya Horiguchi

[permalink] [raw]
Subject: Re: [PATCH 2/2] mm/memory_failure: constify static mm_walk_ops

On Thu, Oct 14, 2021 at 09:50:42AM +0200, Rikard Falkeborn wrote:
> The 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.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>

Acked-by: Naoya Horiguchi <[email protected]>

2021-10-18 06:56:28

by Anshuman Khandual

[permalink] [raw]
Subject: Re: [PATCH 2/2] mm/memory_failure: constify static mm_walk_ops



On 10/14/21 1:20 PM, Rikard Falkeborn wrote:
> The 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.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>
> ---
> mm/memory-failure.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 92eeb317adf4..8d5faf347ed1 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -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,
> };
>

Reviewed-by: Anshuman Khandual <[email protected]>