linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm: constify static mm_walk_ops
@ 2021-10-14  7:50 Rikard Falkeborn
  2021-10-14  7:50 ` [PATCH 1/2] mm/damon/vaddr: " Rikard Falkeborn
  2021-10-14  7:50 ` [PATCH 2/2] mm/memory_failure: " Rikard Falkeborn
  0 siblings, 2 replies; 7+ messages in thread
From: Rikard Falkeborn @ 2021-10-14  7:50 UTC (permalink / raw)
  To: SeongJae Park, Andrew Morton, Naoya Horiguchi
  Cc: linux-mm, linux-kernel, Rikard Falkeborn

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] mm/damon/vaddr: constify static mm_walk_ops
  2021-10-14  7:50 [PATCH 0/2] mm: constify static mm_walk_ops Rikard Falkeborn
@ 2021-10-14  7:50 ` Rikard Falkeborn
  2021-10-14 10:29   ` SeongJae Park
  2021-10-18  6:49   ` Anshuman Khandual
  2021-10-14  7:50 ` [PATCH 2/2] mm/memory_failure: " Rikard Falkeborn
  1 sibling, 2 replies; 7+ messages in thread
From: Rikard Falkeborn @ 2021-10-14  7:50 UTC (permalink / raw)
  To: SeongJae Park, Andrew Morton, Naoya Horiguchi
  Cc: linux-mm, linux-kernel, Rikard Falkeborn

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] mm/memory_failure: constify static mm_walk_ops
  2021-10-14  7:50 [PATCH 0/2] mm: constify static mm_walk_ops Rikard Falkeborn
  2021-10-14  7:50 ` [PATCH 1/2] mm/damon/vaddr: " Rikard Falkeborn
@ 2021-10-14  7:50 ` Rikard Falkeborn
  2021-10-15  0:47   ` Naoya Horiguchi
  2021-10-18  6:52   ` Anshuman Khandual
  1 sibling, 2 replies; 7+ messages in thread
From: Rikard Falkeborn @ 2021-10-14  7:50 UTC (permalink / raw)
  To: SeongJae Park, Andrew Morton, Naoya Horiguchi
  Cc: linux-mm, linux-kernel, Rikard Falkeborn

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mm/damon/vaddr: constify static mm_walk_ops
  2021-10-14  7:50 ` [PATCH 1/2] mm/damon/vaddr: " Rikard Falkeborn
@ 2021-10-14 10:29   ` SeongJae Park
  2021-10-18  6:49   ` Anshuman Khandual
  1 sibling, 0 replies; 7+ messages in thread
From: SeongJae Park @ 2021-10-14 10:29 UTC (permalink / raw)
  To: Rikard Falkeborn
  Cc: SeongJae Park, Andrew Morton, Naoya Horiguchi, linux-mm, linux-kernel

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

[...]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] mm/memory_failure: constify static mm_walk_ops
  2021-10-14  7:50 ` [PATCH 2/2] mm/memory_failure: " Rikard Falkeborn
@ 2021-10-15  0:47   ` Naoya Horiguchi
  2021-10-18  6:52   ` Anshuman Khandual
  1 sibling, 0 replies; 7+ messages in thread
From: Naoya Horiguchi @ 2021-10-15  0:47 UTC (permalink / raw)
  To: Rikard Falkeborn
  Cc: SeongJae Park, Andrew Morton, Naoya Horiguchi, linux-mm, linux-kernel

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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mm/damon/vaddr: constify static mm_walk_ops
  2021-10-14  7:50 ` [PATCH 1/2] mm/damon/vaddr: " Rikard Falkeborn
  2021-10-14 10:29   ` SeongJae Park
@ 2021-10-18  6:49   ` Anshuman Khandual
  1 sibling, 0 replies; 7+ messages in thread
From: Anshuman Khandual @ 2021-10-18  6:49 UTC (permalink / raw)
  To: Rikard Falkeborn, SeongJae Park, Andrew Morton, Naoya Horiguchi
  Cc: linux-mm, linux-kernel



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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] mm/memory_failure: constify static mm_walk_ops
  2021-10-14  7:50 ` [PATCH 2/2] mm/memory_failure: " Rikard Falkeborn
  2021-10-15  0:47   ` Naoya Horiguchi
@ 2021-10-18  6:52   ` Anshuman Khandual
  1 sibling, 0 replies; 7+ messages in thread
From: Anshuman Khandual @ 2021-10-18  6:52 UTC (permalink / raw)
  To: Rikard Falkeborn, SeongJae Park, Andrew Morton, Naoya Horiguchi
  Cc: linux-mm, linux-kernel



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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-18  6:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14  7:50 [PATCH 0/2] mm: constify static mm_walk_ops Rikard Falkeborn
2021-10-14  7:50 ` [PATCH 1/2] mm/damon/vaddr: " Rikard Falkeborn
2021-10-14 10:29   ` SeongJae Park
2021-10-18  6:49   ` Anshuman Khandual
2021-10-14  7:50 ` [PATCH 2/2] mm/memory_failure: " Rikard Falkeborn
2021-10-15  0:47   ` Naoya Horiguchi
2021-10-18  6:52   ` Anshuman Khandual

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).