linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Huang Jianan <huangjianan@oppo.com>
Cc: zhangshiming@oppo.com, yh@oppo.com, guanyuwei@oppo.com,
	guoweichao@oppo.com, linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH] erofs: fix deadlock when shrink erofs slab
Date: Fri, 19 Nov 2021 10:19:16 +0800	[thread overview]
Message-ID: <YZcJpDs3FKpSfzAE@B-P7TQMD6M-0146> (raw)
In-Reply-To: <20211118135844.3559-1-huangjianan@oppo.com>

On Thu, Nov 18, 2021 at 09:58:44PM +0800, Huang Jianan wrote:
> We observed the following deadlock in the stress test under low
> memory scenario:
> 
> Thread A                               Thread B
> - erofs_shrink_scan
>  - erofs_try_to_release_workgroup
>   - erofs_workgroup_try_to_freeze -- A
>                                        - z_erofs_do_read_page
>                                         - z_erofs_collection_begin
>                                          - z_erofs_register_collection
>                                           - erofs_insert_workgroup
>                                            - xa_lock(&sbi->managed_pslots) -- B
>                                            - erofs_workgroup_get
>                                             - erofs_wait_on_workgroup_freezed -- A
>   - xa_erase
>    - xa_lock(&sbi->managed_pslots) -- B
> 
> To fix this, it need to hold the xa lock before freeze the workgroup
> beacuse we will operate xarry. So let's hold the lock before access
  ^ because               ^ xarray

> each workgroup, just like when we using the radix tree before.
> 
> Fixes: 64094a04414f ("erofs: convert workstn to XArray")
> Signed-off-by: Huang Jianan <huangjianan@oppo.com>

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Thanks,
Gao Xiang


      parent reply	other threads:[~2021-11-19  2:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 13:58 [PATCH] erofs: fix deadlock when shrink erofs slab Huang Jianan via Linux-erofs
2021-11-19  1:32 ` Chao Yu
2021-11-19  2:19 ` Gao Xiang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZcJpDs3FKpSfzAE@B-P7TQMD6M-0146 \
    --to=hsiangkao@linux.alibaba.com \
    --cc=guanyuwei@oppo.com \
    --cc=guoweichao@oppo.com \
    --cc=huangjianan@oppo.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=yh@oppo.com \
    --cc=zhangshiming@oppo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).