* [PATCH] SUNRPC: two small improvements to rpcauth shrinker.
@ 2017-01-06 3:19 NeilBrown
0 siblings, 0 replies; only message in thread
From: NeilBrown @ 2017-01-06 3:19 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker, J. Bruce Fields, linux-nfs
[-- Attachment #1: Type: text/plain, Size: 1702 bytes --]
1/ If we find an entry that is too young to be pruned,
return SHRINK_STOP to ensure we don't get called again.
This is more correct, and avoids wasting a little CPU time.
Prior to 3.12, it can prevent drop_slab() from spinning indefinitely.
2/ Return a precise number from rpcauth_cache_shrink_count(), rather than
rounding down to a multiple of 100 (of whatever sysctl_vfs_cache_pressure is).
This ensures that when we "echo 3 > /proc/sys/vm/drop_caches", this cache is
still purged, even if it has fewer than 100 entires.
Neither of these are really important, they just make behaviour
more predicatable, which can be helpful when debugging related issues.
Signed-off-by: NeilBrown <neilb@suse.com>
---
net/sunrpc/auth.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 2bff63a73cf8..d8f17ea7932e 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -464,8 +464,10 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
* Note that the cred_unused list must be time-ordered.
*/
if (time_in_range(cred->cr_expire, expired, jiffies) &&
- test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0)
+ test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) {
+ freed = SHRINK_STOP;
break;
+ }
list_del_init(&cred->cr_lru);
number_cred_unused--;
@@ -520,7 +522,7 @@ static unsigned long
rpcauth_cache_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
{
- return (number_cred_unused / 100) * sysctl_vfs_cache_pressure;
+ return number_cred_unused * sysctl_vfs_cache_pressure / 100;
}
static void
--
2.11.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-01-06 3:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-06 3:19 [PATCH] SUNRPC: two small improvements to rpcauth shrinker NeilBrown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).