[Devel] [PATCH rh7 4/4] oom: Cast the lockdep spell in the code

Konstantin Khorenko khorenko at virtuozzo.com
Mon Nov 28 19:16:19 MSK 2022


task_will_free_mem() requires the task_lock lock is held or the function
is called on the current, but this is just a function comment,
let's add the proper lockdep check according to this comment.

https://jira.sw.ru/browse/PSBM-143283

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
Suggested-by: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
---
 include/linux/oom.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/oom.h b/include/linux/oom.h
index ef0096799ee3..17f5612625f1 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -133,6 +133,8 @@ static inline bool task_will_free_mem(struct task_struct *task)
 {
 	struct mm_struct *mm = task->mm;
 
+	lockdep_assert(lockdep_is_held(&task->alloc_lock) || task == current);
+
 	/*
 	 * Skip tasks without mm because it might have passed its exit_mm and
 	 * exit_oom_victim. oom_reaper could have rescued that but do not rely
-- 
2.24.3



More information about the Devel mailing list