From: Coly Li <colyli@suse.de>
To: Li Lei <noctis.akm@gmail.com>
Cc: kent.overstreet@gmail.com, linux-bcache@vger.kernel.org,
Li Lei <lilei@szsandstone.com>
Subject: Re: [PATCH] bcache: remove unnecessary flush_workqueue
Date: Fri, 8 Apr 2022 00:53:57 +0800 [thread overview]
Message-ID: <40862b68-e81d-089b-d713-b0e6e2bd7e04@suse.de> (raw)
In-Reply-To: <20220327072038.12385-1-lilei@szsandstone.com>
On 3/27/22 3:20 PM, Li Lei wrote:
> All pending works will be drained by destroy_workqueue(), no need to call
> flush_workqueue() explicitly.
>
> Signed-off-by: Li Lei <lilei@szsandstone.com>
> ---
> drivers/md/bcache/writeback.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
> index 9ee0005874cd..2a6d9f39a9b1 100644
> --- a/drivers/md/bcache/writeback.c
> +++ b/drivers/md/bcache/writeback.c
> @@ -793,10 +793,9 @@ static int bch_writeback_thread(void *arg)
> }
> }
>
> - if (dc->writeback_write_wq) {
> - flush_workqueue(dc->writeback_write_wq);
> + if (dc->writeback_write_wq)
> destroy_workqueue(dc->writeback_write_wq);
> - }
> +
> cached_dev_put(dc);
> wait_for_kthread_stop();
>
The above code is from commit 7e865eba00a3 ("bcache: fix potential
deadlock in cached_def_free()"). I explicitly added extra
flush_workqueue() was because of workqueue_sysfs_unregister(wq) in
destory_workqueue().
workqueue_sysfs_unregister() is not simple because it calls
device_unregister(), and the code path is long. During reboot I am not
sure whether extra deadlocking issue might be introduced. So the safe
way is to explicitly call flush_workqueue() firstly to wait for all
kwork finished, then destroy it.
It has been ~3 years passed, now I am totally OK with your above change.
But could you please test your patch with lockdep enabled, and see
whether there is no lock warning observed? Then I'd like to add it into
my test directory.
Thanks.
Coly Li
next prev parent reply other threads:[~2022-04-07 16:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-27 7:20 [PATCH] bcache: remove unnecessary flush_workqueue Li Lei
2022-04-07 16:53 ` Coly Li [this message]
2022-04-09 1:17 ` 李磊
2022-05-13 15:17 ` Coly Li
2022-05-28 18:11 ` Lei Li
2022-06-06 3:22 ` Coly Li
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=40862b68-e81d-089b-d713-b0e6e2bd7e04@suse.de \
--to=colyli@suse.de \
--cc=kent.overstreet@gmail.com \
--cc=lilei@szsandstone.com \
--cc=linux-bcache@vger.kernel.org \
--cc=noctis.akm@gmail.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