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 D203DC432C3 for ; Tue, 26 Nov 2019 09:36:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 98BD720722 for ; Tue, 26 Nov 2019 09:36:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="klHKM3Lb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98BD720722 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 36F5A6B02CF; Tue, 26 Nov 2019 04:36:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 31F9E6B02D0; Tue, 26 Nov 2019 04:36:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 266A26B02D1; Tue, 26 Nov 2019 04:36:37 -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 0D7506B02CF for ; Tue, 26 Nov 2019 04:36:37 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id BE59F8249980 for ; Tue, 26 Nov 2019 09:36:36 +0000 (UTC) X-FDA: 76197923592.19.cent50_90fdcc5558908 X-HE-Tag: cent50_90fdcc5558908 X-Filterd-Recvd-Size: 5710 Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 26 Nov 2019 09:36:36 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id i11so8866024ioi.12 for ; Tue, 26 Nov 2019 01:36:36 -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=TlltnUyL0lNXKgvrNg2repXq6I4I6PrEyBkxcZJ0hAs=; b=klHKM3LbS95I35mvLxoh03c5mxqVKaep1xpu/T+duGqkLVe6xgbmjKvnrbVq0loj8X H0U44d0z1Naj2IaBYS8TKsg6wy+dV3s3VBs7r/UBpHEwAqJVr3/28JRaCO4Xfw2DIUjl 5F1sIVCD86vsve2ID3p9VOKpA+WP8ZT75bKvUkEN3MHIy1BxfyrwnF2n0GSKjeOsohyN 5/ZRGBNM6nzw5JudTUa+6kD2TxRlRDlThGR5KggIiwl3cI2aclr/L8YAJEly2uGs2QZJ 5Dwovj8iipDKDz1JsTO19u3kaCdv2KVHE97Fpt0SrrP08BCY2nFHW/aKwlFn9OleKM6q ouZQ== 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=TlltnUyL0lNXKgvrNg2repXq6I4I6PrEyBkxcZJ0hAs=; b=QMjQOsXydVB64Giw6N+lNx1JiblREewBJ5A9USetJUIL6sz/FVAkrEFjyrKgzD75KB d3mtvN6JHNuVo3wBaKkN0426Nwbrm9WWBc3iMJkLUO/8Lh6KjxWqC1g5J/5KZ6lA4AcQ N7sKjSXcdB5L+tYqtEB0ENI/gOzj1Vqk7lnzAn+tc5+ygIKKqErtlCKguWPrcEcMSeZ1 1MsolGPueRo6mEhIMaZLmhnURqXzexIr8Jp4GSDHmIfQ2mwqJnPb6LZxGdAqDUjpwppN VIivCwH++t4jJzjCVSUhyKLHYuF46vqJVKJEUGkbON467Q/cRj9PELbAfc/sqym14BKH iZ2g== X-Gm-Message-State: APjAAAXBkUsLEZAQdj46lkPdDYjRi0IKl4VHWA81mAdzXJn0zPGjwXNo dryanAddIJfTvHQltE0hoH7m1oYpRKWHs5Q7arh/NyFC780= X-Google-Smtp-Source: APXvYqydMlQKDIV627yoH1sK2ftZ/9mFBubAHxIEV9ep70Hxm/Hk16NgAYSl04DB9dfy3WV/lK54Et75XpcUR22TUy4= X-Received: by 2002:a5d:9909:: with SMTP id x9mr14890692iol.93.1574760995725; Tue, 26 Nov 2019 01:36:35 -0800 (PST) MIME-Version: 1.0 References: <20191125115409.GJ31714@dhcp22.suse.cz> <20191125123123.GL31714@dhcp22.suse.cz> <20191125124553.GM31714@dhcp22.suse.cz> <20191125142150.GP31714@dhcp22.suse.cz> <20191125144213.GB602168@cmpxchg.org> <20191126073129.GA20912@dhcp22.suse.cz> In-Reply-To: <20191126073129.GA20912@dhcp22.suse.cz> From: Yafang Shao Date: Tue, 26 Nov 2019 17:35:59 +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 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, @@ -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; + } } 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. Thanks Yafang Thanks Yafang