mm: setting of min_free_kbytes
Subsystems (2)
cover mm: setting of min_free_kbytes
Hi,
While updating a workload to a 4.1 kernel (from 3.14), I found that min_free_kbytes was automatically set to 11365, whereas on 3.14 it was 67584. This is caused by a change to how min_free_kbytes is set when CONFIG_TRANSPARENT_HUGEPAGE=y, which is detailed in the patch that follows.
I was wondering as well if the setting of min_free_kbytes could be improved in the following cases while looking at this code:
1) memory hotplug
we call init_per_zone_wmark_min() but notset_recommended_min_free_kbytes() (for hugepages)
2) when khugepaged is stopped
Do we want to undo any settings thath khugepaged has done in that case to restore the default settings
Thanks,
-Jason
Jason Baron (1):
mm: update min_free_kbytes from khugepaged after core initialization
mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 7 lines
2.6.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 mm: update min_free_kbytes from khugepaged after core initialization
Khugepaged attempts to raise min_free_kbytes if its set too low. However, on boot khugepaged sets min_free_kbytes first from subsys_initcall(), and then the mm 'core' over-rides min_free_kbytes after from init_per_zone_wmark_min(), via a module_init() call.
Khugepaged used to use a late_initcall() to set min_free_kbytes (such that it occurred after the core initialization), however this was removed when the initialization of min_free_kbytes was integrated into the starting of the khugepaged thread.
The fix here is simply to invoke the core initialization using a core_initcall() instead of module_init(), such that the previous initialization ordering is restored. I didn't restore the late_initcall() since start_stop_khugepaged() already sets min_free_kbytes via set_recommended_min_free_kbytes().
This was noticed when we had a number of page allocation failures when moving a workload to a kernel with this new initialization ordering. On an 8GB system this restores min_free_kbytes back to 67584 from 11365 when CONFIG_TRANSPARENT_HUGEPAGE=y is set and either CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y or CONFIG_TRANSPARENT_HUGEPAGE_MADVISE=y.
--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
@@ -6485,7 +6485,7 @@ int __meminit init_per_zone_wmark_min(void)setup_per_zone_inactive_ratio ();return 0 ; } -module_init (init_per_zone_wmark_min) +core_initcall (init_per_zone_wmark_min)/* * min_free_kbytes_sysctl_handler - just a wrapper around proc_dointvec() so
Signature · 7 lines
2.6.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 1/1] mm: update min_free_kbytes from khugepaged after core initialization
Quoted 23 lines · Jason Baron
Khugepaged attempts to raise
min_free_kbytesif its set too low. However, on boot khugepaged setsmin_free_kbytesfirst fromsubsys_initcall(), and then the mm 'core' over-ridesmin_free_kbytesafter frominit_per_zone_wmark_min(), via amodule_init()call.Khugepaged used to use a
late_initcall()to setmin_free_kbytes(such that it occurred after the core initialization), however this was removed when the initialization ofmin_free_kbyteswas integrated into the starting of the khugepaged thread.The fix here is simply to invoke the core initialization using a
core_initcall()instead ofmodule_init(), such that the previous initialization ordering is restored. I didn't restore thelate_initcall()sincestart_stop_khugepaged()already setsmin_free_kbytesviaset_recommended_min_free_kbytes().This was noticed when we had a number of page allocation failures when moving a workload to a kernel with this new initialization ordering. On an 8GB system this restores
min_free_kbytesback to 67584 from 11365 whenCONFIG_TRANSPARENT_HUGEPAGE=yis set and eitherCONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=yorCONFIG_TRANSPARENT_HUGEPAGE_MADVISE=y.
Quoted 2 lines
Fixes 79553da293d3 ("thp: cleanup khugepaged startup")Signed-off-by Jason Baron <[email protected]>
Looks good to me:
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 1/1] mm: update min_free_kbytes from khugepaged after core initialization
In reply to Jason BaronQuoted 23 lines · Jason Baron
Khugepaged attempts to raise
min_free_kbytesif its set too low. However, on boot khugepaged setsmin_free_kbytesfirst fromsubsys_initcall(), and then the mm 'core' over-ridesmin_free_kbytesafter frominit_per_zone_wmark_min(), via amodule_init()call.Khugepaged used to use a
late_initcall()to setmin_free_kbytes(such that it occurred after the core initialization), however this was removed when the initialization ofmin_free_kbyteswas integrated into the starting of the khugepaged thread.The fix here is simply to invoke the core initialization using a
core_initcall()instead ofmodule_init(), such that the previous initialization ordering is restored. I didn't restore thelate_initcall()sincestart_stop_khugepaged()already setsmin_free_kbytesviaset_recommended_min_free_kbytes().This was noticed when we had a number of page allocation failures when moving a workload to a kernel with this new initialization ordering. On an 8GB system this restores
min_free_kbytesback to 67584 from 11365 whenCONFIG_TRANSPARENT_HUGEPAGE=yis set and eitherCONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=yorCONFIG_TRANSPARENT_HUGEPAGE_MADVISE=y.
Quoted 2 lines
Fixes 79553da293d3 ("thp: cleanup khugepaged startup")Signed-off-by Jason Baron <[email protected]>
I assume it could also be fixed by not setting min_free_kbytes lower in init_per_zone_wmark_min(), but if the ordering is correct this is less code.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>