* [PATCH v2] sbitmap: Silence a debug kernel warning triggered by sbitmap_put()
@ 2021-03-17 3:26 Bart Van Assche
2021-03-17 6:12 ` Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Bart Van Assche @ 2021-03-17 3:26 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Christoph Hellwig, Bart Van Assche, Ming Lei,
Hannes Reinecke, Omar Sandoval
All sbitmap code uses implied preemption protection to update
sb->alloc_hint except sbitmap_put(). Using implied preemption protection
is safe since the value of sb->alloc_hint only affects performance of
sbitmap allocations but not their correctness. Change this_cpu_ptr() in
sbitmap_put() into raw_cpu_ptr() to suppress the following kernel warning
that appears with preemption debugging enabled (CONFIG_DEBUG_PREEMPT):
BUG: using smp_processor_id() in preemptible [00000000] code: scsi_eh_0/152
caller is debug_smp_processor_id+0x17/0x20
CPU: 1 PID: 152 Comm: scsi_eh_0 Tainted: G W 5.12.0-rc1-dbg+ #6
Call Trace:
show_stack+0x52/0x58
dump_stack+0xaf/0xf3
check_preemption_disabled+0xce/0xd0
debug_smp_processor_id+0x17/0x20
scsi_device_unbusy+0x13a/0x1c0 [scsi_mod]
scsi_finish_command+0x4d/0x290 [scsi_mod]
scsi_eh_flush_done_q+0x1e7/0x280 [scsi_mod]
ata_scsi_port_error_handler+0x592/0x750 [libata]
ata_scsi_error+0x1a0/0x1f0 [libata]
scsi_error_handler+0x19e/0x330 [scsi_mod]
kthread+0x222/0x250
ret_from_fork+0x1f/0x30
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Omar Sandoval <osandov@fb.com>
Fixes: c548e62bcf6a ("scsi: sbitmap: Move allocation hint into sbitmap")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
Changes compared to v1: changed patch subject and elaborated patch
description.
include/linux/sbitmap.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/sbitmap.h b/include/linux/sbitmap.h
index 3087e1f15fdd..2713e689ad66 100644
--- a/include/linux/sbitmap.h
+++ b/include/linux/sbitmap.h
@@ -324,7 +324,7 @@ static inline void sbitmap_put(struct sbitmap *sb, unsigned int bitnr)
sbitmap_deferred_clear_bit(sb, bitnr);
if (likely(sb->alloc_hint && !sb->round_robin && bitnr < sb->depth))
- *this_cpu_ptr(sb->alloc_hint) = bitnr;
+ *raw_cpu_ptr(sb->alloc_hint) = bitnr;
}
static inline int sbitmap_test_bit(struct sbitmap *sb, unsigned int bitnr)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] sbitmap: Silence a debug kernel warning triggered by sbitmap_put()
2021-03-17 3:26 [PATCH v2] sbitmap: Silence a debug kernel warning triggered by sbitmap_put() Bart Van Assche
@ 2021-03-17 6:12 ` Christoph Hellwig
2021-03-19 2:41 ` Martin K. Petersen
2021-03-25 3:53 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2021-03-17 6:12 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Christoph Hellwig, Ming Lei,
Hannes Reinecke, Omar Sandoval
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] sbitmap: Silence a debug kernel warning triggered by sbitmap_put()
2021-03-17 3:26 [PATCH v2] sbitmap: Silence a debug kernel warning triggered by sbitmap_put() Bart Van Assche
2021-03-17 6:12 ` Christoph Hellwig
@ 2021-03-19 2:41 ` Martin K. Petersen
2021-03-25 3:53 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-03-19 2:41 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Christoph Hellwig, Ming Lei,
Hannes Reinecke, Omar Sandoval
Bart,
> All sbitmap code uses implied preemption protection to update
> sb->alloc_hint except sbitmap_put(). Using implied preemption
> protection is safe since the value of sb->alloc_hint only affects
> performance of sbitmap allocations but not their correctness. Change
> this_cpu_ptr() in sbitmap_put() into raw_cpu_ptr() to suppress the
> following kernel warning that appears with preemption debugging
> enabled (CONFIG_DEBUG_PREEMPT):
Applied to 5.13/scsi-staging, thanks! (Since Ming's series is queued in
the SCSI tree).
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] sbitmap: Silence a debug kernel warning triggered by sbitmap_put()
2021-03-17 3:26 [PATCH v2] sbitmap: Silence a debug kernel warning triggered by sbitmap_put() Bart Van Assche
2021-03-17 6:12 ` Christoph Hellwig
2021-03-19 2:41 ` Martin K. Petersen
@ 2021-03-25 3:53 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-03-25 3:53 UTC (permalink / raw)
To: Jens Axboe, Bart Van Assche
Cc: Martin K . Petersen, Omar Sandoval, Hannes Reinecke, linux-block,
Christoph Hellwig, Ming Lei
On Tue, 16 Mar 2021 20:26:48 -0700, Bart Van Assche wrote:
> All sbitmap code uses implied preemption protection to update
> sb->alloc_hint except sbitmap_put(). Using implied preemption protection
> is safe since the value of sb->alloc_hint only affects performance of
> sbitmap allocations but not their correctness. Change this_cpu_ptr() in
> sbitmap_put() into raw_cpu_ptr() to suppress the following kernel warning
> that appears with preemption debugging enabled (CONFIG_DEBUG_PREEMPT):
>
> [...]
Applied to 5.13/scsi-queue, thanks!
[1/1] sbitmap: Silence a debug kernel warning triggered by sbitmap_put()
https://git.kernel.org/mkp/scsi/c/035e9f471691
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-25 3:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 3:26 [PATCH v2] sbitmap: Silence a debug kernel warning triggered by sbitmap_put() Bart Van Assche
2021-03-17 6:12 ` Christoph Hellwig
2021-03-19 2:41 ` Martin K. Petersen
2021-03-25 3:53 ` Martin K. Petersen
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).