Skip to content

Commit 87420d7

Browse files
Hakon-BuggeNipaLocal
authored andcommitted
RDMA/cm: Brute force GFP_NOIO
In ib_cm_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 ib_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 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 82d4d1a commit 87420d7

File tree

1 file changed

+14
-1
lines changed
  • drivers/infiniband/core

1 file changed

+14
-1
lines changed

drivers/infiniband/core/cm.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/workqueue.h>
2323
#include <linux/kdev_t.h>
2424
#include <linux/etherdevice.h>
25+
#include <linux/sched/mm.h>
2526

2627
#include <rdma/ib_cache.h>
2728
#include <rdma/ib_cm.h>
@@ -35,6 +36,11 @@ MODULE_DESCRIPTION("InfiniBand CM");
3536
MODULE_LICENSE("Dual BSD/GPL");
3637

3738
#define CM_DESTROY_ID_WAIT_TIMEOUT 10000 /* msecs */
39+
40+
static bool cm_force_noio;
41+
module_param_named(force_noio, cm_force_noio, bool, 0444);
42+
MODULE_PARM_DESC(force_noio, "Force the use of GFP_NOIO (Y/N)");
43+
3844
static const char * const ibcm_rej_reason_strs[] = {
3945
[IB_CM_REJ_NO_QP] = "no QP",
4046
[IB_CM_REJ_NO_EEC] = "no EEC",
@@ -4504,6 +4510,10 @@ static void cm_remove_one(struct ib_device *ib_device, void *client_data)
45044510
static int __init ib_cm_init(void)
45054511
{
45064512
int ret;
4513+
unsigned int noio_flags;
4514+
4515+
if (cm_force_noio)
4516+
noio_flags = memalloc_noio_save();
45074517

45084518
INIT_LIST_HEAD(&cm.device_list);
45094519
rwlock_init(&cm.device_lock);
@@ -4527,10 +4537,13 @@ static int __init ib_cm_init(void)
45274537
if (ret)
45284538
goto error3;
45294539

4530-
return 0;
4540+
goto error2;
45314541
error3:
45324542
destroy_workqueue(cm.wq);
45334543
error2:
4544+
if (cm_force_noio)
4545+
memalloc_noio_restore(noio_flags);
4546+
45344547
return ret;
45354548
}
45364549

0 commit comments

Comments
 (0)