linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: vmscan: remove redundant querying to shrinker
@ 2013-06-14 10:07 Heesub Shin
  2013-06-14 11:10 ` Minchan Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Heesub Shin @ 2013-06-14 10:07 UTC (permalink / raw)
  To: akpm
  Cc: linux-mm, linux-kernel, mgorman, riel, kyungmin.park, d.j.shin,
	sunae.seo, Heesub Shin

shrink_slab() queries each slab cache to get the number of
elements in it. In most cases such queries are cheap but,
on some caches. For example, Android low-memory-killer,
which is operates as a slab shrinker, does relatively
long calculation once invoked and it is quite expensive.

This patch removes redundant queries to shrinker function
in the loop of shrink batch.

Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
 mm/vmscan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index fa6a853..11b6695 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -282,9 +282,8 @@ unsigned long shrink_slab(struct shrink_control *shrink,
 					max_pass, delta, total_scan);
 
 		while (total_scan >= batch_size) {
-			int nr_before;
+			int nr_before = max_pass;
 
-			nr_before = do_shrinker_shrink(shrinker, shrink, 0);
 			shrink_ret = do_shrinker_shrink(shrinker, shrink,
 							batch_size);
 			if (shrink_ret == -1)
@@ -293,6 +292,7 @@ unsigned long shrink_slab(struct shrink_control *shrink,
 				ret += nr_before - shrink_ret;
 			count_vm_events(SLABS_SCANNED, batch_size);
 			total_scan -= batch_size;
+			max_pass = shrink_ret;
 
 			cond_resched();
 		}
-- 
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-06-17  7:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-14 10:07 [PATCH] mm: vmscan: remove redundant querying to shrinker Heesub Shin
2013-06-14 11:10 ` Minchan Kim
2013-06-14 18:13   ` HeeSub Shin
2013-06-14 23:04     ` Andrew Morton
2013-06-15  0:49       ` Kyungmin Park
2013-06-15  6:47       ` Minchan Kim
2013-06-15  7:09 ` Minchan Kim
2013-06-17  0:08 ` Dave Chinner
2013-06-17  7:54   ` Heesub Shin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).