Skip to content

Commit db6169b

Browse files
Guoqing Jiangjgunthorpe
authored andcommitted
RDMA/rtrs: Call {get,put}_cpu_ptr to silence a debug kernel warning
With preemption enabled (CONFIG_DEBUG_PREEMPT=y), the following appeared when rnbd client tries to map remote block device. BUG: using smp_processor_id() in preemptible [00000000] code: bash/1733 caller is debug_smp_processor_id+0x17/0x20 CPU: 0 PID: 1733 Comm: bash Not tainted 5.16.0-rc1 #5 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.14.0-0-g155821a-rebuilt.opensuse.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x5d/0x78 dump_stack+0x10/0x12 check_preemption_disabled+0xe4/0xf0 debug_smp_processor_id+0x17/0x20 rtrs_clt_update_all_stats+0x3b/0x70 [rtrs_client] rtrs_clt_read_req+0xc3/0x380 [rtrs_client] ? rtrs_clt_init_req+0xe3/0x120 [rtrs_client] rtrs_clt_request+0x1a7/0x320 [rtrs_client] ? 0xffffffffc0ab1000 send_usr_msg+0xbf/0x160 [rnbd_client] ? rnbd_clt_put_sess+0x60/0x60 [rnbd_client] ? send_usr_msg+0x160/0x160 [rnbd_client] ? sg_alloc_table+0x27/0xb0 ? sg_zero_buffer+0xd0/0xd0 send_msg_sess_info+0xe9/0x180 [rnbd_client] ? rnbd_clt_put_sess+0x60/0x60 [rnbd_client] ? blk_mq_alloc_tag_set+0x2ef/0x370 rnbd_clt_map_device+0xba8/0xcd0 [rnbd_client] ? send_msg_open+0x200/0x200 [rnbd_client] rnbd_clt_map_device_store+0x3e5/0x620 [rnbd_client To supress the calltrace, let's call get_cpu_ptr/put_cpu_ptr pair in rtrs_clt_update_rdma_stats to disable preemption when accessing per-cpu variable. While at it, let's make the similar change in rtrs_clt_update_wc_stats. And for rtrs_clt_inc_failover_cnt, though it was only called inside rcu section, but it still can be preempted in case CONFIG_PREEMPT_RCU is enabled, so change it to {get,put}_cpu_ptr pair either. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guoqing Jiang <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent b0969f8 commit db6169b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@ void rtrs_clt_update_wc_stats(struct rtrs_clt_con *con)
1919
int cpu;
2020

2121
cpu = raw_smp_processor_id();
22-
s = this_cpu_ptr(stats->pcpu_stats);
22+
s = get_cpu_ptr(stats->pcpu_stats);
2323
if (con->cpu != cpu) {
2424
s->cpu_migr.to++;
2525

2626
/* Careful here, override s pointer */
2727
s = per_cpu_ptr(stats->pcpu_stats, con->cpu);
2828
atomic_inc(&s->cpu_migr.from);
2929
}
30+
put_cpu_ptr(stats->pcpu_stats);
3031
}
3132

3233
void rtrs_clt_inc_failover_cnt(struct rtrs_clt_stats *stats)
3334
{
3435
struct rtrs_clt_stats_pcpu *s;
3536

36-
s = this_cpu_ptr(stats->pcpu_stats);
37+
s = get_cpu_ptr(stats->pcpu_stats);
3738
s->rdma.failover_cnt++;
39+
put_cpu_ptr(stats->pcpu_stats);
3840
}
3941

4042
int rtrs_clt_stats_migration_from_cnt_to_str(struct rtrs_clt_stats *stats, char *buf)
@@ -169,9 +171,10 @@ static inline void rtrs_clt_update_rdma_stats(struct rtrs_clt_stats *stats,
169171
{
170172
struct rtrs_clt_stats_pcpu *s;
171173

172-
s = this_cpu_ptr(stats->pcpu_stats);
174+
s = get_cpu_ptr(stats->pcpu_stats);
173175
s->rdma.dir[d].cnt++;
174176
s->rdma.dir[d].size_total += size;
177+
put_cpu_ptr(stats->pcpu_stats);
175178
}
176179

177180
void rtrs_clt_update_all_stats(struct rtrs_clt_io_req *req, int dir)

0 commit comments

Comments
 (0)