Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp435670ybh; Wed, 18 Mar 2020 02:43:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvuTiIzrpq5j5imD8woPcRPYm9q+CuwByRNRLieGa2PrFEoyBL3tlynZsL6a8H0ON+30SEo X-Received: by 2002:a9d:b8f:: with SMTP id 15mr3019092oth.256.1584524588421; Wed, 18 Mar 2020 02:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584524588; cv=none; d=google.com; s=arc-20160816; b=B7SbZr19MRVPhfKEdV2s1G0IqDEO0+m060c5nVHTWShb6apN/GdE78grklxIEPIR5+ suwvZVhirx2u50yACNAlvAGvYrRA4XNu6u0aa2+gkR4zYrn560p8FPpQgxHGVNuO1pm1 MWtb6NsrL119/hcnjnigV13cdSsRIc1Dn5lKuo4R0GW8NMxQL36N6Mi/yyjEvyuAo4rm BqeOxmYLzd+DofqvP+X/wlZdOI3HGJUKZf1s/csB9SsfR9yoEwupXB2jQIV6C9SrTfaZ FkszZZ9qBxMN2ZnRCNrNajniDRWp/PkSmnhPXtEshAXck470LOAFUfkdR3k8GLe+DUHu AEnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ljtseRed9kkl1p0LldSZEtHZ23CStZbRjiW3J11/rXg=; b=sqtHdzz6X2Qr4iwp98iFgy3Pi/wkPfDV0xICV/zpmuKXJaECFM3/lL5pFQNBximAXO 3ey7erNi3BsLsCeW4uc3b64ZG7jM8r17/w0W8ie6UURU8QNw9bRL3d1KblvWr2AzIvWZ Fw1S+wr83xWaNkQtE1uGdcj3lRx9z/zyuDtCHCOj/pcDnCcPv6EoCL0W4DOCRlwhZs09 k+Bk3CM1VbGlstl74yAK7mqxzNrBwR00xGg4TGfXcCTyZAcWjBp5B7hEBL0y47SlnARh OZ5pK98ykKmxcABf/Tt1hhoL1875Vx4bF+qHU3XwzHNwyn4SiyQm/wMvP+SITC6p5EzL 94Kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w188si1158637oig.183.2020.03.18.02.42.57; Wed, 18 Mar 2020 02:43:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727577AbgCRJmX (ORCPT + 99 others); Wed, 18 Mar 2020 05:42:23 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:36734 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbgCRJmX (ORCPT ); Wed, 18 Mar 2020 05:42:23 -0400 Received: by mail-wm1-f65.google.com with SMTP id g62so2460439wme.1 for ; Wed, 18 Mar 2020 02:42:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ljtseRed9kkl1p0LldSZEtHZ23CStZbRjiW3J11/rXg=; b=oJn+BGjGXGXSSPNpPKMNPXWGrT/w5tTU/FjilRJXEmdETT9UBg+kn0YL/PILwnrpY7 DgDI2LqjY/qH6fwjda7IKItg8lkO0imLN4Ip68O58SFltjfSyt0mLf2slVs3V/yP1guV 9p49JxfzRxd+Nt+9Prm35YctH5b4GC5ZYougLjKhG9jns8ksw+vD2zUf2frl1dHekXcT 94xsQ7yzP4aajzce4k2pEOnwZ4sOvyQCxyHntFACsYa3lmTi9JyTudRMtxq2d54vp+oR Tk87oM1zxZEllj5VY3XnBwCWfnpGWejuKxu98X6112kgIWOD5ly/Fx9iH/6+0yMg3N/a 3V0w== X-Gm-Message-State: ANhLgQ2qlRWsg+vvpV6bee8i2wfcDk8GwvdRNk4EGiyoeLKIGjcopazA y+P/PvthgOkkvYg0M7+uw8k= X-Received: by 2002:a1c:491:: with SMTP id 139mr4410440wme.21.1584524541504; Wed, 18 Mar 2020 02:42:21 -0700 (PDT) Received: from localhost (ip-37-188-180-89.eurotel.cz. [37.188.180.89]) by smtp.gmail.com with ESMTPSA id q9sm2636789wmg.41.2020.03.18.02.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 02:42:20 -0700 (PDT) Date: Wed, 18 Mar 2020 10:42:19 +0100 From: Michal Hocko To: David Rientjes Cc: Andrew Morton , Tetsuo Handa , Vlastimil Babka , Robert Kolchmeyer , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch v2] mm, oom: prevent soft lockup on memcg oom for UP systems Message-ID: <20200318094219.GE21362@dhcp22.suse.cz> References: <8395df04-9b7a-0084-4bb5-e430efe18b97@i-love.sakura.ne.jp> <202003170318.02H3IpSx047471@www262.sakura.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 17-03-20 17:55:04, David Rientjes wrote: > When a process is oom killed as a result of memcg limits and the victim > is waiting to exit, nothing ends up actually yielding the processor back > to the victim on UP systems with preemption disabled. Instead, the > charging process simply loops in memcg reclaim and eventually soft > lockups. It seems that my request to describe the setup got ignored. Sigh. > Memory cgroup out of memory: Killed process 808 (repro) total-vm:41944kB, > anon-rss:35344kB, file-rss:504kB, shmem-rss:0kB, UID:0 pgtables:108kB > oom_score_adj:0 > watchdog: BUG: soft lockup - CPU#0 stuck for 23s! [repro:806] > CPU: 0 PID: 806 Comm: repro Not tainted 5.6.0-rc5+ #136 > RIP: 0010:shrink_lruvec+0x4e9/0xa40 > ... > Call Trace: > shrink_node+0x40d/0x7d0 > do_try_to_free_pages+0x13f/0x470 > try_to_free_mem_cgroup_pages+0x16d/0x230 > try_charge+0x247/0xac0 > mem_cgroup_try_charge+0x10a/0x220 > mem_cgroup_try_charge_delay+0x1e/0x40 > handle_mm_fault+0xdf2/0x15f0 > do_user_addr_fault+0x21f/0x420 > page_fault+0x2f/0x40 > > Make sure that once the oom killer has been called that we forcibly yield > if current is not the chosen victim regardless of priority to allow for > memory freeing. The same situation can theoretically occur in the page > allocator, so do this after dropping oom_lock there as well. I would have prefered the cond_resched solution proposed previously but I can live with this as well. I would just ask to add more information to the changelog. E.g. " We used to have a short sleep after the oom handling but 9bfe5ded054b ("mm, oom: remove sleep from under oom_lock") has removed it because sleep inside the oom_lock is dangerous. This patch restores the sleep outside of the lock. " > Suggested-by: Tetsuo Handa > Tested-by: Robert Kolchmeyer > Cc: stable@vger.kernel.org > Signed-off-by: David Rientjes > --- > mm/memcontrol.c | 2 ++ > mm/page_alloc.c | 2 ++ > 2 files changed, 4 insertions(+) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1576,6 +1576,8 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, > */ > ret = should_force_charge() || out_of_memory(&oc); > mutex_unlock(&oom_lock); > + if (!fatal_signal_pending(current)) > + schedule_timeout_killable(1); Check for fatal_signal_pending is redundant. -- Michal Hocko SUSE Labs