lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZH6AA72wOd4HKTKE@P9FQF9L96D>
Date:   Mon, 5 Jun 2023 17:38:27 -0700
From:   Roman Gushchin <roman.gushchin@...ux.dev>
To:     Kirill Tkhai <tkhai@...ru>
Cc:     akpm@...ux-foundation.org, vbabka@...e.cz, viro@...iv.linux.org.uk,
        brauner@...nel.org, djwong@...nel.org, hughd@...gle.com,
        paulmck@...nel.org, muchun.song@...ux.dev, linux-mm@...ck.org,
        linux-fsdevel@...r.kernel.org, linux-xfs@...r.kernel.org,
        linux-kernel@...r.kernel.org, zhengqi.arch@...edance.com,
        david@...morbit.com
Subject: Re: [PATCH v2 3/3] fs: Use delayed shrinker unregistration

On Mon, Jun 05, 2023 at 10:03:25PM +0300, Kirill Tkhai wrote:
> Kernel test robot reports -88.8% regression in stress-ng.ramfs.ops_per_sec
> test case caused by commit: f95bdb700bc6 ("mm: vmscan: make global slab
> shrink lockless"). Qi Zheng investigated that the reason is in long SRCU's
> synchronize_srcu() occuring in unregister_shrinker().
> 
> This patch fixes the problem by using new unregistration interfaces,
> which split unregister_shrinker() in two parts. First part actually only
> notifies shrinker subsystem about the fact of unregistration and it prevents
> future shrinker methods calls. The second part completes the unregistration
> and it insures, that struct shrinker is not used during shrinker chain
> iteration anymore, so shrinker memory may be freed. Since the long second
> part is called from delayed work asynchronously, it hides synchronize_srcu()
> delay from a user.
> 
> Signed-off-by: Kirill Tkhai <tkhai@...ru>
> ---
>  fs/super.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/super.c b/fs/super.c
> index 8d8d68799b34..f3e4f205ec79 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -159,6 +159,7 @@ static void destroy_super_work(struct work_struct *work)
>  							destroy_work);
>  	int i;
>  
> +	unregister_shrinker_delayed_finalize(&s->s_shrink);
>  	for (i = 0; i < SB_FREEZE_LEVELS; i++)
>  		percpu_free_rwsem(&s->s_writers.rw_sem[i]);
>  	kfree(s);
> @@ -327,7 +328,7 @@ void deactivate_locked_super(struct super_block *s)
>  {
>  	struct file_system_type *fs = s->s_type;
>  	if (atomic_dec_and_test(&s->s_active)) {
> -		unregister_shrinker(&s->s_shrink);
> +		unregister_shrinker_delayed_initiate(&s->s_shrink);

Hm, it makes the API more complex and easier to mess with. Like what will happen
if the second part is never called? Or it's called without the first part being
called first?

Isn't it possible to hide it from a user and call the second part from a work
context automatically?

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ