Skip to contentSkip to conversation

sbitmap: Fix sbitmap_put()

PATCH In review Bart Van Assche 3 participants 4 messages Mar 16, 2021 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sbitmap: Fix sbitmap_put()

This patch fixes the following kernel warning:

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
Cc Ming Lei <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Omar Sandoval <[email protected]>
Fixes c548e62bcf6a ("scsi: sbitmap: Move allocation hint into sbitmap")
---
 include/linux/sbitmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sbitmap.h +1 -1
index 3087e1f15fdd..2713e689ad66 100644
@@ -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)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Bart Van Assche

This patch fixes the following kernel warning:

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
Cc Ming Lei <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Omar Sandoval <[email protected]>
Fixes c548e62bcf6a ("scsi: sbitmap: Move allocation hint into sbitmap")
---
 include/linux/sbitmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sbitmap.h +0 -0
index 3087e1f15fdd..2713e689ad66 100644

include/linux/sbitmap.h static inline void sbitmap_put(struct sbitmap *sb, unsigned int bitnr) · line 330

Quoted 8 lines
include/linux/sbitmap.h +1 -1
@@ -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)
Signature · 1 line
Ming
maintainer
#2 lore raw
In reply to Bart Van Assche
Quoted 18 lines · Bart Van Assche

This patch fixes the following kernel warning:

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

It'd be nice to have a bit of a description in here on what is being fixed, eg that we're preemptible and cannot safely use this_cpu_ptr(), and why that it's OK to use raw_cpu_ptr() instead for this particular application.

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 4 lines · Jens Axboe

It'd be nice to have a bit of a description in here on what is being fixed, eg that we're preemptible and cannot safely use this_cpu_ptr(), and why that it's OK to use raw_cpu_ptr() instead for this particular application.

Sure, I will provide a better description and repost this patch.

Thank you,

Bart.