linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/swap_state: Constify static struct attribute_group
@ 2021-02-01 23:32 Rikard Falkeborn
  2021-02-01 23:54 ` Amy Parker
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2021-02-01 23:32 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Huang Ying, Rikard Falkeborn

The only usage of swap_attr_group is to pass its address to
sysfs_create_group() which takes a pointer to const attribute_group.
Make it const to allow the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 mm/swap_state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/swap_state.c b/mm/swap_state.c
index d0d417efeecc..3cdee7b11da9 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -901,7 +901,7 @@ static struct attribute *swap_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group swap_attr_group = {
+static const struct attribute_group swap_attr_group = {
 	.attrs = swap_attrs,
 };
 
-- 
2.30.0



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

* Re: [PATCH] mm/swap_state: Constify static struct attribute_group
  2021-02-01 23:32 [PATCH] mm/swap_state: Constify static struct attribute_group Rikard Falkeborn
@ 2021-02-01 23:54 ` Amy Parker
  2021-02-02  0:39 ` Huang, Ying
  2021-02-02  1:35 ` Miaohe Lin
  2 siblings, 0 replies; 4+ messages in thread
From: Amy Parker @ 2021-02-01 23:54 UTC (permalink / raw)
  To: Rikard Falkeborn; +Cc: Andrew Morton, Linux MM, linux-kernel, Huang Ying

On Mon, Feb 1, 2021 at 3:37 PM Rikard Falkeborn
<rikard.falkeborn@gmail.com> wrote:
>
> The only usage of swap_attr_group is to pass its address to
> sysfs_create_group() which takes a pointer to const attribute_group.
> Make it const to allow the compiler to put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> ---
>  mm/swap_state.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/swap_state.c b/mm/swap_state.c
> index d0d417efeecc..3cdee7b11da9 100644
> --- a/mm/swap_state.c
> +++ b/mm/swap_state.c
> @@ -901,7 +901,7 @@ static struct attribute *swap_attrs[] = {
>         NULL,
>  };
>
> -static struct attribute_group swap_attr_group = {
> +static const struct attribute_group swap_attr_group = {
>         .attrs = swap_attrs,
>  };
>
> --
> 2.30.0
>

Looks all good to me - there aren't any dependencies on it anywhere else.

Reviewed-by: Amy Parker <enbyamy@gmail.com>


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

* Re: [PATCH] mm/swap_state: Constify static struct attribute_group
  2021-02-01 23:32 [PATCH] mm/swap_state: Constify static struct attribute_group Rikard Falkeborn
  2021-02-01 23:54 ` Amy Parker
@ 2021-02-02  0:39 ` Huang, Ying
  2021-02-02  1:35 ` Miaohe Lin
  2 siblings, 0 replies; 4+ messages in thread
From: Huang, Ying @ 2021-02-02  0:39 UTC (permalink / raw)
  To: Rikard Falkeborn; +Cc: Andrew Morton, linux-mm, linux-kernel

Rikard Falkeborn <rikard.falkeborn@gmail.com> writes:

> The only usage of swap_attr_group is to pass its address to
> sysfs_create_group() which takes a pointer to const attribute_group.
> Make it const to allow the compiler to put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

Looks good to me.

Acked-by: "Huang, Ying" <ying.huang@intel.com>

> ---
>  mm/swap_state.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/swap_state.c b/mm/swap_state.c
> index d0d417efeecc..3cdee7b11da9 100644
> --- a/mm/swap_state.c
> +++ b/mm/swap_state.c
> @@ -901,7 +901,7 @@ static struct attribute *swap_attrs[] = {
>  	NULL,
>  };
>  
> -static struct attribute_group swap_attr_group = {
> +static const struct attribute_group swap_attr_group = {
>  	.attrs = swap_attrs,
>  };


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

* Re: [PATCH] mm/swap_state: Constify static struct attribute_group
  2021-02-01 23:32 [PATCH] mm/swap_state: Constify static struct attribute_group Rikard Falkeborn
  2021-02-01 23:54 ` Amy Parker
  2021-02-02  0:39 ` Huang, Ying
@ 2021-02-02  1:35 ` Miaohe Lin
  2 siblings, 0 replies; 4+ messages in thread
From: Miaohe Lin @ 2021-02-02  1:35 UTC (permalink / raw)
  To: Rikard Falkeborn; +Cc: linux-mm, linux-kernel, Huang Ying, Andrew Morton

Hi:
On 2021/2/2 7:32, Rikard Falkeborn wrote:
> The only usage of swap_attr_group is to pass its address to
> sysfs_create_group() which takes a pointer to const attribute_group.
> Make it const to allow the compiler to put it in read-only memory.
> 
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

Looks good to me. Thanks.
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

> ---
>  mm/swap_state.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/swap_state.c b/mm/swap_state.c
> index d0d417efeecc..3cdee7b11da9 100644
> --- a/mm/swap_state.c
> +++ b/mm/swap_state.c
> @@ -901,7 +901,7 @@ static struct attribute *swap_attrs[] = {
>  	NULL,
>  };
>  
> -static struct attribute_group swap_attr_group = {
> +static const struct attribute_group swap_attr_group = {
>  	.attrs = swap_attrs,
>  };
>  
> 



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

end of thread, other threads:[~2021-02-02  1:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 23:32 [PATCH] mm/swap_state: Constify static struct attribute_group Rikard Falkeborn
2021-02-01 23:54 ` Amy Parker
2021-02-02  0:39 ` Huang, Ying
2021-02-02  1:35 ` Miaohe Lin

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