Skip to content

Commit 6187c2a

Browse files
Hakon-BuggeNipaLocal
authored andcommitted
RDMA/cma: Brute force GFP_NOIO
In cma_init(), we call memalloc_noio_{save,restore} in a parenthetic fashion when enabled by the module parameter force_noio. This in order to conditionally enable rdma_cm to work aligned with block I/O devices. Any work queued later on work-queues created during module initialization will inherit the PF_MEMALLOC_{NOIO,NOFS} flag(s), due to commit ("workqueue: Inherit NOIO and NOFS alloc flags"). We do this in order to enable ULPs using the RDMA stack to be used as a network block I/O device. This to support a filesystem on top of a raw block device which uses said ULP(s) and the RDMA stack as the network transport layer. Under intense memory pressure, we get memory reclaims. Assume the filesystem reclaims memory, goes to the raw block device, which calls into the ULP in question, which calls the RDMA stack. Now, if regular GFP_KERNEL allocations in the ULP or the RDMA stack require reclaims to be fulfilled, we end up in a circular dependency. We break this circular dependency by: 1. Force all allocations in the ULP and the relevant RDMA stack to use GFP_NOIO, by means of a parenthetic use of memalloc_noio_{save,restore} on all relevant entry points. 2. Make sure work-queues inherits current->flags wrt. PF_MEMALLOC_{NOIO,NOFS}, such that work executed on the work-queue inherits the same flag(s). Signed-off-by: Håkon Bugge <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent c8ada36 commit 6187c2a

File tree

1 file changed

+17
-3
lines changed
  • drivers/infiniband/core

1 file changed

+17
-3
lines changed

drivers/infiniband/core/cma.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ MODULE_LICENSE("Dual BSD/GPL");
5050
#define CMA_IBOE_PACKET_LIFETIME 16
5151
#define CMA_PREFERRED_ROCE_GID_TYPE IB_GID_TYPE_ROCE_UDP_ENCAP
5252

53+
static bool cma_force_noio;
54+
module_param_named(force_noio, cma_force_noio, bool, 0444);
55+
MODULE_PARM_DESC(force_noio, "Force the use of GFP_NOIO (Y/N)");
56+
5357
static const char * const cma_events[] = {
5458
[RDMA_CM_EVENT_ADDR_RESOLVED] = "address resolved",
5559
[RDMA_CM_EVENT_ADDR_ERROR] = "address error",
@@ -5424,6 +5428,10 @@ static struct pernet_operations cma_pernet_operations = {
54245428
static int __init cma_init(void)
54255429
{
54265430
int ret;
5431+
unsigned int noio_flags;
5432+
5433+
if (cma_force_noio)
5434+
noio_flags = memalloc_noio_save();
54275435

54285436
/*
54295437
* There is a rare lock ordering dependency in cma_netdev_callback()
@@ -5439,8 +5447,10 @@ static int __init cma_init(void)
54395447
}
54405448

54415449
cma_wq = alloc_ordered_workqueue("rdma_cm", WQ_MEM_RECLAIM);
5442-
if (!cma_wq)
5443-
return -ENOMEM;
5450+
if (!cma_wq) {
5451+
ret = -ENOMEM;
5452+
goto out;
5453+
}
54445454

54455455
ret = register_pernet_subsys(&cma_pernet_operations);
54465456
if (ret)
@@ -5458,7 +5468,8 @@ static int __init cma_init(void)
54585468
if (ret)
54595469
goto err_ib;
54605470

5461-
return 0;
5471+
ret = 0;
5472+
goto out;
54625473

54635474
err_ib:
54645475
ib_unregister_client(&cma_client);
@@ -5469,6 +5480,9 @@ static int __init cma_init(void)
54695480
unregister_pernet_subsys(&cma_pernet_operations);
54705481
err_wq:
54715482
destroy_workqueue(cma_wq);
5483+
out:
5484+
if (cma_force_noio)
5485+
memalloc_noio_restore(noio_flags);
54725486
return ret;
54735487
}
54745488

0 commit comments

Comments
 (0)