vmscan.c (a9dd0a83104c01269ea36a9b4ec42b51edf85427) vmscan.c (ef8f2327996b5c20f11420f64e439e87c7a01604)
1/*
2 * linux/mm/vmscan.c
3 *
4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
5 *
6 * Swap reorganised 29.12.95, Stephen Tweedie.
7 * kswapd added: 7.1.96 sct
8 * Removed kswapd_ctl limits, and swap out as many pages as needed

--- 2215 unchanged lines hidden (view full) ---

2224#endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */
2225
2226/*
2227 * This is a basic per-node page freer. Used by both kswapd and direct reclaim.
2228 */
2229static void shrink_node_memcg(struct pglist_data *pgdat, struct mem_cgroup *memcg,
2230 struct scan_control *sc, unsigned long *lru_pages)
2231{
1/*
2 * linux/mm/vmscan.c
3 *
4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
5 *
6 * Swap reorganised 29.12.95, Stephen Tweedie.
7 * kswapd added: 7.1.96 sct
8 * Removed kswapd_ctl limits, and swap out as many pages as needed

--- 2215 unchanged lines hidden (view full) ---

2224#endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */
2225
2226/*
2227 * This is a basic per-node page freer. Used by both kswapd and direct reclaim.
2228 */
2229static void shrink_node_memcg(struct pglist_data *pgdat, struct mem_cgroup *memcg,
2230 struct scan_control *sc, unsigned long *lru_pages)
2231{
2232 struct zone *zone = &pgdat->node_zones[sc->reclaim_idx];
2233 struct lruvec *lruvec = mem_cgroup_lruvec(pgdat, zone, memcg);
2232 struct lruvec *lruvec = mem_cgroup_lruvec(pgdat, memcg);
2234 unsigned long nr[NR_LRU_LISTS];
2235 unsigned long targets[NR_LRU_LISTS];
2236 unsigned long nr_to_scan;
2237 enum lru_list lru;
2238 unsigned long nr_reclaimed = 0;
2239 unsigned long nr_to_reclaim = sc->nr_to_reclaim;
2240 struct blk_plug plug;
2241 bool scan_adjusted;

--- 192 unchanged lines hidden (view full) ---

2434{
2435 struct reclaim_state *reclaim_state = current->reclaim_state;
2436 unsigned long nr_reclaimed, nr_scanned;
2437 bool reclaimable = false;
2438
2439 do {
2440 struct mem_cgroup *root = sc->target_mem_cgroup;
2441 struct mem_cgroup_reclaim_cookie reclaim = {
2233 unsigned long nr[NR_LRU_LISTS];
2234 unsigned long targets[NR_LRU_LISTS];
2235 unsigned long nr_to_scan;
2236 enum lru_list lru;
2237 unsigned long nr_reclaimed = 0;
2238 unsigned long nr_to_reclaim = sc->nr_to_reclaim;
2239 struct blk_plug plug;
2240 bool scan_adjusted;

--- 192 unchanged lines hidden (view full) ---

2433{
2434 struct reclaim_state *reclaim_state = current->reclaim_state;
2435 unsigned long nr_reclaimed, nr_scanned;
2436 bool reclaimable = false;
2437
2438 do {
2439 struct mem_cgroup *root = sc->target_mem_cgroup;
2440 struct mem_cgroup_reclaim_cookie reclaim = {
2442 .zone = &pgdat->node_zones[classzone_idx],
2441 .pgdat = pgdat,
2443 .priority = sc->priority,
2444 };
2445 unsigned long node_lru_pages = 0;
2446 struct mem_cgroup *memcg;
2447
2448 nr_reclaimed = sc->nr_reclaimed;
2449 nr_scanned = sc->nr_scanned;
2450

--- 191 unchanged lines hidden (view full) ---

2642
2643 /*
2644 * This steals pages from memory cgroups over softlimit
2645 * and returns the number of reclaimed pages and
2646 * scanned pages. This works for global memory pressure
2647 * and balancing, not for a memcg's limit.
2648 */
2649 nr_soft_scanned = 0;
2442 .priority = sc->priority,
2443 };
2444 unsigned long node_lru_pages = 0;
2445 struct mem_cgroup *memcg;
2446
2447 nr_reclaimed = sc->nr_reclaimed;
2448 nr_scanned = sc->nr_scanned;
2449

--- 191 unchanged lines hidden (view full) ---

2641
2642 /*
2643 * This steals pages from memory cgroups over softlimit
2644 * and returns the number of reclaimed pages and
2645 * scanned pages. This works for global memory pressure
2646 * and balancing, not for a memcg's limit.
2647 */
2648 nr_soft_scanned = 0;
2650 nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone,
2649 nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone->zone_pgdat,
2651 sc->order, sc->gfp_mask,
2652 &nr_soft_scanned);
2653 sc->nr_reclaimed += nr_soft_reclaimed;
2654 sc->nr_scanned += nr_soft_scanned;
2655 /* need some check for avoid more shrink_zone() */
2656 }
2657
2658 /* See comment about same check for global reclaim above */

--- 253 unchanged lines hidden (view full) ---

2912
2913 return nr_reclaimed;
2914}
2915
2916#ifdef CONFIG_MEMCG
2917
2918unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg,
2919 gfp_t gfp_mask, bool noswap,
2650 sc->order, sc->gfp_mask,
2651 &nr_soft_scanned);
2652 sc->nr_reclaimed += nr_soft_reclaimed;
2653 sc->nr_scanned += nr_soft_scanned;
2654 /* need some check for avoid more shrink_zone() */
2655 }
2656
2657 /* See comment about same check for global reclaim above */

--- 253 unchanged lines hidden (view full) ---

2911
2912 return nr_reclaimed;
2913}
2914
2915#ifdef CONFIG_MEMCG
2916
2917unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg,
2918 gfp_t gfp_mask, bool noswap,
2920 struct zone *zone,
2919 pg_data_t *pgdat,
2921 unsigned long *nr_scanned)
2922{
2923 struct scan_control sc = {
2924 .nr_to_reclaim = SWAP_CLUSTER_MAX,
2925 .target_mem_cgroup = memcg,
2926 .may_writepage = !laptop_mode,
2927 .may_unmap = 1,
2928 .reclaim_idx = MAX_NR_ZONES - 1,

--- 10 unchanged lines hidden (view full) ---

2939
2940 /*
2941 * NOTE: Although we can get the priority field, using it
2942 * here is not a good idea, since it limits the pages we can scan.
2943 * if we don't reclaim here, the shrink_node from balance_pgdat
2944 * will pick up pages from other mem cgroup's as well. We hack
2945 * the priority and make it zero.
2946 */
2920 unsigned long *nr_scanned)
2921{
2922 struct scan_control sc = {
2923 .nr_to_reclaim = SWAP_CLUSTER_MAX,
2924 .target_mem_cgroup = memcg,
2925 .may_writepage = !laptop_mode,
2926 .may_unmap = 1,
2927 .reclaim_idx = MAX_NR_ZONES - 1,

--- 10 unchanged lines hidden (view full) ---

2938
2939 /*
2940 * NOTE: Although we can get the priority field, using it
2941 * here is not a good idea, since it limits the pages we can scan.
2942 * if we don't reclaim here, the shrink_node from balance_pgdat
2943 * will pick up pages from other mem cgroup's as well. We hack
2944 * the priority and make it zero.
2945 */
2947 shrink_node_memcg(zone->zone_pgdat, memcg, &sc, &lru_pages);
2946 shrink_node_memcg(pgdat, memcg, &sc, &lru_pages);
2948
2949 trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed);
2950
2951 *nr_scanned = sc.nr_scanned;
2952 return sc.nr_reclaimed;
2953}
2954
2955unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,

--- 33 unchanged lines hidden (view full) ---

2989
2990 trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed);
2991
2992 return nr_reclaimed;
2993}
2994#endif
2995
2996static void age_active_anon(struct pglist_data *pgdat,
2947
2948 trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed);
2949
2950 *nr_scanned = sc.nr_scanned;
2951 return sc.nr_reclaimed;
2952}
2953
2954unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,

--- 33 unchanged lines hidden (view full) ---

2988
2989 trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed);
2990
2991 return nr_reclaimed;
2992}
2993#endif
2994
2995static void age_active_anon(struct pglist_data *pgdat,
2997 struct zone *zone, struct scan_control *sc)
2996 struct scan_control *sc)
2998{
2999 struct mem_cgroup *memcg;
3000
3001 if (!total_swap_pages)
3002 return;
3003
3004 memcg = mem_cgroup_iter(NULL, NULL, NULL);
3005 do {
2997{
2998 struct mem_cgroup *memcg;
2999
3000 if (!total_swap_pages)
3001 return;
3002
3003 memcg = mem_cgroup_iter(NULL, NULL, NULL);
3004 do {
3006 struct lruvec *lruvec = mem_cgroup_lruvec(pgdat, zone, memcg);
3005 struct lruvec *lruvec = mem_cgroup_lruvec(pgdat, memcg);
3007
3008 if (inactive_list_is_low(lruvec, false))
3009 shrink_active_list(SWAP_CLUSTER_MAX, lruvec,
3010 sc, LRU_ACTIVE_ANON);
3011
3012 memcg = mem_cgroup_iter(NULL, memcg, NULL);
3013 } while (memcg);
3014}

--- 173 unchanged lines hidden (view full) ---

3188 }
3189
3190 /*
3191 * Do some background aging of the anon list, to give
3192 * pages a chance to be referenced before reclaiming. All
3193 * pages are rotated regardless of classzone as this is
3194 * about consistent aging.
3195 */
3006
3007 if (inactive_list_is_low(lruvec, false))
3008 shrink_active_list(SWAP_CLUSTER_MAX, lruvec,
3009 sc, LRU_ACTIVE_ANON);
3010
3011 memcg = mem_cgroup_iter(NULL, memcg, NULL);
3012 } while (memcg);
3013}

--- 173 unchanged lines hidden (view full) ---

3187 }
3188
3189 /*
3190 * Do some background aging of the anon list, to give
3191 * pages a chance to be referenced before reclaiming. All
3192 * pages are rotated regardless of classzone as this is
3193 * about consistent aging.
3194 */
3196 age_active_anon(pgdat, &pgdat->node_zones[MAX_NR_ZONES - 1], &sc);
3195 age_active_anon(pgdat, &sc);
3197
3198 /*
3199 * If we're getting trouble reclaiming, start doing writepage
3200 * even in laptop mode.
3201 */
3202 if (sc.priority < DEF_PRIORITY - 2 || !pgdat_reclaimable(pgdat))
3203 sc.may_writepage = 1;
3204
3205 /* Call soft limit reclaim before calling shrink_node. */
3206 sc.nr_scanned = 0;
3207 nr_soft_scanned = 0;
3196
3197 /*
3198 * If we're getting trouble reclaiming, start doing writepage
3199 * even in laptop mode.
3200 */
3201 if (sc.priority < DEF_PRIORITY - 2 || !pgdat_reclaimable(pgdat))
3202 sc.may_writepage = 1;
3203
3204 /* Call soft limit reclaim before calling shrink_node. */
3205 sc.nr_scanned = 0;
3206 nr_soft_scanned = 0;
3208 nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone, sc.order,
3207 nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(pgdat, sc.order,
3209 sc.gfp_mask, &nr_soft_scanned);
3210 sc.nr_reclaimed += nr_soft_reclaimed;
3211
3212 /*
3213 * There should be no need to raise the scanning priority if
3214 * enough pages are already being scanned that that high
3215 * watermark would be met at 100% efficiency.
3216 */

--- 584 unchanged lines hidden ---
3208 sc.gfp_mask, &nr_soft_scanned);
3209 sc.nr_reclaimed += nr_soft_reclaimed;
3210
3211 /*
3212 * There should be no need to raise the scanning priority if
3213 * enough pages are already being scanned that that high
3214 * watermark would be met at 100% efficiency.
3215 */

--- 584 unchanged lines hidden ---