From nobody Fri Oct 3 01:10:44 2025 Received: from mta20.hihonor.com (mta20.hihonor.com [81.70.206.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56CC8275B1C; Tue, 9 Sep 2025 09:07:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.70.206.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757408828; cv=none; b=l1P3/phnUC9xj3zPeNVrXyapmy6s/jsiAkdxuYC1K+7knh6+w9PrMSdMqTiHOTEl0kKFqB+OMpZtTmQhwuviJETiHGtCDrLxySEYizD8nBMQRYyhdJ4jAdRaE0nX85P4oIEqd37c8GGOmGSYlbImXs7gDhlXMYzNLykjlDILzmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757408828; c=relaxed/simple; bh=7skizSUOygvtS5PJuQyyoPDDGCQB5spdhLE3ItvC2uA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FV47XkeRcmCDirNmJhQadztdS2h8VArLbw716dbsBQzGYA2SCsFdWVbhlj0PyfNU0OKX123wv8x7ByE6SW875Fi0+jhpQtGljm2NTc+Qv0JO3qIKn8VjwM4r1aFl880BbEwy8lGSShwq7QqskX2UjqnrMkcRkH3NV4tDDAj5mEc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com; spf=pass smtp.mailfrom=honor.com; arc=none smtp.client-ip=81.70.206.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=honor.com Received: from w001.hihonor.com (unknown [10.68.25.235]) by mta20.hihonor.com (SkyGuard) with ESMTPS id 4cLdH22Tf2zYl7DQ; Tue, 9 Sep 2025 17:06:38 +0800 (CST) Received: from a018.hihonor.com (10.68.17.250) by w001.hihonor.com (10.68.25.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 9 Sep 2025 17:07:03 +0800 Received: from localhost.localdomain (10.144.20.219) by a018.hihonor.com (10.68.17.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 9 Sep 2025 17:07:03 +0800 From: zhongjinji To: CC: , , , , , , , , , , , , , , , Subject: [PATCH v8 1/3] mm/oom_kill: Introduce thaw_oom_process() for thawing OOM victims Date: Tue, 9 Sep 2025 17:06:57 +0800 Message-ID: <20250909090659.26400-2-zhongjinji@honor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250909090659.26400-1-zhongjinji@honor.com> References: <20250909090659.26400-1-zhongjinji@honor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: w003.hihonor.com (10.68.17.88) To a018.hihonor.com (10.68.17.250) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" OOM killer is a mechanism that selects and kills processes when the system runs out of memory to reclaim resources and keep the system stable. However, the oom victim cannot terminate on its own when it is frozen, because __thaw_task() only thaws one thread of the victim, while the other threads remain in the frozen state. Since __thaw_task did not fully thaw the OOM victim for self-termination, introduce thaw_oom_process() to properly thaw OOM victims. Signed-off-by: zhongjinji Acked-by: Michal Hocko --- include/linux/freezer.h | 2 ++ kernel/freezer.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/freezer.h b/include/linux/freezer.h index b303472255be..19a4b57950cd 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -47,6 +47,7 @@ extern int freeze_processes(void); extern int freeze_kernel_threads(void); extern void thaw_processes(void); extern void thaw_kernel_threads(void); +extern void thaw_oom_process(struct task_struct *p); =20 static inline bool try_to_freeze(void) { @@ -80,6 +81,7 @@ static inline int freeze_processes(void) { return -ENOSYS= ; } static inline int freeze_kernel_threads(void) { return -ENOSYS; } static inline void thaw_processes(void) {} static inline void thaw_kernel_threads(void) {} +static inline void thaw_oom_process(struct task_struct *p) {} =20 static inline bool try_to_freeze(void) { return false; } =20 diff --git a/kernel/freezer.c b/kernel/freezer.c index 6a96149aede9..17970e0be8a7 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c @@ -206,6 +206,25 @@ void __thaw_task(struct task_struct *p) wake_up_state(p, TASK_FROZEN); } =20 +/* + * thaw_oom_process - thaw the OOM victim process + * @p: process to be thawed + * + * Sets TIF_MEMDIE for all threads in the process group and thaws them. + * Threads with TIF_MEMDIE are ignored by the freezer. + */ +void thaw_oom_process(struct task_struct *p) +{ + struct task_struct *t; + + rcu_read_lock(); + for_each_thread(p, t) { + set_tsk_thread_flag(t, TIF_MEMDIE); + __thaw_task(t); + } + rcu_read_unlock(); +} + /** * set_freezable - make %current freezable * --=20 2.17.1