[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250902160129.13862-1-zhongjinji@honor.com>
Date: Wed, 3 Sep 2025 00:01:29 +0800
From: zhongjinji <zhongjinji@...or.com>
To: <mhocko@...e.com>
CC: <akpm@...ux-foundation.org>, <feng.han@...or.com>,
<fengbaopeng@...or.com>, <liam.howlett@...cle.com>,
<linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>, <liulu.liu@...or.com>,
<lorenzo.stoakes@...cle.com>, <rientjes@...gle.com>,
<shakeel.butt@...ux.dev>, <surenb@...gle.com>, <tglx@...utronix.de>,
<tianxiaobin@...or.com>, <zhongjinji@...or.com>
Subject: Re: [PATCH v6 1/2] mm/oom_kill: Do not delay oom reaper when the victim is frozen
> > Sorry, I found that it doesn't work now (because I previously tested it by
> > simulating OOM, which made testing easier but also caused the mistake. I will
> > re-run the new test). Calling __thaw_task in mark_oom_victim will change the
> > victim's state to running. However, other threads are still in the frozen state,
> > so the process still can't exit. We should update it again by moving __thaw_task
> > to after frozen (this way, executing __thaw_task and frozen in the same function
> > looks more reasonable). Since mark_oom_victim and queue_oom_reaper always appear
> > in pairs, this won't introduce any risky changes.
>
> Hmm, I must have completely forgot that we are actually thawing the
> frozen task! That means that the actual argument for not delaying the
> oom reaper doesn't hold.
> Now I do see why the existing implementation doesn't really work as you
> would expect though. Is there any reason why we are not thawing the
> whole process group? I guess I just didn't realize that __thaw_task is
> per thread rather than per process back then when I have introduced it.
Previously, I didn't know why we needed to call __thaw_task() in
mark_oom_victim(). Now I understand.
> Because thread specific behavior makes very little sense to me TBH.
> So rather than plaing with __thaw_task placement which doesn't really
> make much sense wrt to delaying the reaper we should look into that
> part.
>
> Sorry, I should have realized earlier when proposing that.
Is this modification acceptable?
This change only thaws the process previously identified as the victim,
and does not thaw the process being killed in for_each_process.
The reason is that the process being killed in for_each_process is usually
a vfork process, which is only temporary and rarely encountered.
@@ -772,12 +773,18 @@ static void mark_oom_victim(struct task_struct *tsk)
mmgrab(tsk->signal->oom_mm);
/*
- * Make sure that the task is woken up from uninterruptible sleep
+ * Make sure that the process is woken up from uninterruptible sleep
* if it is frozen because OOM killer wouldn't be able to free
* any memory and livelock. freezing_slow_path will tell the freezer
- * that TIF_MEMDIE tasks should be ignored.
+ * that TIF_MEMDIE thread should be ignored.
*/
- __thaw_task(tsk);
+ rcu_read_lock();
+ for_each_thread(tsk, t) {
+ set_tsk_thread_flag(t, TIF_MEMDIE);
+ __thaw_task(t);
+ }
+ rcu_read_unlock();
+
atomic_inc(&oom_victims);
cred = get_task_cred(tsk);
trace_mark_victim(tsk, cred->uid.val);
Powered by blists - more mailing lists