From patchwork Wed Nov 12 18:58:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 5291421 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 89A78C11AC for ; Wed, 12 Nov 2014 18:59:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2AC4201DD for ; Wed, 12 Nov 2014 18:59:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3A12201E4 for ; Wed, 12 Nov 2014 18:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753298AbaKLS72 (ORCPT ); Wed, 12 Nov 2014 13:59:28 -0500 Received: from cantor2.suse.de ([195.135.220.15]:48118 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753468AbaKLS7B (ORCPT ); Wed, 12 Nov 2014 13:59:01 -0500 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7C44BAC24; Wed, 12 Nov 2014 18:59:00 +0000 (UTC) From: Michal Hocko To: LKML Cc: , linux-pm@vger.kernel.org, Tejun Heo , Andrew Morton , "\\\"Rafael J. Wysocki\\\"" , David Rientjes , Oleg Nesterov , Cong Wang Subject: [RFC 4/4] OOM: thaw the OOM victim if it is frozen Date: Wed, 12 Nov 2014 19:58:52 +0100 Message-Id: <1415818732-27712-5-git-send-email-mhocko@suse.cz> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1415818732-27712-1-git-send-email-mhocko@suse.cz> References: <20141110163055.GC18373@dhcp22.suse.cz> <1415818732-27712-1-git-send-email-mhocko@suse.cz> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP oom_kill_process only sets TIF_MEMDIE flag and sends a signal to the victim. This is basically noop when the task is frozen though because the task sleeps in uninterruptible sleep. The victim is eventually thawed later when oom_scan_process_thread meets the task again in a later OOM invocation so the OOM killer doesn't live lock. But this is less than optimal. Let's add the frozen check and thaw the task right before we send SIGKILL to the victim. The check and thawing in oom_scan_process_thread has to stay because the task might got access to memory reserves even without an explicit SIGKILL from oom_kill_process (e.g. it already has fatal signal pending or it is exiting already). Signed-off-by: Michal Hocko --- mm/oom_kill.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 39a591092ca0..67ea7fb70fa4 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -511,6 +511,8 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, rcu_read_unlock(); set_tsk_thread_flag(victim, TIF_MEMDIE); + if (frozen(victim)) + __thaw_task(victim); do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, true); put_task_struct(victim); }