mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
mm: compaction: add a tunable that decides when memory should be compacted and when it should be reclaimed
The kernel applies some heuristics when deciding if memory should be compacted or reclaimed to satisfy a high-order allocation. One of these is based on the fragmentation. If the index is below 500, memory will not be compacted. This choice is arbitrary and not based on data. To help optimise the system and set a sensible default for this value, this patch adds a sysctl extfrag_threshold. The kernel will only compact memory if the fragmentation index is above the extfrag_threshold. [[email protected]: Fix build errors when proc fs is not configured] Signed-off-by: Mel Gorman <[email protected]> Signed-off-by: Randy Dunlap <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Minchan Kim <[email protected]> Cc: KOSAKI Motohiro <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
56de7263fc
commit
5e77190580
4 changed files with 44 additions and 1 deletions
|
|
@ -433,6 +433,8 @@ static unsigned long compact_zone_order(struct zone *zone,
|
|||
return compact_zone(zone, &cc);
|
||||
}
|
||||
|
||||
int sysctl_extfrag_threshold = 500;
|
||||
|
||||
/**
|
||||
* try_to_compact_pages - Direct compact to satisfy a high-order allocation
|
||||
* @zonelist: The zonelist used for the current allocation
|
||||
|
|
@ -491,7 +493,7 @@ unsigned long try_to_compact_pages(struct zonelist *zonelist,
|
|||
* Only compact if a failure would be due to fragmentation.
|
||||
*/
|
||||
fragindex = fragmentation_index(zone, order);
|
||||
if (fragindex >= 0 && fragindex <= 500)
|
||||
if (fragindex >= 0 && fragindex <= sysctl_extfrag_threshold)
|
||||
continue;
|
||||
|
||||
if (fragindex == -1 && zone_watermark_ok(zone, order, watermark, 0, 0)) {
|
||||
|
|
@ -572,6 +574,14 @@ int sysctl_compaction_handler(struct ctl_table *table, int write,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sysctl_extfrag_handler(struct ctl_table *table, int write,
|
||||
void __user *buffer, size_t *length, loff_t *ppos)
|
||||
{
|
||||
proc_dointvec_minmax(table, write, buffer, length, ppos);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
|
||||
ssize_t sysfs_compact_node(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
|
|
|
|||
Loading…
Reference in a new issue