mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "jianchao.w.wang@oracle.com" <jianchao.w.wang@oracle.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [PATCH] blk-mq: use mutex_trylock to avoid lock inversion
Date: Wed, 20 Jun 2018 16:18:49 +0000	[thread overview]
Message-ID: <2c2003ff1baac05688495677f67239d52f6d9527.camel@wdc.com> (raw)
In-Reply-To: <d528a730-8e44-225b-2a35-3544160761dc@oracle.com>

On Wed, 2018-06-20 at 10:09 +0800, jianchao.wang wrote:
> It is very easy to reproduce with following scripts.
> 
> script 0
> while true
> do
> 	modprobe null_blk queue_mode=2 shared_tags=1
> 	sleep 0.1
> 	rmmod null_blk
> 	sleep 0.1
> done
> 
> script 1
> file0="/sys/block/nullb0/mq/0/nr_tags"
> file1="/sys/block/nullb0/mq/0/cpu0/rq_list"
> while true;
> do
> 	if [ -e $file0 ];then
> 		cat $file0
> 	fi
> 	if [ -e $file1 ];then
> 		cat $file1
> 	fi
> done

Hello Jianchao,

Thanks for having shared a reproducer. However, the approach of the patch you
posted doesn't seem like the right approach to me. I propose to proceed as
follows:
* Convert the reproducer into a blktests test and submit is as a patch to the
  blktests project (https://github.com/osandov/blktests).
* Remove the mutex_lock/unlock(&sysfs_lock) calls from blk_cleanup_queue().
  These calls are useless.  Block drivers are required to call del_gendisk()
  before calling blk_cleanup_queue(). That means that sysfs attributes are
  removed synchronously before blk_cleanup_queue() is called. The following
  statement in blk_cleanup_queue() verifies that:
    WARN_ON_ONCE(q->kobj.state_in_sysfs);
  BTW, this also means that the blk_queue_dying() checks in various show and
  store methods are superfluous.
* Introduce a new mutex to serialize blk_mq_register_dev() and
  blk_mq_sysfs_register() and blk_mq_sysfs_unregister(). I think it is wrong
  that these functions use sysfs_mutex.
* Document the purpose of sysfs_mutex in include/linux/blkdev.h, namely to
  serialize the sysfs .show() and .store() callback functions and also to
  serialize elevator changes.

Thanks,

Bart.



  reply	other threads:[~2018-06-20 16:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19  7:00 Jianchao Wang
2018-06-19 15:20 ` Bart Van Assche
2018-06-20  2:09   ` jianchao.wang
2018-06-20 16:18     ` Bart Van Assche [this message]
2018-06-21  8:23       ` jianchao.wang
2018-06-26  3:46         ` jianchao.wang
2018-06-26 15:36           ` Bart Van Assche
2018-06-28  1:11             ` jianchao.wang
2018-06-28  1:15               ` jianchao.wang

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=2c2003ff1baac05688495677f67239d52f6d9527.camel@wdc.com \
    --to=bart.vanassche@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=jianchao.w.wang@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®