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 <aryabi...@virtuozzo.com>
---
 mm/tcache.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

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,
-- 
2.7.3

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to