public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Martin Wilck <mwilck@suse.com>,
	Steffen Maier <maier@linux.ibm.com>,
	linux-scsi <linux-scsi@vger.kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E . J . Bottomley" <jejb@linux.ibm.com>,
	Sachin Sant <sachinp@linux.ibm.com>,
	Hannes Reinecke <hare@suse.de>,
	Benjamin Block <bblock@linux.ibm.com>,
	linux-s390 <linux-s390@vger.kernel.org>
Subject: Re: kernel BUG scsi_dh_alua sleeping from invalid context && kernel WARNING do not call blocking ops when !TASK_RUNNING
Date: Tue, 17 Jan 2023 10:50:37 -0800	[thread overview]
Message-ID: <c23a6bf4-0b6e-0bbb-b74d-af69756bcf9a@acm.org> (raw)
In-Reply-To: <125f247806396f19fd27dcfa71f530b5b4a529a6.camel@suse.com>

On 1/17/23 01:28, Martin Wilck wrote:
> On Mon, 2023-01-16 at 09:48 -0800, Bart Van Assche wrote:
>> On 1/16/23 08:57, Martin Wilck wrote:
>>> Can we simply defer the scsi_device_put() to a workqueue?
>>
>> I'm concerned that would reintroduce a race condition when LLD kernel
>> modules are removed.
> 
> I don't follow. Normally, alua_rtpg_queue() queues rtpg_work, and
> alua_rtpg_work() will be called from the work queue and will eventually
> call scsi_device_put() when the RTPG is finished.
> 
> alua_rtpg_queue() only calls scsi_device_put() if queueing rtpg_work
> fails[*]. If we deferred this scsi_device_put() call to a work queue,
> what would be the difference (wrt a module_put() race condition)
> compared to the case where queue_delayed_work() succeeds?
> In both cases, scsi_device_put() would be called from a work queue.
> 
> Given that alua_rtpg_queue() must take a reference to the scsi device
> for the case that queueing succeeds, and that alua_rtpg_queue() is
> sometimes called in atomic context, I think deferring the
> scsi_device_put() call is the only option we have.

Hi Martin,

Before commit f93ed747e2c7 ("scsi: core: Release SCSI devices 
synchronously") the SCSI device release code could continue running 
asynchronously after the last module_put() call of the LLD associated 
with the SCSI device.

Since commit f93ed747e2c7 it is guaranteed that freeing device memory 
(scsi_device_dev_release()) has finished before the last LLD 
module_put() call happens.

Do you perhaps plan to defer the scsi_device_put() calls in the ALUA 
device handler to a workqueue?

Thanks,

Bart.

  reply	other threads:[~2023-01-17 19:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 14:59 kernel BUG scsi_dh_alua sleeping from invalid context && kernel WARNING do not call blocking ops when !TASK_RUNNING Steffen Maier
2023-01-16 16:57 ` Martin Wilck
2023-01-16 17:48   ` Bart Van Assche
2023-01-16 17:58     ` Martin Wilck
2023-01-17  9:28     ` Martin Wilck
2023-01-17 18:50       ` Bart Van Assche [this message]
2023-01-17 21:48         ` Martin Wilck
2023-01-17 21:52           ` Bart Van Assche
2023-01-17 22:03             ` Martin Wilck
2023-01-18  0:29               ` Bart Van Assche
2023-01-18  8:45                 ` Martin Wilck
2023-01-18 16:17                 ` Steffen Maier
2023-01-24 11:16                   ` Steffen Maier
2023-01-24 11:36                     ` Martin Wilck
2023-01-16 17:55 ` Bart Van Assche
2023-01-16 18:12   ` Steffen Maier
2023-01-16 18:31     ` Bart Van Assche
2023-01-17  7:46   ` Martin Wilck

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=c23a6bf4-0b6e-0bbb-b74d-af69756bcf9a@acm.org \
    --to=bvanassche@acm.org \
    --cc=bblock@linux.ibm.com \
    --cc=hare@suse.de \
    --cc=jejb@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=maier@linux.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=mwilck@suse.com \
    --cc=sachinp@linux.ibm.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