Skip to content

Commit eff6d99

Browse files
Bob Pearsonjgunthorpe
authored andcommitted
RDMA/rxe: Limit the number of calls to each tasklet
Limit the maximum number of calls to each tasklet from rxe_do_task() before yielding the cpu. When the limit is reached reschedule the tasklet and exit the calling loop. This patch prevents one tasklet from consuming 100% of a cpu core and causing a deadlock or soft lockup. Link: https://lore.kernel.org/r/20220630190425.2251-9-rpearsonhpe@gmail.com Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 8bb143c commit eff6d99

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

drivers/infiniband/sw/rxe/rxe_param.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ enum rxe_device_param {
105105
RXE_INFLIGHT_SKBS_PER_QP_HIGH = 64,
106106
RXE_INFLIGHT_SKBS_PER_QP_LOW = 16,
107107

108+
/* Max number of interations of each tasklet
109+
* before yielding the cpu to let other
110+
* work make progress
111+
*/
112+
RXE_MAX_ITERATIONS = 1024,
113+
108114
/* Delay before calling arbiter timer */
109115
RXE_NSEC_ARB_TIMER_DELAY = 200,
110116

drivers/infiniband/sw/rxe/rxe_task.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/interrupt.h>
99
#include <linux/hardirq.h>
1010

11-
#include "rxe_task.h"
11+
#include "rxe.h"
1212

1313
int __rxe_do_task(struct rxe_task *task)
1414

@@ -33,6 +33,7 @@ void rxe_do_task(struct tasklet_struct *t)
3333
int cont;
3434
int ret;
3535
struct rxe_task *task = from_tasklet(task, t, tasklet);
36+
unsigned int iterations = RXE_MAX_ITERATIONS;
3637

3738
spin_lock_bh(&task->state_lock);
3839
switch (task->state) {
@@ -61,13 +62,20 @@ void rxe_do_task(struct tasklet_struct *t)
6162
spin_lock_bh(&task->state_lock);
6263
switch (task->state) {
6364
case TASK_STATE_BUSY:
64-
if (ret)
65+
if (ret) {
6566
task->state = TASK_STATE_START;
66-
else
67+
} else if (iterations--) {
6768
cont = 1;
69+
} else {
70+
/* reschedule the tasklet and exit
71+
* the loop to give up the cpu
72+
*/
73+
tasklet_schedule(&task->tasklet);
74+
task->state = TASK_STATE_START;
75+
}
6876
break;
6977

70-
/* soneone tried to run the task since the last time we called
78+
/* someone tried to run the task since the last time we called
7179
* func, so we will call one more time regardless of the
7280
* return value
7381
*/

0 commit comments

Comments
 (0)