From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B833C10DCE for ; Wed, 18 Mar 2020 09:42:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 15A3220674 for ; Wed, 18 Mar 2020 09:42:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15A3220674 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 97BD96B006C; Wed, 18 Mar 2020 05:42:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92D276B006E; Wed, 18 Mar 2020 05:42:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81AC46B0070; Wed, 18 Mar 2020 05:42:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id 6B5F56B006C for ; Wed, 18 Mar 2020 05:42:23 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 38CCD2C94 for ; Wed, 18 Mar 2020 09:42:23 +0000 (UTC) X-FDA: 76607992566.29.brass38_4eff7fb80db09 X-HE-Tag: brass38_4eff7fb80db09 X-Filterd-Recvd-Size: 5230 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Wed, 18 Mar 2020 09:42:22 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id 11so2441306wmo.2 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=PGnFsvdBUE1mfiHxzudq9bZvyUx3oMJqS2nDeuu4wirHm+GQTrBEiVk5G7hKoS3Oog qyA+Q+TJBOZcN/WxCfdMgTdqgMb+IQWs6f39OEiaaKN99nMI82YlU0o8WjzEagKZBoaX sMtz5bH+gjWDgJg1pjub6iUarjq534DTmukaUwqZeN69ArNt3r2okizwdeDvygEBoFSD c2JvUpIJ/aqil+awRmkCWcLrOxIU+C1AHjocEkTorif4O89eY/0xGJi275gwcAK7JZAb eao8MPlR/gsq8xiyry25bNzFXK2/YSaqtwEcYo7S2k/g5Mfhjdz7AniTqLyxLfBWGOMR 7W/g== X-Gm-Message-State: ANhLgQ14SArACuO60kErKtRNLaM/HPNhoMXggn4ib3AeE90HvvSykoie a+JSVVLr9uOFiK6Hq4OQZ+s= X-Google-Smtp-Source: ADFU+vvP3LS0LaEjrw/WAD9Qk7RHGbGtBAt4Jjsh8GMY5tqbX5OV2LjVXH2YVK16i3+uApOFqMuWmg== 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: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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