[Devel] [PATCH rh7] tcache: do not try to create node if we are not going to store page

Vladimir Davydov vdavydov at parallels.com
Fri Sep 25 05:14:23 PDT 2015


Currently, we try to create a tcache node even if we are not going to
actually store a page in tcache (tcache is disabled or we are called by
global reclaimer). This is suboptimal, because we will drop the node
anyway then.

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 mm/tcache.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/mm/tcache.c b/mm/tcache.c
index b078c84f9564..ce5b0edd8253 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -835,10 +835,15 @@ static void tcache_cleancache_put_page(int pool_id,
 {
 	struct tcache_node *node;
 	struct page *cache_page = NULL;
+	bool may_put = ACCESS_ONCE(tcache_active);
 
-	node = tcache_get_node_and_pool(pool_id, &key, true);
+	/* It makes no sense to populate tcache when we are short on memory */
+	if (current->flags & PF_MEMALLOC)
+		may_put = false;
+
+	node = tcache_get_node_and_pool(pool_id, &key, may_put);
 	if (node) {
-		if (tcache_active && !(current->flags & PF_MEMALLOC))
+		if (may_put)
 			cache_page = tcache_alloc_page();
 		if (cache_page) {
 			copy_highpage(cache_page, page);
-- 
2.1.4




More information about the Devel mailing list