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=-0.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 47945C432C3 for ; Tue, 26 Nov 2019 10:56:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB09520722 for ; Tue, 26 Nov 2019 10:56:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D3Ga8k23" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB09520722 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8FED86B02DD; Tue, 26 Nov 2019 05:56:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 888406B02DE; Tue, 26 Nov 2019 05:56:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 777936B02DF; Tue, 26 Nov 2019 05:56:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 5C31A6B02DD for ; Tue, 26 Nov 2019 05:56:54 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id D1B0B180AD81A for ; Tue, 26 Nov 2019 10:56:53 +0000 (UTC) X-FDA: 76198125906.08.tin38_765ba444db430 X-HE-Tag: tin38_765ba444db430 X-Filterd-Recvd-Size: 8336 Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Tue, 26 Nov 2019 10:56:53 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id z193so20051122iof.1 for ; Tue, 26 Nov 2019 02:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RfQaiOrK8HNIt3HotDHUv/NP7OxJDV3pRPZ7Xj4RCMM=; b=D3Ga8k232azUlGZZHk4Roo3BEEG/15A0N3TtkVOmTtxp/LIOEloCA76dGIiPkSe07p SgUYC7I+8Vpb2OF4uNkmHEqOt025GM8eXvX1ThKCfJPsmci0U+LcVUe4J2FYWcsu0m52 GOjz/sjBTF34m9XSJQnUfcP1wQvTEBv1V4VhsheXzJDTc+Ol0HYyyP6st7mQ9olXPvrS a2TAEcqW1oPuknj/6rmGj1tyEfuhlI6+RGD+LDMlVFQsOo1TtcC0U1Aze2GUVeJDExDx 2VgyEq/ONkgnuy5Fi7oRvGbcv3DA/kaVx9z7vsqXaPbmhMgkZO8dDcbivauKDh7B1u8J vzDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RfQaiOrK8HNIt3HotDHUv/NP7OxJDV3pRPZ7Xj4RCMM=; b=Xuf8QTsUhLjqS6cL6kSKR5zadENCZQ8cFh5ptp1da6ef2sRlyvamy9VeLA/W+6RFKF U7P3yqAbf3G8SY6xYJeaU3kq2l7QYEp0Jx0gtX4Nh0//jj564Z/RHXJ8o3DQJ80LCliL TP2ofb53UgJtedaIoicl1Icujidhgsp6JAnfPPHanVleo9xijO+Llhs4U7WaR3xw9Id1 rAdrUMZZ84nUNYBDmWUUf6G4edxhhDb4iozwBYPUpk00mJE0IuD2Yf6h+2fQv/WrL1S3 MUCjfrTzR21jZcyCxD4ijBquip1k2R421vk8yzWXklftpoWRkgdusUPgp7f9hnWJpDni 99fg== X-Gm-Message-State: APjAAAUZvNu+uH9jYx8nbtZeHRDHTioeQN5qCr8O+TJu9quSpF4hYrtA 3HgByGW2TQoxXLvBNNeDHzNtHCoLm3xWxcH9yVNFPuMlqpE= X-Google-Smtp-Source: APXvYqyaGYUvzI1QBf/88ObJRZrbybAI+joLcwuN3Ltp4wk1hWsijm75myMWftD6Bhmme0seG772/S2bVQyO+nsD5dQ= X-Received: by 2002:a5d:8953:: with SMTP id b19mr4109512iot.168.1574765812485; Tue, 26 Nov 2019 02:56:52 -0800 (PST) MIME-Version: 1.0 References: <20191125124553.GM31714@dhcp22.suse.cz> <20191125142150.GP31714@dhcp22.suse.cz> <20191125144213.GB602168@cmpxchg.org> <20191126073129.GA20912@dhcp22.suse.cz> <20191126095033.GC20912@dhcp22.suse.cz> <20191126102213.GD20912@dhcp22.suse.cz> In-Reply-To: <20191126102213.GD20912@dhcp22.suse.cz> From: Yafang Shao Date: Tue, 26 Nov 2019 18:56:16 +0800 Message-ID: Subject: Re: [PATCH] mm, memcg: clear page protection when memcg oom group happens To: Michal Hocko Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Linux MM Content-Type: text/plain; charset="UTF-8" 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, Nov 26, 2019 at 6:22 PM Michal Hocko wrote: > > On Tue 26-11-19 18:02:27, Yafang Shao wrote: > > On Tue, Nov 26, 2019 at 5:50 PM Michal Hocko wrote: > > > > > > On Tue 26-11-19 17:35:59, Yafang Shao wrote: > > > > On Tue, Nov 26, 2019 at 3:31 PM Michal Hocko wrote: > > > > > > > > > > On Tue 26-11-19 11:52:19, Yafang Shao wrote: > > > > > > On Mon, Nov 25, 2019 at 10:42 PM Johannes Weiner wrote: > > > > > > > > > > > > > > On Mon, Nov 25, 2019 at 03:21:50PM +0100, Michal Hocko wrote: > > > > > > > > On Mon 25-11-19 22:11:15, Yafang Shao wrote: > > > > > > > > > When there're no processes, we don't need to protect the pages. You > > > > > > > > > can consider it as 'fault tolerance' . > > > > > > > > > > > > > > > > I have already tried to explain why this is a bold statement that > > > > > > > > doesn't really hold universally and that the kernel doesn't really have > > > > > > > > enough information to make an educated guess. > > > > > > > > > > > > > > I agree, this is not obviously true. And the kernel shouldn't try to > > > > > > > guess whether the explicit userspace configuration is still desirable > > > > > > > to userspace or not. Should we also delete the cgroup when it becomes > > > > > > > empty for example? > > > > > > > > > > > > > > It's better to implement these kinds of policy decisions from > > > > > > > userspace. > > > > > > > > > > > > > > There is a cgroup.events file that can be polled, and its "populated" > > > > > > > field shows conveniently whether there are tasks in a subtree or > > > > > > > not. You can use that to clear protection settings. > > > > > > > > > > > > Why isn't force_empty supported in cgroup2 ? > > > > > > > > > > There wasn't any sound usecase AFAIR. > > > > > > > > > > > In this case we can free the protected file pages immdiately with force_empty. > > > > > > > > > > You can do the same thing by setting the hard limit to 0. > > > > > > > > I look though the code, and the difference between setting the hard > > > > limit to 0 and force empty is that setting the hard limit to 0 will > > > > generate some OOM reports, that should not happen in this case. > > > > I think we should make little improvement as bellow, > > > > > > Yes, if you are not able to reclaim all of the memory then the OOM > > > killer is triggered. And that was not the case with force_empty. I > > > didn't mean that the two are equivalent, sorry if I misled you. > > > I merely wanted to point out that you have means to cleanup the memcg > > > with the existing API. > > > > > > > @@ -6137,9 +6137,11 @@ static ssize_t memory_max_write(struct > > > > kernfs_open_file *of, > > > > continue; > > > > } > > > > > > > > - memcg_memory_event(memcg, MEMCG_OOM); > > > > - if (!mem_cgroup_out_of_memory(memcg, GFP_KERNEL, 0)) > > > > - break; > > > > + if (cgroup_is_populated(memcg->css.cgroup)) { > > > > + memcg_memory_event(memcg, MEMCG_OOM); > > > > + if (!mem_cgroup_out_of_memory(memcg, GFP_KERNEL, 0)) > > > > + break; > > > > + } > > > > } > > > > > > If there are no killable tasks then > > > "Out of memory and no killable processes..." > > > is printed and that really reflects the situation and is the right thing > > > to do. Your above patch would suppress that information which might be > > > important. > > > > > > > Not only this output. > > Pls. see dump_header(), many outputs and even worse is that the > > dump_stack() is also executed. > > Yes, there will be the full oom report. I have outlined the "no > killable" part because this is the main distinguisher for the "no tasks" > case. > But the case here is there is "no tasks" (!cgroup_is_populated(memcg->css.cgroup)), rather than "no killable". This output is really a misleading. > > > > Well, if someone don't want to kill proesses but only want ot drop > > > > page caches, setting the hard limit to 0 won't work. > > > > > > Could you be more specific about a real world example when somebody > > > wants to drop per-memcg pagecache? > > > > For example, if one memcg has lots of negtive denties, that causes > > the file page cache continuesly been reclaimed, so we want to drop all > > these negtive dentries. force_empty is a better workaround so far, and > > that can give us more chance to analyze why negtive dentries are > > generated. > > force_empty sounds like a brute force to clean negative dentries TBH. > And it is not really way too much different from shrinking the hard > limit. > > Why doesn't a normal reclaim work for those situation? Anyway, this is > getting really tangent to the original topic so I would suggest to start > a new email thread with a clear description of a problem you are facing > and we can go from there. Sure. I will start a new thread.