On Sun, 2023-01-29 at 23:58 -0800, Christoph Hellwig wrote: > On Thu, Jan 26, 2023 at 10:22:12PM -0500, Martin K. Petersen wrote: > > On Wed, 25 Jan 2023 11:43:11 -0800, Bart Van Assche wrote: > > > > > Although most calls of scsi_device_put() happen from non-atomic > > > context, > > > alua_rtpg_queue() calls this function from atomic context if > > > alua_rtpg_queue() itself is called from atomic context. > > > alua_rtpg_queue() > > > is always called from contexts where the caller must hold at > > > least one > > > reference to the scsi device in question. This means that the > > > reference > > > taken by alua_rtpg_queue() itself can't be the last one, and thus > > > can be > > > dropped without entering the code path in which scsi_device_put() > > > might > > > actually sleep. Hence move the might_sleep() annotation from > > > scsi_device_put() into scsi_device_dev_release(). > > > > > > [...] > > > > Applied to 6.2/scsi-fixes, thanks! > > This is a really bad idea. Instead of actually catching > scsi_device_put > put from a wrong context all the time, it now limits to the final put > and thus making the annotation a lot less useful. The other idea that we discussed was this: https://lore.kernel.org/linux-scsi/53321793-fede-f84e-260a-9d6bc0bc2b6c@xxxxxxx/T/#t That approach would still catch other wrong call contexts (i.e. from outside the ALUA code). But it requires adding a new exported function in scsi.c. Would you prefer that, or do you have something completely different in mind? Idea #3 was to use a deferred call (e.g. a workqueue) for dropping the additional ref that had been takein in alua_rtpg_queue(). Thanks, Martin