[Devel] [PATCH RHEL7 COMMIT] ve/mm/cleancache: count only successful put in the cleancache_puts counter

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jul 21 11:23:33 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.33.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.33.12
------>
commit 2f2ca21337880d07ec0de2d58832060910f102cf
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Fri Jul 21 12:23:33 2017 +0400

    ve/mm/cleancache: count only successful put in the cleancache_puts counter
    
    Current semantic of the cleancache_puts counter (/sys/kernel/debug/cleancache/puts)
    is to count the number of the attempts to put into cleancache. Let's change
    this to the number of the successful puts, as this is less confusing.
    
    https://jira.sw.ru/browse/PSBM-63964
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 drivers/staging/zcache/zcache-main.c | 7 ++++---
 drivers/xen/tmem.c                   | 8 ++++----
 include/linux/cleancache.h           | 2 +-
 mm/cleancache.c                      | 7 ++-----
 mm/tcache.c                          | 7 +++++--
 5 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 3fe94dd..01e8446 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1495,7 +1495,7 @@ int zcache_autocreate_pool(unsigned int cli_id, unsigned int pool_id, bool eph)
  * to translate in-kernel semantics to zcache semantics.
  */
 
-static void zcache_cleancache_put_page(int pool_id,
+static int zcache_cleancache_put_page(int pool_id,
 					struct cleancache_filekey key,
 					pgoff_t index, struct page *page)
 {
@@ -1504,11 +1504,12 @@ static void zcache_cleancache_put_page(int pool_id,
 
 	if (!disable_cleancache_ignore_nonactive && !PageWasActive(page)) {
 		inc_zcache_eph_nonactive_puts_ignored();
-		return;
+		return 0;
 	}
 	if (likely(ind == index))
-		(void)zcache_put_page(LOCAL_CLIENT, pool_id, &oid, index,
+		return !zcache_put_page(LOCAL_CLIENT, pool_id, &oid, index,
 					page, PAGE_SIZE, false, 1);
+	return 0;
 }
 
 static int zcache_cleancache_get_page(int pool_id,
diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c
index 24814f8..4390855 100644
--- a/drivers/xen/tmem.c
+++ b/drivers/xen/tmem.c
@@ -168,7 +168,7 @@ static int xen_tmem_destroy_pool(u32 pool_id)
 
 /* cleancache ops */
 
-static void tmem_cleancache_put_page(int pool, struct cleancache_filekey key,
+static int tmem_cleancache_put_page(int pool, struct cleancache_filekey key,
 				     pgoff_t index, struct page *page)
 {
 	u32 ind = (u32) index;
@@ -176,11 +176,11 @@ static void tmem_cleancache_put_page(int pool, struct cleancache_filekey key,
 	unsigned long pfn = page_to_pfn(page);
 
 	if (pool < 0)
-		return;
+		return 0;
 	if (ind != index)
-		return;
+		return 0;
 	mb(); /* ensure page is quiescent; tmem may address it with an alias */
-	(void)xen_tmem_put_page((u32)pool, oid, ind, pfn);
+	return !xen_tmem_put_page((u32)pool, oid, ind, pfn);
 }
 
 static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key,
diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
index bda5ec0b4..dc9250b 100644
--- a/include/linux/cleancache.h
+++ b/include/linux/cleancache.h
@@ -30,7 +30,7 @@ struct cleancache_ops {
 	int (*init_shared_fs)(char *uuid, size_t);
 	int (*get_page)(int, struct cleancache_filekey,
 			pgoff_t, struct page *);
-	void (*put_page)(int, struct cleancache_filekey,
+	int (*put_page)(int, struct cleancache_filekey,
 			pgoff_t, struct page *);
 	void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
 	void (*invalidate_inode)(int, struct cleancache_filekey);
diff --git a/mm/cleancache.c b/mm/cleancache.c
index 16fc1d7..850668a 100644
--- a/mm/cleancache.c
+++ b/mm/cleancache.c
@@ -219,19 +219,16 @@ void __cleancache_put_page(struct page *page)
 	int pool_id;
 	struct cleancache_filekey key = { .u.key = { 0 } };
 
-	if (!cleancache_ops) {
-		cleancache_puts++;
+	if (!cleancache_ops)
 		return;
-	}
 
 	VM_BUG_ON_PAGE(!PageLocked(page), page);
 	pool_id = page->mapping->host->i_sb->cleancache_poolid;
 	if (pool_id >= 0 &&
 		cleancache_get_key(page->mapping->host, &key) >= 0) {
 		if (!mem_cgroup_cleancache_disabled(page)) {
-			cleancache_ops->put_page(pool_id, key,
+			cleancache_puts += cleancache_ops->put_page(pool_id, key,
 						 page->index, page);
-			cleancache_puts++;
 		} else
 			cleancache_ops->invalidate_page(pool_id, key,
 							page->index);
diff --git a/mm/tcache.c b/mm/tcache.c
index a77e3cf..53a5544 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -1173,16 +1173,17 @@ static int tcache_cleancache_init_shared_fs(char *uuid, size_t pagesize)
 	return -1;
 }
 
-static void tcache_cleancache_put_page(int pool_id,
+static int tcache_cleancache_put_page(int pool_id,
 				       struct cleancache_filekey key,
 				       pgoff_t index, struct page *page)
 {
+	int ret = 0;
 	struct tcache_node *node;
 	struct page *cache_page = NULL;
 
 	/* It makes no sense to populate tcache when we are short on memory */
 	if (!READ_ONCE(tcache_active) || !(current->flags & PF_MEMCG_RECLAIM))
-		return;
+		return 0;
 
 	node = tcache_get_node_and_pool(pool_id, &key, true);
 	if (node) {
@@ -1192,6 +1193,8 @@ static void tcache_cleancache_put_page(int pool_id,
 			if (tcache_attach_page(node, index, cache_page))
 				if (put_page_testzero(cache_page))
 					tcache_put_page(page);
+			else
+				ret = 1;
 		}
 		tcache_put_node_and_pool(node);
 	}


More information about the Devel mailing list