Commit 4c3ffd05 authored by NeilBrown's avatar NeilBrown Committed by Anna Schumaker

SUNRPC: two small improvements to rpcauth shrinker.

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: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent ddeaa637
...@@ -464,8 +464,10 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan) ...@@ -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. * Note that the cred_unused list must be time-ordered.
*/ */
if (time_in_range(cred->cr_expire, expired, jiffies) && 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; break;
}
list_del_init(&cred->cr_lru); list_del_init(&cred->cr_lru);
number_cred_unused--; number_cred_unused--;
...@@ -520,7 +522,7 @@ static unsigned long ...@@ -520,7 +522,7 @@ static unsigned long
rpcauth_cache_shrink_count(struct shrinker *shrink, struct shrink_control *sc) 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 static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment