diff mbox series

[2/2] mm/memory_failure: constify static mm_walk_ops

Message ID 20211014075042.17174-3-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 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 <rikard.falkeborn@gmail.com>
---
 mm/memory-failure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Naoya Horiguchi Oct. 15, 2021, 12:47 a.m. UTC | #1
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 <rikard.falkeborn@gmail.com>

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Anshuman Khandual Oct. 18, 2021, 6:52 a.m. UTC | #2
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 <rikard.falkeborn@gmail.com>
> ---
>  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 <anshuman.khandual@arm.com>
diff mbox series

Patch

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,
 };