[Devel,rh7,1/2] tcache: don't invalidate pages on unsuccessful put/inability to put

Submitted by Andrey Ryabinin on Dec. 12, 2016, 11:28 a.m.

Details

Message ID 1481542086-5887-1-git-send-email-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin Dec. 12, 2016, 11:28 a.m.
This reverts commit 9a72c78a0e738571451596f68ab97940c24af611
("tcache: invalidate page on unsuccessful put").

There is no need to invalidate the page on unsuccessful put,
because we always put only uptodate pages in cleancache. If page becomes
outdated clencache uses cleancache_invalidate_* to remove such pages from
its cache.
This should save us some CPU cycles during reclaim if tcache is not active
or when we perform global reclaim.

https://jira.sw.ru/browse/PSBM-56475
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/tcache.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/tcache.c b/mm/tcache.c
index 95a8259..cec5a4e 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -1141,27 +1141,24 @@  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);
 
 	/* It makes no sense to populate tcache when we are short on memory */
-	if (current->flags & PF_MEMALLOC)
-		may_put = false;
+	if (!READ_ONCE(tcache_active) || current->flags & PF_MEMALLOC)
+		return;
 
-	node = tcache_get_node_and_pool(pool_id, &key, may_put);
+	node = tcache_get_node_and_pool(pool_id, &key, true);
 	if (node) {
-		if (may_put)
-			cache_page = tcache_alloc_page(node->pool);
+		cache_page = tcache_alloc_page(node->pool);
 		if (cache_page) {
 			copy_highpage(cache_page, page);
 			/* cleancache does not care about failures */
 			(void)tcache_attach_page(node, index, cache_page);
-		} else
-			cache_page = tcache_detach_page(node, index, false);
+		}
 		tcache_put_node_and_pool(node);
-	}
+		if (cache_page)
+			tcache_put_page(cache_page);
 
-	if (cache_page)
-		tcache_put_page(cache_page);
+	}
 }
 
 static int tcache_cleancache_get_page(int pool_id,