|
@@ -1351,12 +1351,48 @@ static int inactive_anon_is_low(struct zone *zone, struct scan_control *sc)
|
|
return low;
|
|
return low;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int inactive_file_is_low_global(struct zone *zone)
|
|
|
|
+{
|
|
|
|
+ unsigned long active, inactive;
|
|
|
|
+
|
|
|
|
+ active = zone_page_state(zone, NR_ACTIVE_FILE);
|
|
|
|
+ inactive = zone_page_state(zone, NR_INACTIVE_FILE);
|
|
|
|
+
|
|
|
|
+ return (active > inactive);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * inactive_file_is_low - check if file pages need to be deactivated
|
|
|
|
+ * @zone: zone to check
|
|
|
|
+ * @sc: scan control of this context
|
|
|
|
+ *
|
|
|
|
+ * When the system is doing streaming IO, memory pressure here
|
|
|
|
+ * ensures that active file pages get deactivated, until more
|
|
|
|
+ * than half of the file pages are on the inactive list.
|
|
|
|
+ *
|
|
|
|
+ * Once we get to that situation, protect the system's working
|
|
|
|
+ * set from being evicted by disabling active file page aging.
|
|
|
|
+ *
|
|
|
|
+ * This uses a different ratio than the anonymous pages, because
|
|
|
|
+ * the page cache uses a use-once replacement algorithm.
|
|
|
|
+ */
|
|
|
|
+static int inactive_file_is_low(struct zone *zone, struct scan_control *sc)
|
|
|
|
+{
|
|
|
|
+ int low;
|
|
|
|
+
|
|
|
|
+ if (scanning_global_lru(sc))
|
|
|
|
+ low = inactive_file_is_low_global(zone);
|
|
|
|
+ else
|
|
|
|
+ low = mem_cgroup_inactive_file_is_low(sc->mem_cgroup);
|
|
|
|
+ return low;
|
|
|
|
+}
|
|
|
|
+
|
|
static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
|
|
static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
|
|
struct zone *zone, struct scan_control *sc, int priority)
|
|
struct zone *zone, struct scan_control *sc, int priority)
|
|
{
|
|
{
|
|
int file = is_file_lru(lru);
|
|
int file = is_file_lru(lru);
|
|
|
|
|
|
- if (lru == LRU_ACTIVE_FILE) {
|
|
|
|
|
|
+ if (lru == LRU_ACTIVE_FILE && inactive_file_is_low(zone, sc)) {
|
|
shrink_active_list(nr_to_scan, zone, sc, priority, file);
|
|
shrink_active_list(nr_to_scan, zone, sc, priority, file);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|