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=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 A4F4AC3815B for ; Mon, 20 Apr 2020 08:13:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 71E9620BED for ; Mon, 20 Apr 2020 08:13:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71E9620BED 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 1C0A58E0006; Mon, 20 Apr 2020 04:13:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16F158E0003; Mon, 20 Apr 2020 04:13:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 085078E0006; Mon, 20 Apr 2020 04:13:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id E24498E0003 for ; Mon, 20 Apr 2020 04:13:56 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9CA381F1A for ; Mon, 20 Apr 2020 08:13:56 +0000 (UTC) X-FDA: 76727520072.09.prose97_3f82da65e3347 X-HE-Tag: prose97_3f82da65e3347 X-Filterd-Recvd-Size: 4125 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Mon, 20 Apr 2020 08:13:56 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id t14so10893088wrw.12 for ; Mon, 20 Apr 2020 01:13:56 -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=2AaRnlbNp/NUxCsknLYXGy373bIHnoL38xs8tHfqC90=; b=qbelq7/ltpu5aB/Y4vu4ql8FtFMVcVkQ6dBapLLIXri1FVPedND6eL6pKgpUFZHWU0 hWzt+CmqECZodsYl+9w8tkzvkNBjbT8RQBq7siiXnyUb7Pjn90pzU/a92iWzCgIvllmn 5Thh7NwPw7hgQSv/wD9zyp1/acwcmVrEOoM9CSlnXDQbiwkcmnEmTxbrRV4Kyr4JUeoU c2CVrkmnUeslWBQKuHr3/NHYAyQoKrNxMMo9ZBqM9zChU2eCdkJ40JphAYs28w8nxs09 d10JgpXgPyOR16Ftq5YpLAc/di8kSHeJMW9hcQ+F3YWEIFDcPrYmWt9WvIv9+uyxKXUy yL5g== X-Gm-Message-State: AGi0PuY0xMVwmNPRXh7OSYqvRinvRWSUTan8aCj6XNdW1ZNLyCqGW+4j o8W4sRZt0BYRyCeWdmpuzVYZDNfB X-Google-Smtp-Source: APiQypKULyENCBaipjG3LiZ072UpCqww/53XrjUthIzY2/+JJQY1LzAtKWYT7lxcHd+4TOewoq5POQ== X-Received: by 2002:a5d:4092:: with SMTP id o18mr9557319wrp.227.1587370435267; Mon, 20 Apr 2020 01:13:55 -0700 (PDT) Received: from localhost (ip-37-188-130-62.eurotel.cz. [37.188.130.62]) by smtp.gmail.com with ESMTPSA id x23sm373121wmj.6.2020.04.20.01.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 01:13:54 -0700 (PDT) Date: Mon, 20 Apr 2020 10:13:53 +0200 From: Michal Hocko To: Yafang Shao Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: Re: [PATCH 3/3] memcg oom: bail out from the charge path if no victim found Message-ID: <20200420081353.GI27314@dhcp22.suse.cz> References: <20200418151311.7397-1-laoar.shao@gmail.com> <20200418151311.7397-4-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200418151311.7397-4-laoar.shao@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat 18-04-20 11:13:11, Yafang Shao wrote: > Without considering the manually triggered OOM, if no victim found in > system OOM, the system will be deadlocked on memory, however if no > victim found in memcg OOM, it can charge successfully and runs well. > This behavior in memcg oom is not proper because that can prevent the > memcg from being limited. > > Take an easy example. > $ cd /sys/fs/cgroup/foo/ > $ echo $$ > cgroup.procs > $ echo 200M > memory.max > $ cat memory.max > 209715200 > $ echo -1000 > /proc/$$/oom_score_adj > Then, let's run a memhog task in memcg foo, which will allocate 1G > memory and keeps running. > $ /home/yafang/test/memhog & Well, echo -1000 is a privileged operation. And it has to be used with an extreme care because you know that you are creating an unkillable task. So the above test is a clear example of the misconfiguration. > Then memory.current will be greater than memory.max. Run bellow command > in another shell. > $ cat /sys/fs/cgroup/foo/memory.current > 1097228288 > The tasks which have already allocated memory and won't allocate new > memory still runs well. This behavior makes nonsense. > > This patch is to improve it. > If no victim found in memcg oom, we should force the current task to > wait until there's available pages. That is similar with the behavior in > memcg1 when oom_kill_disable is set. The primary reason why we force the charge is because we _cannot_ wait indefinitely in the charge path because the current call chain might hold locks or other resources which could block a large part of the system. You are essentially reintroducing that behavior. Is the above example a real usecase or you have just tried a test case that would trigger the problem? -- Michal Hocko SUSE Labs