[Devel] [PATCH RHEL7 COMMIT] oom: Cast the lockdep spell in the code

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


The commit is pushed to "branch-rh7-3.10.0-1160.80.1.vz7.190.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.80.1.vz7.190.1
------>
commit acce6e8d56cbd2730d12ca3bcd6399d3df3135eb
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Mon Nov 28 17:44:17 2022 +0300

    oom: Cast the lockdep spell in the code
    
    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


More information about the Devel mailing list