Skip to contentSkip to conversation

fs: nfs: return per memcg count for xattr shrinkers

PATCH In review Yang Shi 2 participants 2 messages Sep 30, 2020

Subsystems (3)
lore
Share & tools
lore

Yang Shi

author
#0 lore raw

PATCH 1/1 fs: nfs: return per memcg count for xattr shrinkers

The list_lru_count() returns the pre node count, but the new xattr shrinkers are memcg aware, so the shrinkers should return per memcg count by calling list_lru_shrink_count() instead. Otherwise over-shrink might be experienced. The problem was spotted by visual code inspection.

Cc Trond Myklebust <[email protected]>
Cc Anna Schumaker <[email protected]>
Cc Frank van der Linden <[email protected]>
---
 fs/nfs/nfs42xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs42xattr.c +2 -2
index 86777996cfec..6e5f34916937 100644
@@ -882,7 +882,7 @@ nfs4_xattr_cache_count(struct shrinker *shrink, struct shrink_control *sc)
 {
 	unsigned long count;
 
-	count = list_lru_count(&nfs4_xattr_cache_lru);
+	count = list_lru_shrink_count(&nfs4_xattr_cache_lru, sc);
 	return vfs_pressure_ratio(count);
 }
 
@@ -976,7 +976,7 @@ nfs4_xattr_entry_count(struct shrinker *shrink, struct shrink_control *sc)
 	lru = (shrink == &nfs4_xattr_large_entry_shrinker) ?
 	    &nfs4_xattr_large_entry_lru : &nfs4_xattr_entry_lru;
 
-	count = list_lru_count(lru);
+	count = list_lru_shrink_count(lru, sc);
 	return vfs_pressure_ratio(count);
 }
 
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 38 lines · Yang Shi

The list_lru_count() returns the pre node count, but the new xattr shrinkers are memcg aware, so the shrinkers should return per memcg count by calling list_lru_shrink_count() instead. Otherwise over-shrink might be experienced. The problem was spotted by visual code inspection.

Cc Trond Myklebust <[email protected]>
Cc Anna Schumaker <[email protected]>
Cc Frank van der Linden <[email protected]>
---
 fs/nfs/nfs42xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs42xattr.c +2 -3
index 86777996cfec..6e5f34916937 100644
@@ -882,7 +882,7 @@ nfs4_xattr_cache_count(struct shrinker *shrink, struct shrink_control *sc)
 {
        unsigned long count;
 
-       count = list_lru_count(&nfs4_xattr_cache_lru);
+       count = list_lru_shrink_count(&nfs4_xattr_cache_lru, sc);
        return vfs_pressure_ratio(count);
 }
 
@@ -976,7 +976,7 @@ nfs4_xattr_entry_count(struct shrinker *shrink, struct shrink_control *sc)
        lru = (shrink == &nfs4_xattr_large_entry_shrinker) ?
            &nfs4_xattr_large_entry_lru : &nfs4_xattr_entry_lru;
 
-       count = list_lru_count(lru);
+       count = list_lru_shrink_count(lru, sc);
        return vfs_pressure_ratio(count);
 }
 
--
Quoted 2 lines

2.26.2

Yep, thanks.