Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2323047rwb; Wed, 30 Nov 2022 05:22:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Sn3K5EPXricQ8m2txyDXYvr1sBvRu6NkwbuQkh3hSndeABxvFd8wrxaX+PUJID2x7IYHc X-Received: by 2002:a63:1a52:0:b0:464:3985:3c63 with SMTP id a18-20020a631a52000000b0046439853c63mr36669067pgm.141.1669814575839; Wed, 30 Nov 2022 05:22:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669814575; cv=none; d=google.com; s=arc-20160816; b=hh5nlnJX8kHTNbu71jUFfpR4jhrWPJ4uxetwQAzSG1bwYz1Nqf0u4QICOzOb1MFR3J sdzb6eGkq0IH2knndJfIf8XXd91+zA5sElH6aviW62UaxhN5qdSgZr0FkBjNfpkevxJh pp7iEi52ZZTaE9+qvLlz9cEDQkGBdrglyCFx0TxPW+aEKBc7FBaLIlsKUUsvNOS0bWNs FVTndixo329OP/8V0hAZ2PAUQfNz2mLVs3z70eyukKQqWREaA4lbSQ11LpbKqknus4EL QACjzyvcT7HySdr5B2p4Y3z5I6GkNZhoU9QH0dn9UOjbp9P46cj84b1+4Nre7obS+6Kz KrWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=78kBTVjk9NN3b//OL4d2dPMzsmFl6kOFvw+wnxdUvC0=; b=ZHYkTOelXPYNoEiCZgw9Vaev2mXjAmaCtUsCUtRUDbtVAXZfQaNkGJQvtpCVMyvHwL 6GT/rZSvEqRtoj7FWBcTTO4wm/yogLE5k3o6HgXEZLD1qmXiBfYgor/GxavHzDZ04f3z DSeGFbpZjI9YTFdU1SKiisAB2pTWkpmu9PWQM4QYlbHvFvH981myR6yndfXMDFgGWm+9 o1sxaVbkm3mjXvGX+reHQFVMJtQ0SJGeYWdSuSmMYxE3Wzl5t130cwZw5STrlEwqgsIY ozNPIovXmFqH38CwQGrzF9HCVy2u5TvzdROfkAMuj2sPbaQ4h28w1EiF4ctdmoCazdHt AI5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=CJ5yMJnr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m197-20020a633fce000000b00458ae7b0a24si355572pga.208.2022.11.30.05.22.44; Wed, 30 Nov 2022 05:22:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=CJ5yMJnr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233664AbiK3NPK (ORCPT + 85 others); Wed, 30 Nov 2022 08:15:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234530AbiK3NPI (ORCPT ); Wed, 30 Nov 2022 08:15:08 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2816B56D4B; Wed, 30 Nov 2022 05:15:08 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C695B21ACC; Wed, 30 Nov 2022 13:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1669814106; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=78kBTVjk9NN3b//OL4d2dPMzsmFl6kOFvw+wnxdUvC0=; b=CJ5yMJnrkOzf4sfqOWKQ1oSbCwMifCAwlufTAq1pWndcvZ5cAeOuB0nUqN676FKRXuNrLs VanShgHoCm8feQxtJEpumXrdKUFYdFlrhjNoHTeVkyWn3K/SDlL9mo3hqvI/V/M59IYJW1 bgTi/RkuuLd/q/bmdszcfp1VvqnOwSE= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9C39C1331F; Wed, 30 Nov 2022 13:15:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id V0ynJVpXh2OuVwAAMHmgww (envelope-from ); Wed, 30 Nov 2022 13:15:06 +0000 Date: Wed, 30 Nov 2022 14:15:06 +0100 From: Michal Hocko To: chengkaitao Cc: tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org, corbet@lwn.net, roman.gushchin@linux.dev, shakeelb@google.com, akpm@linux-foundation.org, songmuchun@bytedance.com, cgel.zte@gmail.com, ran.xiaokai@zte.com.cn, viro@zeniv.linux.org.uk, zhengqi.arch@bytedance.com, ebiederm@xmission.com, Liam.Howlett@oracle.com, chengzhihao1@huawei.com, haolee.swjtu@gmail.com, yuzhao@google.com, willy@infradead.org, vasily.averin@linux.dev, vbabka@suse.cz, surenb@google.com, sfr@canb.auug.org.au, mcgrof@kernel.org, sujiaxun@uniontech.com, feng.tang@intel.com, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: memcontrol: protect the memory in cgroup from being oom killed Message-ID: References: <20221130070158.44221-1-chengkaitao@didiglobal.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221130070158.44221-1-chengkaitao@didiglobal.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 30-11-22 15:01:58, chengkaitao wrote: > From: chengkaitao > > We created a new interface for memory, If there is > the OOM killer under parent memory cgroup, and the memory usage of a > child cgroup is within its effective oom.protect boundary, the cgroup's > tasks won't be OOM killed unless there is no unprotected tasks in other > children cgroups. It draws on the logic of in the > inheritance relationship. Could you be more specific about usecases? How do you tune oom.protect wrt to other tunables? How does this interact with the oom_score_adj tunining (e.g. a first hand oom victim with the score_adj 1000 sitting in a oom protected memcg)? I haven't really read through the whole patch but this struck me odd. > @@ -552,8 +552,19 @@ static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns, > unsigned long totalpages = totalram_pages() + total_swap_pages; > unsigned long points = 0; > long badness; > +#ifdef CONFIG_MEMCG > + struct mem_cgroup *memcg; > > - badness = oom_badness(task, totalpages); > + rcu_read_lock(); > + memcg = mem_cgroup_from_task(task); > + if (memcg && !css_tryget(&memcg->css)) > + memcg = NULL; > + rcu_read_unlock(); > + > + update_parent_oom_protection(root_mem_cgroup, memcg); > + css_put(&memcg->css); > +#endif > + badness = oom_badness(task, totalpages, MEMCG_OOM_PROTECT); the badness means different thing depending on which memcg hierarchy subtree you look at. Scaling based on the global oom could get really misleading. -- Michal Hocko SUSE Labs