Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4217018pxk; Tue, 8 Sep 2020 13:54:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypz+/5+LRoetmupVt6hqwPr1grU8nuNTDgQ+/sr3cXJ1/D+VsIQuoZhwDIyWBpE7x91zTO X-Received: by 2002:a17:907:3301:: with SMTP id ym1mr302391ejb.367.1599598471177; Tue, 08 Sep 2020 13:54:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599598471; cv=none; d=google.com; s=arc-20160816; b=Y1XkAN4wI2c4To0tmEwmFsoJ8FJqZiOIYLoqYPj7U+U+kgeu3ReS2TvK4qEYAqdBEk tFf0hNWF0RxLBIjOtA/3b+PoJHCHhMKngFVo455fJqtJD8t1fuD++Wzz3lhh4pWcHbYn HyFxBA5j5JmooJTxiU4qhl4GG9JRJPse/nuTCL9WRUEE9Woxwnl52qIBHk3ITT8Fk3/x Ho2cmkh5J8flqbsiWTKGHzLJid02WMKRRTxnumIywfO3V5GWV13YSHQ7U1hC0uYY/a62 GSfklc3Mp5jLw5fFR4JziLwqnEa8uENxbU0b+oWupUkOLPr87F7ThKXINK8CPtvBOgTK oi6A== 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=pI1eQi93oHqIt0ttUjCU3nFKvEFIAoFNnJkgWRGBS+g=; b=T3jw6LKW6lfkQv3WgabDjyOcpvbFX+YzxIjLyKtZOHssAsOKv6s/fJZSpsD+NwureN FT+rH5g7rDjm/OqhUVPWwwttCZKDIakLSXI4rR4DRJfdRuyQ36CYhrUpDcOXFYwDGd8P JQi7nD0ySydtFKsV1TfTVuLTvlnkuyiaYk0rfTkpM6lux928KwRc7F2DXtjbTMuABQvK m5vVxuI5mIPentq4zeTKS7LyjzOzFwe89HQVl9rFdDG2LOCTElDhw4MUBDqZ/7arQGGP /96Dzmclv9esNfsd8yInPdS67+YOJ8Jlzc2cr4W5dHwmfl5bpuK8qLhOkhIB1YFnk6pi hp3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zl3si114113ejb.374.2020.09.08.13.54.09; Tue, 08 Sep 2020 13:54:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730400AbgIHUxO (ORCPT + 99 others); Tue, 8 Sep 2020 16:53:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:33328 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729912AbgIHUxN (ORCPT ); Tue, 8 Sep 2020 16:53:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 02C86ADC5; Tue, 8 Sep 2020 20:53:12 +0000 (UTC) Date: Tue, 8 Sep 2020 22:53:10 +0200 From: Michal Hocko To: Yang Shi Cc: Julius Hemanth Pitti , Johannes Weiner , Vladimir Davydov , Andrew Morton , Roman Gushchin , Cgroups , Linux MM , Linux Kernel Mailing List , xe-linux-external@cisco.com Subject: Re: [PATCH v2] mm: memcg: yield cpu when we fail to charge pages Message-ID: <20200908205310.GF26850@dhcp22.suse.cz> References: <20200908201426.14837-1-jpitti@cisco.com> 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 08-09-20 13:31:51, Yang Shi wrote: > On Tue, Sep 8, 2020 at 1:14 PM Julius Hemanth Pitti wrote: > > > > For non root CG, in try_charge(), we keep trying > > to charge until we succeed. On non-preemptive > > kernel, when we are OOM, this results in holding > > CPU forever. > > > > On SMP systems, this doesn't create a big problem > > because oom_reaper get a change to kill victim > > and make some free pages. However on a single-core > > CPU (or cases where oom_reaper pinned to same CPU > > where try_charge is executing), oom_reaper shall > > never get scheduled and we stay in try_charge forever. > > > > Steps to repo this on non-smp: > > 1. mount -t tmpfs none /sys/fs/cgroup > > 2. mkdir /sys/fs/cgroup/memory > > 3. mount -t cgroup none /sys/fs/cgroup/memory -o memory > > 4. mkdir /sys/fs/cgroup/memory/0 > > 5. echo 40M > /sys/fs/cgroup/memory/0/memory.limit_in_bytes > > 6. echo $$ > /sys/fs/cgroup/memory/0/tasks > > 7. stress -m 5 --vm-bytes 10M --vm-hang 0 > > Isn't it the same problem solved by e3336cab2579 ("mm: memcg: fix > memcg reclaim soft lockup")? It has been in Linus's tree. Yes it should because it adds a scheduling point regardless of reclaimability. > > Signed-off-by: Julius Hemanth Pitti > > Acked-by: Roman Gushchin > > --- > > > > Changes in v2: > > - Added comments. > > - Added "Acked-by: Roman Gushchin ". > > --- > > mm/memcontrol.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index cfa6cbad21d5..4f293bf8c7ed 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -2745,6 +2745,15 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, > > if (fatal_signal_pending(current)) > > goto force; > > > > + /* > > + * We failed to charge even after retries, give oom_reaper or > > + * other process a change to make some free pages. > > + * > > + * On non-preemptive, Non-SMP system, this is critical, else > > + * we keep retrying with no success, forever. > > + */ > > + cond_resched(); > > + > > /* > > * keep retrying as long as the memcg oom killer is able to make > > * a forward progress or bypass the charge if the oom killer > > -- > > 2.17.1 > > > > -- Michal Hocko SUSE Labs