Skip to content

Commit ce89e74

Browse files
Ye Binchucklever
authored andcommitted
svcrdma: fix miss destroy percpu_counter in svc_rdma_proc_init()
There's issue as follows: RPC: Registered rdma transport module. RPC: Registered rdma backchannel transport module. RPC: Unregistered rdma transport module. RPC: Unregistered rdma backchannel transport module. BUG: unable to handle page fault for address: fffffbfff80c609a PGD 123fee067 P4D 123fee067 PUD 123fea067 PMD 10c624067 PTE 0 Oops: Oops: 0000 [#1] PREEMPT SMP KASAN NOPTI RIP: 0010:percpu_counter_destroy_many+0xf7/0x2a0 Call Trace: <TASK> __die+0x1f/0x70 page_fault_oops+0x2cd/0x860 spurious_kernel_fault+0x36/0x450 do_kern_addr_fault+0xca/0x100 exc_page_fault+0x128/0x150 asm_exc_page_fault+0x26/0x30 percpu_counter_destroy_many+0xf7/0x2a0 mmdrop+0x209/0x350 finish_task_switch.isra.0+0x481/0x840 schedule_tail+0xe/0xd0 ret_from_fork+0x23/0x80 ret_from_fork_asm+0x1a/0x30 </TASK> If register_sysctl() return NULL, then svc_rdma_proc_cleanup() will not destroy the percpu counters which init in svc_rdma_proc_init(). If CONFIG_HOTPLUG_CPU is enabled, residual nodes may be in the 'percpu_counters' list. The above issue may occur once the module is removed. If the CONFIG_HOTPLUG_CPU configuration is not enabled, memory leakage occurs. To solve above issue just destroy all percpu counters when register_sysctl() return NULL. Fixes: 1e7e557 ("svcrdma: Restore read and write stats") Fixes: 22df5a2 ("svcrdma: Convert rdma_stat_sq_starve to a per-CPU counter") Fixes: df971cd ("svcrdma: Convert rdma_stat_recv to a per-CPU counter") Signed-off-by: Ye Bin <yebin10@huawei.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 573954a commit ce89e74

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

net/sunrpc/xprtrdma/svc_rdma.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,25 +233,34 @@ static int svc_rdma_proc_init(void)
233233

234234
rc = percpu_counter_init(&svcrdma_stat_read, 0, GFP_KERNEL);
235235
if (rc)
236-
goto out_err;
236+
goto err;
237237
rc = percpu_counter_init(&svcrdma_stat_recv, 0, GFP_KERNEL);
238238
if (rc)
239-
goto out_err;
239+
goto err_read;
240240
rc = percpu_counter_init(&svcrdma_stat_sq_starve, 0, GFP_KERNEL);
241241
if (rc)
242-
goto out_err;
242+
goto err_recv;
243243
rc = percpu_counter_init(&svcrdma_stat_write, 0, GFP_KERNEL);
244244
if (rc)
245-
goto out_err;
245+
goto err_sq;
246246

247247
svcrdma_table_header = register_sysctl("sunrpc/svc_rdma",
248248
svcrdma_parm_table);
249+
if (!svcrdma_table_header)
250+
goto err_write;
251+
249252
return 0;
250253

251-
out_err:
254+
err_write:
255+
rc = -ENOMEM;
256+
percpu_counter_destroy(&svcrdma_stat_write);
257+
err_sq:
252258
percpu_counter_destroy(&svcrdma_stat_sq_starve);
259+
err_recv:
253260
percpu_counter_destroy(&svcrdma_stat_recv);
261+
err_read:
254262
percpu_counter_destroy(&svcrdma_stat_read);
263+
err:
255264
return rc;
256265
}
257266

0 commit comments

Comments
 (0)