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=-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 A67CFC432C0 for ; Mon, 25 Nov 2019 12:45:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5A9922075C for ; Mon, 25 Nov 2019 12:45:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A9922075C 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 D0BE76B05D1; Mon, 25 Nov 2019 07:45:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CBCFE6B05D3; Mon, 25 Nov 2019 07:45:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD1556B05D4; Mon, 25 Nov 2019 07:45:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id A4D916B05D1 for ; Mon, 25 Nov 2019 07:45:57 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 5361E8249980 for ; Mon, 25 Nov 2019 12:45:57 +0000 (UTC) X-FDA: 76194771954.04.kick85_8b34536b36649 X-HE-Tag: kick85_8b34536b36649 X-Filterd-Recvd-Size: 6685 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 Nov 2019 12:45:56 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id b11so5852642wmj.4 for ; Mon, 25 Nov 2019 04:45:56 -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=lLOQ/oAkkQm0jTZ7BPfTdfwwDrI7r6qBN4Sp8pj58Mk=; b=IL4e7YUx5bkz/qC6Ue9EVHA6sGrlLkhTxQSlu+kMXK4ixH1jjgxiBU3j7mMQwlfvNc NCMcU2DNUsy+Kg9opBIWYoLVKRwIM7hHLERdxkEF/9QHuczK+QtMuV8yC7f/FQHPL+PW kOzlw/Va4ElsRlJ58E1noJX8TgAtH1f31/xe1FAziGEpURhc3gzGQsy5Kg6jPSZIgUSE 30gdtdfbaqbyLoOb9Dm5TAsFmlNzRLVZqhyN+sZtCxaFxEekVKp4KQDqnXKV7wqlnyUQ tbJFZHwrJr35eeJj76fsMnrKtcOBYrgR2o76Wi7OmAHL2aWo5jEALxgxcDkIAn7aZweL iT4g== X-Gm-Message-State: APjAAAWSNXOsqouzblS1huwWauL7HBDGAmlV1uGjQTfviFWHnebV8gyi NGkoeDBDSKJzrR99Mp5LOBc= X-Google-Smtp-Source: APXvYqyyvozlyNwGhHzxfNjUFYKZYK8qcXxViCYBKcTCz55YaS66a/rJo+4q0S8CJjj+g5LD4sXqLQ== X-Received: by 2002:a05:600c:2201:: with SMTP id z1mr23369941wml.68.1574685955287; Mon, 25 Nov 2019 04:45:55 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id w7sm9953767wru.62.2019.11.25.04.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2019 04:45:54 -0800 (PST) Date: Mon, 25 Nov 2019 13:45:53 +0100 From: Michal Hocko To: Yafang Shao Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Linux MM Subject: Re: [PATCH] mm, memcg: clear page protection when memcg oom group happens Message-ID: <20191125124553.GM31714@dhcp22.suse.cz> References: <1574676893-1571-1-git-send-email-laoar.shao@gmail.com> <20191125110848.GH31714@dhcp22.suse.cz> <20191125115409.GJ31714@dhcp22.suse.cz> <20191125123123.GL31714@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 20:37:52, Yafang Shao wrote: > On Mon, Nov 25, 2019 at 8:31 PM Michal Hocko wrote: > > > > On Mon 25-11-19 20:17:15, Yafang Shao wrote: > > > On Mon, Nov 25, 2019 at 7:54 PM Michal Hocko wrote: > > > > > > > > On Mon 25-11-19 19:37:59, Yafang Shao wrote: > > > > > On Mon, Nov 25, 2019 at 7:08 PM Michal Hocko wrote: > > > > > > > > > > > > On Mon 25-11-19 05:14:53, Yafang Shao wrote: > > > > > > > We set memory.oom.group to make all processes in this memcg are killed by > > > > > > > OOM killer to free more pages. In this case, it doesn't make sense to > > > > > > > protect the pages with memroy.{min, low} again if they are set. > > > > > > > > > > > > I do not see why? What does group OOM killing has anything to do with > > > > > > the reclaim protection? What is the actual problem you are trying to > > > > > > solve? > > > > > > > > > > > > > > > > The cgroup is treated as a indivisible workload when cgroup.oom.group > > > > > is set and OOM killer is trying to kill a prcess in this cgroup. > > > > > > > > Yes this is true. > > > > > > > > > We set cgroup.oom.group is to guarantee the workload integrity, now > > > > > that processes ara all killed, why keeps the page cache here? > > > > > > > > Because an administrator has configured the reclaim protection in a > > > > certain way and hopefully had a good reason to do that. We are not going > > > > to override that configure just because there is on OOM killer invoked > > > > and killed tasks in that memcg. The workload might get restarted and it > > > > would run under a different constrains all of the sudden which is not > > > > expected. > > > > > > > > In short kernel should never silently change the configuration made by > > > > an admistrator. > > > > > > Understood. > > > > > > So what about bellow changes ? We don't override the admin setting, > > > but we reclaim the page caches from it if this memcg is oom killed. > > > Something like, > > > > > > mem_cgroup_protected > > > { > > > ... > > > + if (!cgroup_is_populated(memcg->css.cgroup) && > > > mem_cgroup_under_oom_group_kill(memcg)) > > > + return MEMCG_PROT_NONE; > > > + > > > usage = page_counter_read(&memcg->memory); > > > if (!usage) > > > return MEMCG_PROT_NONE; > > > } > > > > I assume that mem_cgroup_under_oom_group_kill is essentially > > memcg->under_oom && memcg->oom_group > > But that doesn't really help much because all the reclaim attempts have > > been already attempted and failed. I do not remember exact details about > > under_oom but I have a recollection that it wouldn't really work for > > cgroup v2 because the oom_control is not in place and so the state would > > be set for only very short time period. > > > > Again, what is a problem that you are trying to fix? > > When there's no processes running in a memcg, for example if they are > killed by OOM killer, we can't reclaim the file page cache protected > by memory.min of this memcg. These file page caches are useless in > this case. > That's what I'm trying to fix. Could you be more specific please? I would assume that the group oom configured memcg would either restart its workload when killed (that is why you want to kill the whole workload to restart it cleanly in many case) or simply tear down the memcg altogether. In other words why do you care about the oom killer case so much? It is not different that handling a lingering memcg with the workload already finished. You simply have no way to know whether the reclaim protection is still required. Admin is supposed to either offline the memcg that is no longer used or drop the reclaim protection once it is not needed because that has some visible consequences on the overall system operation. -- Michal Hocko SUSE Labs