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

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 8 05:45:28 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.8.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.8.4
------>
commit b5f889b9404ef2e039fa59ff80c217baca49a927
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Thu Oct 8 16:45:28 2015 +0400

    tcache: do not try to create node if we are not going to store page
    
    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 virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai at odin.com>
---
 mm/tcache.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/mm/tcache.c b/mm/tcache.c
index b078c84..ce5b0ed 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);



More information about the Devel mailing list