diff --git a/patch/kernel/sun8i-default/fix-kswapd.patch b/patch/kernel/sun8i-default/fix-kswapd.patch new file mode 100644 index 0000000000..b10926c031 --- /dev/null +++ b/patch/kernel/sun8i-default/fix-kswapd.patch @@ -0,0 +1,73 @@ +diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h +index a2bbaef..06f8e38 100644 +--- a/include/linux/vm_event_item.h ++++ b/include/linux/vm_event_item.h +@@ -35,6 +35,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, + #endif + PGINODESTEAL, SLABS_SCANNED, KSWAPD_INODESTEAL, + KSWAPD_LOW_WMARK_HIT_QUICKLY, KSWAPD_HIGH_WMARK_HIT_QUICKLY, ++ KSWAPD_SKIP_CONGESTION_WAIT, + PAGEOUTRUN, ALLOCSTALL, PGROTATED, + #ifdef CONFIG_COMPACTION + COMPACTBLOCKS, COMPACTPAGES, COMPACTPAGEFAILED, +diff --git a/mm/vmstat.c b/mm/vmstat.c +index 1de03bf..1034ebc 100644 +--- a/mm/vmstat.c ++++ b/mm/vmstat.c +@@ -758,6 +758,7 @@ const char * const vmstat_text[] = { + "kswapd_inodesteal", + "kswapd_low_wmark_hit_quickly", + "kswapd_high_wmark_hit_quickly", ++ "kswapd_skip_congestion_wait", + "pageoutrun", + "allocstall", + +diff --git a/mm/vmscan.c b/mm/vmscan.c +index db61d7f..d6b0e39 100755 +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -2782,6 +2782,7 @@ loop_again: + + for (priority = DEF_PRIORITY; priority >= 0; priority--) { + unsigned long lru_pages = 0; ++ int has_under_min_watermark_zone = 0; + + /* The swap token gets in the way of swapout... */ + if (!priority) +@@ -2923,7 +2924,17 @@ loop_again: + continue; + } + +- if (zone_balanced(zone, testorder, 0, end_zone)) { ++ if (!zone_balanced(zone, testorder, 0, end_zone)) { ++ all_zones_ok = 0; ++ /* ++ * We are still under min water mark. This ++ * means that we have a GFP_ATOMIC allocation ++ * failure risk. Hurry up! ++ */ ++ if (!zone_watermark_ok_safe(zone, order, ++ min_wmark_pages(zone), end_zone, 0)) ++ has_under_min_watermark_zone = 1; ++ } else { + /* + * If a zone reaches its high watermark, + * consider it to be no longer congested. It's +@@ -2940,6 +2951,17 @@ loop_again: + if (all_zones_ok || (order && pgdat_balanced(pgdat, balanced, *classzone_idx))) + break; /* kswapd: all done */ + /* ++ * OK, kswapd is getting into trouble. Take a nap, then take ++ * another pass across the zones. ++ */ ++ if (total_scanned && (priority < DEF_PRIORITY - 2)) { ++ if (has_under_min_watermark_zone) ++ count_vm_event(KSWAPD_SKIP_CONGESTION_WAIT); ++ else ++ congestion_wait(BLK_RW_ASYNC, HZ/10); ++ } ++ ++ /* + * We do this so kswapd doesn't build up large priorities for + * example when it is freeing in parallel with allocators. It + * matches the direct reclaim path behaviour in terms of impact diff --git a/scripts/update-motd.d/30-sysinfo b/scripts/update-motd.d/30-sysinfo index 8fed4863db..3c9fdcca75 100644 --- a/scripts/update-motd.d/30-sysinfo +++ b/scripts/update-motd.d/30-sysinfo @@ -89,7 +89,7 @@ users=$(users | wc -w) swap_total=$(free -m | awk '/Swap/ { printf("%3.0f", $3/$2*100) }' | sed 's/ //g') swap_usage=${swap_usage//[!0-9]/} # to remove alfanumeric if swap not used swap_total=$(free -m | awk '/Swap/ {print $(2)}') -ip_address=$(hostname -I | tail -1) +ip_address=$(hostname -I | tr " " "\n" | grep -E "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" | tail -n2 | tr "\n" " ") root_usage=$(df -h / | awk '/\// {print $(NF-1)}' | sed 's/%//g') root_total=$(df -h / | awk '/\// {print $(NF-4)}') if [ -e "$storage" ]; then