Skip to content

Instantly share code, notes, and snippets.

@christian-marie
Created November 12, 2014 10:26
Show Gist options
  • Save christian-marie/cf7d5934b3d89702946c to your computer and use it in GitHub Desktop.
Save christian-marie/cf7d5934b3d89702946c to your computer and use it in GitHub Desktop.
diff -uNr kernel-3.10.0-123.el7/linux-3.10.0-123.el7.x86_64/include/trace/events/vmscan.h kernel-3.10.0-123.el7p/linux-3.10.0-123.el7.x86_64/include/trace/events/vmscan.h
--- a/include/trace/events/vmscan.h 2014-05-05 14:58:32.000000000 +0000
+++ b/include/trace/events/vmscan.h 2014-11-12 00:07:59.193842097 +0000
@@ -36,6 +36,25 @@
(RECLAIM_WB_ASYNC) \
)
+TRACE_EVENT(mm_vmscan_frob,
+
+ TP_PROTO(unsigned long zonefile, unsigned long zonefree),
+
+ TP_ARGS(zonefile, zonefree),
+
+ TP_STRUCT__entry(
+ __field( unsigned long, zonefile )
+ __field( unsigned long, zonefree )
+ ),
+
+ TP_fast_assign(
+ __entry->zonefile = zonefile;
+ __entry->zonefree = zonefree;
+ ),
+
+ TP_printk("file=%lu free =%lu", __entry->zonefile, __entry->zonefree)
+);
+
TRACE_EVENT(mm_vmscan_kswapd_sleep,
TP_PROTO(int nid),
diff -uNr kernel-3.10.0-123.el7/linux-3.10.0-123.el7.x86_64/mm/vmscan.c kernel-3.10.0-123.el7p/linux-3.10.0-123.el7.x86_64/mm/vmscan.c
--- a/mm/vmscan.c 2014-05-05 14:58:32.000000000 +0000
+++ b/mm/vmscan.c 2014-11-12 00:08:00.754875382 +0000
@@ -1857,6 +1857,30 @@
goto out;
}
+ /*
+ * Prevent the reclaimer from falling into the cache trap: as
+ * cache pages start out inactive, every cache fault will tip
+ * the scan balance towards the file LRU. And as the file LRU
+ * shrinks, so does the window for rotation from references.
+ * This means we have a runaway feedback loop where a tiny
+ * thrashing file LRU becomes infinitely more attractive than
+ * anon pages. Try to detect this based on file LRU size.
+ */
+ if (global_reclaim(sc)) {
+ unsigned long zonefile;
+ unsigned long zonefree;
+
+ zonefree = zone_page_state(zone, NR_FREE_PAGES);
+ zonefile = zone_page_state(zone, NR_ACTIVE_FILE) +
+ zone_page_state(zone, NR_INACTIVE_FILE);
+
+ if (unlikely(zonefile + zonefree <= high_wmark_pages(zone))) {
+ trace_mm_vmscan_frob(zonefree, zonefile);
+ scan_balance = SCAN_ANON;
+ goto out;
+ }
+ }
+
anon = get_lru_size(lruvec, LRU_ACTIVE_ANON) +
get_lru_size(lruvec, LRU_INACTIVE_ANON);
file = get_lru_size(lruvec, LRU_ACTIVE_FILE) +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment