Skip to contentSkip to conversation

mm: compaction: move compaction sysctl to its own file

PATCH Superseded [email protected] 5 participants 9 messages Mar 22, 2023 – Mar 27, 2023

Subsystems (4)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/2 mm: compaction: move compaction sysctl to its own file

From: Minghao Chi <[email protected]>

This moves all compaction sysctls to its own file.

---
 include/linux/compaction.h |  7 ----
 kernel/sysctl.c            | 59 -----------------------------
 mm/compaction.c            | 77 ++++++++++++++++++++++++++++++++++----
 3 files changed, 69 insertions(+), 74 deletions(-)
include/linux/compaction.h +0 -7
index 52a9ff65faee..a6e512cfb670 100644
@@ -81,13 +81,6 @@ static inline unsigned long compact_gap(unsigned int order)
 }
 
 #ifdef CONFIG_COMPACTION
-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);
-extern int compaction_proactiveness_sysctl_handler(struct ctl_table *table,
-		int write, void *buffer, size_t *length, loff_t *ppos);
-extern int sysctl_extfrag_threshold;
-extern int sysctl_compact_unevictable_allowed;
 
 extern unsigned int extfrag_for_order(struct zone *zone, unsigned int order);
 extern int fragmentation_index(struct zone *zone, unsigned int order);
kernel/sysctl.c +0 -59

77 lines not on this page · raw message

mm/compaction.c +69 -8

125 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · On Wed, Mar 22, 2023 at 10:46:28AM +0800, [email protected] wrote:

From: Minghao Chi <[email protected]>

This moves all compaction sysctls to its own file.

So there's a whole lot of these 'move sysctrls to their own file' patches, but no actual explanation of why that is desirable. Please explain why we'd want to split code that is closely related, and now requires marking symbols non-static just to create a new tiny source file.

#2 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · On Wed, Mar 22, 2023 at 10:46:28AM +0800, [email protected] wrote:

From: Minghao Chi <[email protected]>

This moves all compaction sysctls to its own file.

So there's a whole lot of these 'move sysctrls to their own file' patches, but no actual explanation of why that is desirable. Please

I think Luis started this initiative, maybe he can provide the canonical reasoning :)

Quoted 3 lines

explain why we'd want to split code that is closely related, and now requires marking symbols non-static just to create a new tiny source file.

Hmm? I can see the opposite, at least in the compaction patch here. Related code and variables are moved closer together, made static, declarations removed from headers. It looks like an improvement to me.

#3 lore raw
Quoted 11 lines · Vlastimil Babka
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · On Wed, Mar 22, 2023 at 10:46:28AM +0800, [email protected] wrote:

From: Minghao Chi <[email protected]>

This moves all compaction sysctls to its own file.

So there's a whole lot of these 'move sysctrls to their own file' patches, but no actual explanation of why that is desirable. Please

I think Luis started this initiative, maybe he can provide the canonical reasoning :)

The kernel/sysctl.c is flooded now with commit log entries which describe a proper rationale, however some folks forget to also include similar rationale in new patches. I try to remind folks when I can, thanks for reminding them to continue to do that. That needs to be fixed in this patch. The summary is its hard to coordiante merge conflicts with all the syctls in one place, best to just put them where they are used.

There is a small hidden penalty increase in size to the kernel with the sysctls moves today though and one for which Matthew Wilcox has recently asked for us to pause these moves until we can save more memory. The extra memory is caused by the extra empty struct ctl_table added to the end of the new array. The way to avoid that penalty is to deprecate all APIs in sysctl registation which deal with complex array structures. I have some some of that addressed on my sysctl-next tree (and merged on linux-next) but much more work is required to deprecate the older APIs. I was ready to pause the kernel/sysctl.c moves until those APIs are deprecated and we start having sysctl APIs which allow us to not have the empty array at the end. But as I thought about this just now, the use cases that move the sysctls where __init is used could benefit already in size.

For this patch there seems to be a savings of 4 bytes:

$ ./scripts/bloat-o-meter vmlinux.old vmlinux
add/remove: 1/0 grow/shrink: 1/2 up/down: 346/-350 (-4)
Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               167     193     +26
proc_dointvec_minmax_warn_RT_change          104      10     -94
vm_table                                    2112    1856    -256
Total: Before=19287558, After=19287554, chg -0.00%

So I don't think we need to pause this move or others where are have savings.

Minghao, can you fix the commit log, and explain how you are also saving 4 bytes as per the above bloat-o-meter results?

Quoted 7 lines
Quoted 3 lines

explain why we'd want to split code that is closely related, and now requires marking symbols non-static just to create a new tiny source file.

Hmm? I can see the opposite, at least in the compaction patch here. Related code and variables are moved closer together, made static, declarations removed from headers. It looks like an improvement to me.

Glad this helps.

Luis

#4 lore raw
Quoted 9 lines
$ ./scripts/bloat-o-meter vmlinux.old vmlinux
add/remove: 1/0 grow/shrink: 1/2 up/down: 346/-350 (-4)
Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               167     193     +26
proc_dointvec_minmax_warn_RT_change          104      10     -94
vm_table                                    2112    1856    -256
Total: Before=19287558, After=19287554, chg -0.00%
Quoted 4 lines

So I don't think we need to pause this move or others where are have savings.

Minghao, can you fix the commit log, and explain how you are also saving 4 bytes as per the above bloat-o-meter results?

$ ./scripts/bloat-o-meter vmlinux vmlinux.new
add/remove: 1/0 grow/shrink: 1/1 up/down: 350/-256 (94)
Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               180     210     +30
vm_table                                    2112    1856    -256
Total: Before=21104198, After=21104292, chg +0.00%

In my environment, kcompactd_init increases by 30 instead of 26. And proc_dointvec_minmax_warn_RT_change No expansion.

minghao

#5 lore raw
Quoted 22 lines · ye xingchen
Quoted 9 lines
$ ./scripts/bloat-o-meter vmlinux.old vmlinux
add/remove: 1/0 grow/shrink: 1/2 up/down: 346/-350 (-4)
Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               167     193     +26
proc_dointvec_minmax_warn_RT_change          104      10     -94
vm_table                                    2112    1856    -256
Total: Before=19287558, After=19287554, chg -0.00%
Quoted 4 lines

So I don't think we need to pause this move or others where are have savings.

Minghao, can you fix the commit log, and explain how you are also saving 4 bytes as per the above bloat-o-meter results?

$ ./scripts/bloat-o-meter vmlinux vmlinux.new
add/remove: 1/0 grow/shrink: 1/1 up/down: 350/-256 (94)
Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               180     210     +30
vm_table                                    2112    1856    -256
Total: Before=21104198, After=21104292, chg +0.00%
Quoted 2 lines

In my environment, kcompactd_init increases by 30 instead of 26. And proc_dointvec_minmax_warn_RT_change No expansion.

How about a defconfig + compaction enabled? Provide that information and let Vlastimal ACK/NACK the patch.

Luis

#6 lore raw
Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
$ ./scripts/bloat-o-meter vmlinux.old vmlinux
add/remove: 1/0 grow/shrink: 1/2 up/down: 346/-350 (-4)
Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               167     193     +26
proc_dointvec_minmax_warn_RT_change          104      10     -94
vm_table                                    2112    1856    -256
Total: Before=19287558, After=19287554, chg -0.00%
Quoted 4 lines

So I don't think we need to pause this move or others where are have savings.

Minghao, can you fix the commit log, and explain how you are also saving 4 bytes as per the above bloat-o-meter results?

$ ./scripts/bloat-o-meter vmlinux vmlinux.new
add/remove: 1/0 grow/shrink: 1/1 up/down: 350/-256 (94)
Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               180     210     +30
vm_table                                    2112    1856    -256
Total: Before=21104198, After=21104292, chg +0.00%
Quoted 5 lines
Quoted 2 lines

In my environment, kcompactd_init increases by 30 instead of 26. And proc_dointvec_minmax_warn_RT_change No expansion.

How about a defconfig + compaction enabled? Provide that information and let Vlastimal ACK/NACK the patch.

I use x86_defconfig and linux-next-20230327 branch

$ make defconfig;make all -j120
CONFIG_COMPACTION=y

add/remove: 1/0 grow/shrink: 1/1 up/down: 350/-256 (94)

Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               180     210     +30

vm_table 2112 1856 -256
Total: Before=21119987, After=21120081, chg +0.00%

#7 lore raw
Quoted 31 lines · ye xingchen
Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
$ ./scripts/bloat-o-meter vmlinux.old vmlinux
add/remove: 1/0 grow/shrink: 1/2 up/down: 346/-350 (-4)
Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               167     193     +26
proc_dointvec_minmax_warn_RT_change          104      10     -94
vm_table                                    2112    1856    -256
Total: Before=19287558, After=19287554, chg -0.00%
Quoted 4 lines

So I don't think we need to pause this move or others where are have savings.

Minghao, can you fix the commit log, and explain how you are also saving 4 bytes as per the above bloat-o-meter results?

$ ./scripts/bloat-o-meter vmlinux vmlinux.new
add/remove: 1/0 grow/shrink: 1/1 up/down: 350/-256 (94)
Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               180     210     +30
vm_table                                    2112    1856    -256
Total: Before=21104198, After=21104292, chg +0.00%
Quoted 5 lines
Quoted 2 lines

In my environment, kcompactd_init increases by 30 instead of 26. And proc_dointvec_minmax_warn_RT_change No expansion.

How about a defconfig + compaction enabled? Provide that information and let Vlastimal ACK/NACK the patch.

I use x86_defconfig and linux-next-20230327 branch

$ make defconfig;make all -j120
CONFIG_COMPACTION=y
Quoted 6 lines

add/remove: 1/0 grow/shrink: 1/1 up/down: 350/-256 (94)

Function                                     old     new   delta
vm_compaction                                  -     320    +320
kcompactd_init                               180     210     +30

vm_table 2112 1856 -256
Total: Before=21119987, After=21120081, chg +0.00%

No savings then, but to me the patch still seems a worthwile cleanup. But if others think the 94 bytes are an issue, it can wait for the new APIs.