Message ID | 20230727080502.77895-23-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | use refcount+RCU method to implement lockless slab shrink | expand |
On 2023/7/27 16:04, Qi Zheng wrote: > Use new APIs to dynamically allocate the sunrpc_cred shrinker. > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> > Reviewed-by: Muchun Song <songmuchun@bytedance.com> > --- > net/sunrpc/auth.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c > index 2f16f9d17966..6b898b1be6f5 100644 > --- a/net/sunrpc/auth.c > +++ b/net/sunrpc/auth.c > @@ -861,11 +861,7 @@ rpcauth_uptodatecred(struct rpc_task *task) > test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0; > } > > -static struct shrinker rpc_cred_shrinker = { > - .count_objects = rpcauth_cache_shrink_count, > - .scan_objects = rpcauth_cache_shrink_scan, > - .seeks = DEFAULT_SEEKS, > -}; > +static struct shrinker *rpc_cred_shrinker; > > int __init rpcauth_init_module(void) > { > @@ -874,9 +870,16 @@ int __init rpcauth_init_module(void) > err = rpc_init_authunix(); > if (err < 0) > goto out1; > - err = register_shrinker(&rpc_cred_shrinker, "sunrpc_cred"); > - if (err < 0) > + rpc_cred_shrinker = shrinker_alloc(0, "sunrpc_cred"); > + if (!rpc_cred_shrinker) Here should set err to -ENOMEM, will fix. > goto out2; > + > + rpc_cred_shrinker->count_objects = rpcauth_cache_shrink_count; > + rpc_cred_shrinker->scan_objects = rpcauth_cache_shrink_scan; > + rpc_cred_shrinker->seeks = DEFAULT_SEEKS; > + > + shrinker_register(rpc_cred_shrinker); > + > return 0; > out2: > rpc_destroy_authunix(); > @@ -887,5 +890,5 @@ int __init rpcauth_init_module(void) > void rpcauth_remove_module(void) > { > rpc_destroy_authunix(); > - unregister_shrinker(&rpc_cred_shrinker); > + shrinker_free(rpc_cred_shrinker); > }
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 2f16f9d17966..6b898b1be6f5 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -861,11 +861,7 @@ rpcauth_uptodatecred(struct rpc_task *task) test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0; } -static struct shrinker rpc_cred_shrinker = { - .count_objects = rpcauth_cache_shrink_count, - .scan_objects = rpcauth_cache_shrink_scan, - .seeks = DEFAULT_SEEKS, -}; +static struct shrinker *rpc_cred_shrinker; int __init rpcauth_init_module(void) { @@ -874,9 +870,16 @@ int __init rpcauth_init_module(void) err = rpc_init_authunix(); if (err < 0) goto out1; - err = register_shrinker(&rpc_cred_shrinker, "sunrpc_cred"); - if (err < 0) + rpc_cred_shrinker = shrinker_alloc(0, "sunrpc_cred"); + if (!rpc_cred_shrinker) goto out2; + + rpc_cred_shrinker->count_objects = rpcauth_cache_shrink_count; + rpc_cred_shrinker->scan_objects = rpcauth_cache_shrink_scan; + rpc_cred_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(rpc_cred_shrinker); + return 0; out2: rpc_destroy_authunix(); @@ -887,5 +890,5 @@ int __init rpcauth_init_module(void) void rpcauth_remove_module(void) { rpc_destroy_authunix(); - unregister_shrinker(&rpc_cred_shrinker); + shrinker_free(rpc_cred_shrinker); }