linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 1/2] sysctl: Limit the value of interface compact_memory
@ 2023-03-06  6:07 ye.xingchen
  2023-03-08 10:21 ` Vlastimil Babka
  0 siblings, 1 reply; 3+ messages in thread
From: ye.xingchen @ 2023-03-06  6:07 UTC (permalink / raw)
  To: mcgrof
  Cc: keescook, yzaikin, akpm, linmiaohe, chi.minghao, linux-kernel,
	linux-fsdevel, linux-mm

From: Minghao Chi <chi.minghao@zte.com.cn>

In Documentation/admin-guide/sysctl/vm.rst:109 say: when 1 is written
to the file, all zones are compacted such that free memory is available
in contiguous blocks where possible.
So limit the value of interface compact_memory to 1.

Link: https://lore.kernel.org/all/ZAJwoXJCzfk1WIBx@bombadil.infradead.org/
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn>

---
 include/linux/compaction.h | 1 +
 kernel/sysctl.c            | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/compaction.h b/include/linux/compaction.h
index 52a9ff65faee..caa24e33eeb1 100644
--- a/include/linux/compaction.h
+++ b/include/linux/compaction.h
@@ -81,6 +81,7 @@ static inline unsigned long compact_gap(unsigned int order)
 }

 #ifdef CONFIG_COMPACTION
+extern int sysctl_compact_memory;
 extern unsigned int sysctl_compaction_proactiveness;
 extern int sysctl_compaction_handler(struct ctl_table *table, int write,
 			void *buffer, size_t *length, loff_t *ppos);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c14552a662ae..67f70952f71a 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2192,10 +2192,12 @@ static struct ctl_table vm_table[] = {
 #ifdef CONFIG_COMPACTION
 	{
 		.procname	= "compact_memory",
-		.data		= NULL,
+		.data		= &sysctl_compact_memory,
 		.maxlen		= sizeof(int),
 		.mode		= 0200,
 		.proc_handler	= sysctl_compaction_handler,
+		.extra1		= SYSCTL_ONE,
+		.extra2		= SYSCTL_ONE,
 	},
 	{
 		.procname	= "compaction_proactiveness",
-- 
2.25.1

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

* Re: [PATCH V2 1/2] sysctl: Limit the value of interface compact_memory
  2023-03-06  6:07 [PATCH V2 1/2] sysctl: Limit the value of interface compact_memory ye.xingchen
@ 2023-03-08 10:21 ` Vlastimil Babka
  2023-03-08 19:58   ` Luis Chamberlain
  0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka @ 2023-03-08 10:21 UTC (permalink / raw)
  To: ye.xingchen, mcgrof
  Cc: keescook, yzaikin, akpm, linmiaohe, chi.minghao, linux-kernel,
	linux-fsdevel, linux-mm



On 3/6/23 07:07, ye.xingchen@zte.com.cn wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
> 
> In Documentation/admin-guide/sysctl/vm.rst:109 say: when 1 is written
> to the file, all zones are compacted such that free memory is available
> in contiguous blocks where possible.
> So limit the value of interface compact_memory to 1.
> 
> Link: https://lore.kernel.org/all/ZAJwoXJCzfk1WIBx@bombadil.infradead.org/

I don't think the split to two patches you did, achieves Luis' request.

> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn>
> 
> ---
>  include/linux/compaction.h | 1 +
>  kernel/sysctl.c            | 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/compaction.h b/include/linux/compaction.h
> index 52a9ff65faee..caa24e33eeb1 100644
> --- a/include/linux/compaction.h
> +++ b/include/linux/compaction.h
> @@ -81,6 +81,7 @@ static inline unsigned long compact_gap(unsigned int order)
>  }
> 
>  #ifdef CONFIG_COMPACTION
> +extern int sysctl_compact_memory;
>  extern unsigned int sysctl_compaction_proactiveness;
>  extern int sysctl_compaction_handler(struct ctl_table *table, int write,
>  			void *buffer, size_t *length, loff_t *ppos);
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index c14552a662ae..67f70952f71a 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -2192,10 +2192,12 @@ static struct ctl_table vm_table[] = {
>  #ifdef CONFIG_COMPACTION
>  	{
>  		.procname	= "compact_memory",
> -		.data		= NULL,
> +		.data		= &sysctl_compact_memory,

I doubt this compiles/links without patch 2, as there's no definition
until patch 2.

>  		.maxlen		= sizeof(int),
>  		.mode		= 0200,
>  		.proc_handler	= sysctl_compaction_handler,
> +		.extra1		= SYSCTL_ONE,
> +		.extra2		= SYSCTL_ONE,
>  	},
>  	{
>  		.procname	= "compaction_proactiveness",

IIUC his request was to move the compaction entries out of sysctl.c?


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

* Re: [PATCH V2 1/2] sysctl: Limit the value of interface compact_memory
  2023-03-08 10:21 ` Vlastimil Babka
@ 2023-03-08 19:58   ` Luis Chamberlain
  0 siblings, 0 replies; 3+ messages in thread
From: Luis Chamberlain @ 2023-03-08 19:58 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: ye.xingchen, keescook, yzaikin, akpm, linmiaohe, chi.minghao,
	linux-kernel, linux-fsdevel, linux-mm

On Wed, Mar 08, 2023 at 11:21:36AM +0100, Vlastimil Babka wrote:
> 
> 
> On 3/6/23 07:07, ye.xingchen@zte.com.cn wrote:
> > From: Minghao Chi <chi.minghao@zte.com.cn>
> > 
> > In Documentation/admin-guide/sysctl/vm.rst:109 say: when 1 is written
> > to the file, all zones are compacted such that free memory is available
> > in contiguous blocks where possible.
> > So limit the value of interface compact_memory to 1.
> > 
> > Link: https://lore.kernel.org/all/ZAJwoXJCzfk1WIBx@bombadil.infradead.org/
> 
> I don't think the split to two patches you did, achieves Luis' request.
> 
> IIUC his request was to move the compaction entries out of sysctl.c?

Yes, thanks Vlastimil, just git log kernel/sysctl.c and you'll see tons
of examples.

  Luis

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

end of thread, other threads:[~2023-03-08 19:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-06  6:07 [PATCH V2 1/2] sysctl: Limit the value of interface compact_memory ye.xingchen
2023-03-08 10:21 ` Vlastimil Babka
2023-03-08 19:58   ` Luis Chamberlain

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