* [PATCH V3 2/2] mm: compaction: limit illegal input parameters of compact_memory interface
@ 2023-03-09 3:42 ye.xingchen
2023-03-09 3:56 ` Luis Chamberlain
0 siblings, 1 reply; 4+ messages in thread
From: ye.xingchen @ 2023-03-09 3:42 UTC (permalink / raw)
To: mcgrof; +Cc: keescook, yzaikin, akpm, linux-kernel, linux-fsdevel, linux-mm
From: Minghao Chi <chi.minghao@zte.com.cn>
Available only when CONFIG_COMPACTION is set. When 1 is written to
the file, all zones are compacted such that free memory is available
in contiguous blocks where possible.
But echo others-parameter > compact_memory, this function will be
triggered by writing parameters to the interface.
Applied this patch,
sh/$ echo 1.1 > /proc/sys/vm/compact_memory
sh/$ sh: write error: Invalid argument
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>
---
mm/compaction.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/mm/compaction.c b/mm/compaction.c
index acbda28c11f4..39f4c8a6f843 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -2762,15 +2762,18 @@ int compaction_proactiveness_sysctl_handler(struct ctl_table *table, int write,
return 0;
}
+static int sysctl_compact_memory;
#ifdef CONFIG_SYSCTL
static struct ctl_table vm_compact_memory[] = {
{
.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,
},
{ }
};
@@ -2782,6 +2785,11 @@ static struct ctl_table vm_compact_memory[] = {
int sysctl_compaction_handler(struct ctl_table *table, int write,
void *buffer, size_t *length, loff_t *ppos)
{
+ int ret;
+
+ ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
+ if (ret)
+ return ret;
if (write)
compact_nodes();
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V3 2/2] mm: compaction: limit illegal input parameters of compact_memory interface
2023-03-09 3:42 [PATCH V3 2/2] mm: compaction: limit illegal input parameters of compact_memory interface ye.xingchen
@ 2023-03-09 3:56 ` Luis Chamberlain
2023-03-09 6:58 ` Luis Chamberlain
2023-03-10 1:54 ` ye xingchen
0 siblings, 2 replies; 4+ messages in thread
From: Luis Chamberlain @ 2023-03-09 3:56 UTC (permalink / raw)
To: ye.xingchen
Cc: keescook, yzaikin, akpm, linux-kernel, linux-fsdevel, linux-mm
On Thu, Mar 09, 2023 at 11:42:58AM +0800, ye.xingchen@zte.com.cn wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
>
> Available only when CONFIG_COMPACTION is set. When 1 is written to
> the file, all zones are compacted such that free memory is available
> in contiguous blocks where possible.
> But echo others-parameter > compact_memory, this function will be
> triggered by writing parameters to the interface.
>
> Applied this patch,
> sh/$ echo 1.1 > /proc/sys/vm/compact_memory
> sh/$ sh: write error: Invalid argument
Didn't echo 2 > /proc/sys/vm/compact_memory used to work too?
Why kill that? Did the docs say only 1 was possible? If not
perhaps the docs need to be updated?
Luis
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V3 2/2] mm: compaction: limit illegal input parameters of compact_memory interface
2023-03-09 3:56 ` Luis Chamberlain
@ 2023-03-09 6:58 ` Luis Chamberlain
2023-03-10 1:54 ` ye xingchen
1 sibling, 0 replies; 4+ messages in thread
From: Luis Chamberlain @ 2023-03-09 6:58 UTC (permalink / raw)
To: ye.xingchen
Cc: Kees Cook, Iurii Zaikin, Andrew Morton, linux-kernel,
Linux FS Devel, linux-mm, Vlastimil Babka
[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]
Actually, it seems odd to use a min setting and configure it to map to
SYSCTL_ONE to SYSCTL_ONE so just a SYCTL_$(type)_MAX or just the type max
would be better and not break old userspace.
On Wed, Mar 8, 2023, 7:56 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
> On Thu, Mar 09, 2023 at 11:42:58AM +0800, ye.xingchen@zte.com.cn wrote:
> > From: Minghao Chi <chi.minghao@zte.com.cn>
> >
> > Available only when CONFIG_COMPACTION is set. When 1 is written to
> > the file, all zones are compacted such that free memory is available
> > in contiguous blocks where possible.
> > But echo others-parameter > compact_memory, this function will be
> > triggered by writing parameters to the interface.
> >
> > Applied this patch,
> > sh/$ echo 1.1 > /proc/sys/vm/compact_memory
> > sh/$ sh: write error: Invalid argument
>
> Didn't echo 2 > /proc/sys/vm/compact_memory used to work too?
>
> Why kill that? Did the docs say only 1 was possible? If not
> perhaps the docs need to be updated?
>
> Luis
>
>
[-- Attachment #2: Type: text/html, Size: 1532 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V3 2/2] mm: compaction: limit illegal input parameters of compact_memory interface
2023-03-09 3:56 ` Luis Chamberlain
2023-03-09 6:58 ` Luis Chamberlain
@ 2023-03-10 1:54 ` ye xingchen
1 sibling, 0 replies; 4+ messages in thread
From: ye xingchen @ 2023-03-10 1:54 UTC (permalink / raw)
To: mcgrof
Cc: akpm, keescook, linux-fsdevel, linux-kernel, linux-mm,
ye.xingchen, yzaikin, chi.minghao
>> From: Minghao Chi <chi.minghao@zte.com.cn>
>>
>> Available only when CONFIG_COMPACTION is set. When 1 is written to
>> the file, all zones are compacted such that free memory is available
>> in contiguous blocks where possible.
>> But echo others-parameter > compact_memory, this function will be
>> triggered by writing parameters to the interface.
>>
>> Applied this patch,
>> sh/$ echo 1.1 > /proc/sys/vm/compact_memory
>> sh/$ sh: write error: Invalid argument
>
>Didn't echo 2 > /proc/sys/vm/compact_memory used to work too?
yes
>
>Why kill that? Did the docs say only 1 was possible? If not
>perhaps the docs need to be updated?
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.
Chi, and Ye
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-10 1:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 3:42 [PATCH V3 2/2] mm: compaction: limit illegal input parameters of compact_memory interface ye.xingchen
2023-03-09 3:56 ` Luis Chamberlain
2023-03-09 6:58 ` Luis Chamberlain
2023-03-10 1:54 ` ye xingchen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox