Skip to content

Commit ab5cdc3

Browse files
Leon Romanovskydledford
Leon Romanovsky
authored andcommitted
IB/mlx5: Postpone remove_keys under knowledge of coming preemption
The remove_keys() logic is performed as garbage collection task. Such task is intended to be run when no other active processes are running. The need_resched() will return TRUE if there are user tasks to be activated in near future. In such case, we don't execute remove_keys() and postpone the garbage collection work to try to run in next cycle, in order to free CPU resources to other tasks. The possible pseudo-code to trigger such scenario: 1. Allocate a lot of MR to fill the cache above the limit. 2. Wait a small amount of time "to calm" the system. 3. Start CPU extensive operations on multi-node cluster. 4. Expect performance degradation during MR cache shrink operation. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Eli Cohen <eli@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 0ef2f05 commit ab5cdc3

File tree

1 file changed

+13
-1
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+13
-1
lines changed

drivers/infiniband/hw/mlx5/mr.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,19 @@ static void __cache_work_func(struct mlx5_cache_ent *ent)
381381
}
382382
}
383383
} else if (ent->cur > 2 * ent->limit) {
384-
if (!someone_adding(cache) &&
384+
/*
385+
* The remove_keys() logic is performed as garbage collection
386+
* task. Such task is intended to be run when no other active
387+
* processes are running.
388+
*
389+
* The need_resched() will return TRUE if there are user tasks
390+
* to be activated in near future.
391+
*
392+
* In such case, we don't execute remove_keys() and postpone
393+
* the garbage collection work to try to run in next cycle,
394+
* in order to free CPU resources to other tasks.
395+
*/
396+
if (!need_resched() && !someone_adding(cache) &&
385397
time_after(jiffies, cache->last_add + 300 * HZ)) {
386398
remove_keys(dev, i, 1);
387399
if (ent->cur > ent->limit)

0 commit comments

Comments
 (0)