Skip to content

Commit 0ce3d74

Browse files
Dave ChinnerAl Viro
authored andcommitted
shrinker: add node awareness
Pass the node of the current zone being reclaimed to shrink_slab(), allowing the shrinker control nodemask to be set appropriately for node aware shrinkers. Signed-off-by: Dave Chinner <[email protected]> Signed-off-by: Glauber Costa <[email protected]> Acked-by: Mel Gorman <[email protected]> Cc: "Theodore Ts'o" <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Al Viro <[email protected]> Cc: Artem Bityutskiy <[email protected]> Cc: Arve Hjønnevåg <[email protected]> Cc: Carlos Maiolino <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Chuck Lever <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: David Rientjes <[email protected]> Cc: Gleb Natapov <[email protected]> Cc: Greg Thelen <[email protected]> Cc: J. Bruce Fields <[email protected]> Cc: Jan Kara <[email protected]> Cc: Jerome Glisse <[email protected]> Cc: John Stultz <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Marcelo Tosatti <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Steven Whitehouse <[email protected]> Cc: Thomas Hellstrom <[email protected]> Cc: Trond Myklebust <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 4e717f5 commit 0ce3d74

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

drivers/staging/android/ashmem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,9 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
692692
.gfp_mask = GFP_KERNEL,
693693
.nr_to_scan = 0,
694694
};
695+
696+
nodes_setall(sc.nodes_to_scan);
697+
695698
ret = ashmem_shrink(&ashmem_shrinker, &sc);
696699
sc.nr_to_scan = ret;
697700
ashmem_shrink(&ashmem_shrinker, &sc);

fs/drop_caches.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static void drop_slab(void)
4444
.gfp_mask = GFP_KERNEL,
4545
};
4646

47+
nodes_setall(shrink.nodes_to_scan);
4748
do {
4849
nr_objects = shrink_slab(&shrink, 1000, 1000);
4950
} while (nr_objects > 10);

include/linux/shrinker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ struct shrink_control {
1616

1717
/* How many slab objects shrinker() should scan and try to reclaim */
1818
unsigned long nr_to_scan;
19+
20+
/* shrink from these nodes */
21+
nodemask_t nodes_to_scan;
1922
};
2023

2124
#define SHRINK_STOP (~0UL)

mm/memory-failure.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,12 @@ void shake_page(struct page *p, int access)
248248
*/
249249
if (access) {
250250
int nr;
251+
int nid = page_to_nid(p);
251252
do {
252253
struct shrink_control shrink = {
253254
.gfp_mask = GFP_KERNEL,
254255
};
256+
node_set(nid, shrink.nodes_to_scan);
255257

256258
nr = shrink_slab(&shrink, 1000, 1000);
257259
if (page_count(p) == 1)

mm/vmscan.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,12 +2374,16 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
23742374
*/
23752375
if (global_reclaim(sc)) {
23762376
unsigned long lru_pages = 0;
2377+
2378+
nodes_clear(shrink->nodes_to_scan);
23772379
for_each_zone_zonelist(zone, z, zonelist,
23782380
gfp_zone(sc->gfp_mask)) {
23792381
if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
23802382
continue;
23812383

23822384
lru_pages += zone_reclaimable_pages(zone);
2385+
node_set(zone_to_nid(zone),
2386+
shrink->nodes_to_scan);
23832387
}
23842388

23852389
shrink_slab(shrink, sc->nr_scanned, lru_pages);
@@ -2836,6 +2840,8 @@ static bool kswapd_shrink_zone(struct zone *zone,
28362840
return true;
28372841

28382842
shrink_zone(zone, sc);
2843+
nodes_clear(shrink.nodes_to_scan);
2844+
node_set(zone_to_nid(zone), shrink.nodes_to_scan);
28392845

28402846
reclaim_state->reclaimed_slab = 0;
28412847
nr_slab = shrink_slab(&shrink, sc->nr_scanned, lru_pages);
@@ -3544,10 +3550,9 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
35443550
* number of slab pages and shake the slab until it is reduced
35453551
* by the same nr_pages that we used for reclaiming unmapped
35463552
* pages.
3547-
*
3548-
* Note that shrink_slab will free memory on all zones and may
3549-
* take a long time.
35503553
*/
3554+
nodes_clear(shrink.nodes_to_scan);
3555+
node_set(zone_to_nid(zone), shrink.nodes_to_scan);
35513556
for (;;) {
35523557
unsigned long lru_pages = zone_reclaimable_pages(zone);
35533558

0 commit comments

Comments
 (0)