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=-2.5 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 DDEC0C432C0 for ; Mon, 25 Nov 2019 09:38:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A8D7E207FD for ; Mon, 25 Nov 2019 09:38:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8D7E207FD 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 55E216B05CE; Mon, 25 Nov 2019 04:38:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 50E8D6B05CF; Mon, 25 Nov 2019 04:38:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 425B66B05D0; Mon, 25 Nov 2019 04:38:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id 2C9996B05CE for ; Mon, 25 Nov 2019 04:38:08 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id B96388249980 for ; Mon, 25 Nov 2019 09:38:07 +0000 (UTC) X-FDA: 76194298614.25.road20_6402b2f1b8924 X-HE-Tag: road20_6402b2f1b8924 X-Filterd-Recvd-Size: 5439 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 Nov 2019 09:38:07 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id i12so17130520wro.5 for ; Mon, 25 Nov 2019 01:38:07 -0800 (PST) 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:user-agent; bh=hrLqf+5z1RGNsS+CK/e7f8rVW0oyd7iFChGZ+CgiFkI=; b=K5hm3CTtcBXX4Iy5M2CQ/oPDQ1wrN+zn5Xtu3mVm0CKh4pBoDopJklab1s2GAIzxlI 7VCLOuO6z7taCDmk/Y91aecU82Vaefy3oBYP18Y3RXn/USmdPbq/c1XSJe7fPyYf50jg njbKIODI5icdlubqtyZvcoIxthx6waV9DH9KQT4/U6SWjmasfb5lE6iqANfuJ0lyq8x4 FZurKG66eYlWT+2gwc1ow9oY86gBHPNPDPGJlYLDatwx1zmdoerO/uJybzSSiBxc/DY+ m6wk46tRwkP7ETX0iH7WwPIP9Ly4Tej2jXriRRHGgggstx2NDFSzF4YUsNHN3j6JyOgT v3gg== X-Gm-Message-State: APjAAAV6sD/80FM727POM7dIQcPybn+m73PRx7nfmiXmJj3nOlarhOIt TWoZGYwEwClteaoW3dcCLffEF7AU X-Google-Smtp-Source: APXvYqzBHWQmZwoxHdk4fGp1qEhVh/1ZW3yzQZPWlwqQxaSFdSPtlGp4awnsPn9xZX0XOmpIewcY1w== X-Received: by 2002:adf:e609:: with SMTP id p9mr31198700wrm.241.1574674686189; Mon, 25 Nov 2019 01:38:06 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id 72sm10043602wrl.73.2019.11.25.01.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2019 01:38:05 -0800 (PST) Date: Mon, 25 Nov 2019 10:38:04 +0100 From: Michal Hocko To: Yafang Shao Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Linux MM Subject: Re: [PATCH] mm, memcg: don't protect pages if memcg is not populated Message-ID: <20191125093804.GG31714@dhcp22.suse.cz> References: <1574488602-11773-1-git-send-email-laoar.shao@gmail.com> <20191125081446.GA31714@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 Mon 25-11-19 17:11:14, Yafang Shao wrote: > On Mon, Nov 25, 2019 at 4:14 PM Michal Hocko wrote: > > > > On Sat 23-11-19 00:56:42, Yafang Shao wrote: > > > memory.{min, low} keeps protecting pages in a memcg even if there're no > > > process running in this memcg. That makes nonsense, because if there're > > > no processes running in this memcg there may be something wrong happens > > > and these protected pages are not useful now. > > > > Well, the min resp. low limits protect charges rather than tasks. And > > thre are cases when there is no direct relation between the charged > > memory and a specific task - e.g. long living kernel objects or page > > cache. So there is nothing really unusual to have charges in an absence > > of any tasks. I do not really see any reason why the protection > > shouldn't apply to them. Such a be behavior would be quite inconsistent > > btw. Just imagine a case when there is _a_ task but that one doesn't > > really have any charges in the memcg. Why should we respect reclaim > > protection in that case? > > > > Per my understanding, the memory.{min, low} is used to protect the workload. > I don't know in which cases we protect the 'content' only. I didn't say anything about the content. You are right that those limits are protecting a working set. I do not think it would be hard to imagine a workload which has a page cache to be the working set and want to protect it while tasks are only very short lived and so "no tasks" state wouldn't be all that unusual. > If one memcg is used to protect the content only, e.g. some file > caches, then these file caches will be shared by processes in > different memcgs, that may cause some unexpected issues, for example, > how to handle the writeback throttle ? Yes, sharing might lead to surprising behavior but I do not not understand how this is really related to the proposed patch. > I don't know how to use memory.{min, low} to protect long living > kernel objects neither without any processes. > > I would appreciate if you could explain my questions in detail. See the example above. > > Btw. offlined memcgs already have no min/low watermarks protect. > > > > Do you have any specific usecase that suffers from this behavior? > > > > For example, if oom happens, the processes in this memcg may be killed > by OOM killer, and if memory.oom.group is set, all processes in it > will be killed. So these protected pages are useless. In that cases, > we should clear memory.{min, low} protection. I do agree that the reclaim protection might lead to an unexpected OOM handling. Especially when charged objects are not directly bound to the process life time. But this patch is not going to help here in general. One has to be really careful when configuring the protection. It is a hard guarantee after all. -- Michal Hocko SUSE Labs