Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1816610rwd; Wed, 17 May 2023 01:35:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4IyUUJZLlVkz6jS14oaZ+mnjHR3DIHntCE/hoj3ApYShf7lm0SyMaAYD7hL7kmk0J4PLU0 X-Received: by 2002:a17:902:c102:b0:1ae:436c:b064 with SMTP id 2-20020a170902c10200b001ae436cb064mr3965856pli.8.1684312531065; Wed, 17 May 2023 01:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684312531; cv=none; d=google.com; s=arc-20160816; b=bDbMsz/dYT4SE4RhqpzZrr+oU2ABqYFq5VdD5xJtg/eLkCLzbC0osvGjKZFh26jzJ7 V+m4bSV+3uRNBXWDMcBsGoJRzzhgBKba/YcuyCYjcrcKzn5M1QmLAyl6MySjMxM5E1K1 qqOMmhBguU7easZHYLRFavAANkKyltrvRgpjKjQzdIRZ03n6TLmmK8Zlw3HHMKS0ul8I ZwMLQOqKjwJjMk2o8P+8q0MILHw+pZ3zWVy7fMP7/c2/kXmn7MFCqVNRWhDjSzq9m63v mm3ShiMsuyrAH63sYi39eXKxavBgja5yi1HXG2YTSo8ceuC7kHgcXPFRmFM7+6siah14 7TuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=M/JbPTvNpjTaAOSiw7cq2XUFwTTZo3maiLd9kZ3gbPY=; b=teLlHSQR60HXYIOp+kOJqCWIx31nHnLhgx8BL7yoGMGlDzD8lqQEVHXjSrmqPS2aW7 p4jlgIaqGUO9qLsySQPolSaMADv9qSf6xmZRmf5jV8diixd1Cj9j80DTMnE9vwHUK2+h wOSjyWy1t8x/h9Lanc/D/B5wPPFHw0T/oGQKxCUm6CuCDYCmYW1KN6BsxT35YFahIp1h WkkeHCSgGzBIy8kehy6XLLjoBvICn3SiZpvF+vcF+5+sm8xsH6Qcv86927F8tHuoWkC+ dGdO4o5FtevfjS6A4ckaMo5wcni1AiEGnyAPWTPaE6+nUr0uzcc59PLSrlWeI08qqCTH sEvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="E/nQr0Tt"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj3-20020a170902850300b001ab0340f9cesi19711447plb.11.2023.05.17.01.35.19; Wed, 17 May 2023 01:35:31 -0700 (PDT) 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=@google.com header.s=20221208 header.b="E/nQr0Tt"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230259AbjEQIKq (ORCPT + 99 others); Wed, 17 May 2023 04:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbjEQIKa (ORCPT ); Wed, 17 May 2023 04:10:30 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 249192102 for ; Wed, 17 May 2023 01:10:29 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-510b4e488e4so813104a12.3 for ; Wed, 17 May 2023 01:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684311027; x=1686903027; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=M/JbPTvNpjTaAOSiw7cq2XUFwTTZo3maiLd9kZ3gbPY=; b=E/nQr0TtAbvKOJgpRKAM1JVFuP/MwUX23KxLMaK9E935LDpjE6s9HpTk6zcktHzA3V lVxuSKWxkpaEF/0X7X4fb0A2wQtR+BP46udE3XC2KotT4N3Y20wucgNCN5myvUQPrgYm hf8qXaIk4/mtVqOzBMdebf1uOebU+yZFQwgKC0uSR7A2S8DJaBgTCt2tXTRjmHgu9gTl He1rqLvC6itIyQX551xHdP0ntcFbz4HClZ9Wg7mkLnBAKGlfTSh3/2KEYLgKR0024kd1 FZk9gcyZUQemmV3CyHP8mGDAj9j4MwZkxgKrt5y90zAG/N8tFGr657bHQAGYojKPXnWN MoDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684311027; x=1686903027; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M/JbPTvNpjTaAOSiw7cq2XUFwTTZo3maiLd9kZ3gbPY=; b=k7DNLUqv6UzuI67u5yDvE6FTvh/1gjA86j0YE1TrDzyCWI9q33SGVnKRgt9uS/v1me 72nQlosciMCdlk7dCaOURoa9PJViRiRJTlsceZrTYWNBgFCsKeCvE5hh5Rpxfg3NOrvE d1+shrVrMkHBT3Bog8Yi7NUyGaFsgkXm/OiQMXRDrNGYD3cIvgFgx4YOsQnKXKTZoorn 66cUc7YuCkPdYt8Iau4qtBo3Mfn6bCTT8at3waqRrfxxYBIMMEALG8KUz9xRhzIV15Kp A9p7BpD3LEG43gjf674tH3Lsp2PSt+HEk7rUXXGmNMuAKAFWneD8uxEI8jE0K7th9rK5 LvDQ== X-Gm-Message-State: AC+VfDztg6l3TSCsMavMEpmMzWuCAWr8VBI9/fBz2yZfJFiHPDM2wnXN l0rEjlieuewnomtgMDd87CAXm1M2zaXgqElAVr1+KQ== X-Received: by 2002:a17:906:fe04:b0:966:1984:9d21 with SMTP id wy4-20020a170906fe0400b0096619849d21mr30993043ejb.9.1684311027372; Wed, 17 May 2023 01:10:27 -0700 (PDT) MIME-Version: 1.0 References: <09A746CC-E38D-4ECA-B0F4-862EC6229A0F@didiglobal.com> In-Reply-To: <09A746CC-E38D-4ECA-B0F4-862EC6229A0F@didiglobal.com> From: Yosry Ahmed Date: Wed, 17 May 2023 01:09:50 -0700 Message-ID: Subject: Re: [PATCH v4 0/2] memcontrol: support cgroup level OOM protection To: =?UTF-8?B?56iL5Z6y5rabIENoZW5na2FpdGFvIENoZW5n?= Cc: "tj@kernel.org" , "lizefan.x@bytedance.com" , "hannes@cmpxchg.org" , "corbet@lwn.net" , "mhocko@kernel.org" , "roman.gushchin@linux.dev" , "shakeelb@google.com" , "akpm@linux-foundation.org" , "brauner@kernel.org" , "muchun.song@linux.dev" , "viro@zeniv.linux.org.uk" , "zhengqi.arch@bytedance.com" , "ebiederm@xmission.com" , "Liam.Howlett@oracle.com" , "chengzhihao1@huawei.com" , "pilgrimtao@gmail.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" , "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" , David Rientjes Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, May 17, 2023 at 1:01=E2=80=AFAM =E7=A8=8B=E5=9E=B2=E6=B6=9B Chengka= itao Cheng wrote: > > At 2023-05-17 14:59:06, "Yosry Ahmed" wrote: > >+David Rientjes > > > >On Tue, May 16, 2023 at 8:20=E2=80=AFPM chengkaitao wrote: > >> > >> Establish a new OOM score algorithm, supports the cgroup level OOM > >> protection mechanism. When an global/memcg oom event occurs, we treat > >> all processes in the cgroup as a whole, and OOM killers need to select > >> the process to kill based on the protection quota of the cgroup. > >> > > > >Perhaps this is only slightly relevant, but at Google we do have a > >different per-memcg approach to protect from OOM kills, or more > >specifically tell the kernel how we would like the OOM killer to > >behave. > > > >We define an interface called memory.oom_score_badness, and we also > >allow it to be specified per-process through a procfs interface, > >similar to oom_score_adj. > > > >These scores essentially tell the OOM killer the order in which we > >prefer memcgs to be OOM'd, and the order in which we want processes in > >the memcg to be OOM'd. By default, all processes and memcgs start with > >the same score. Ties are broken based on the rss of the process or the > >usage of the memcg (prefer to kill the process/memcg that will free > >more memory) -- similar to the current OOM killer. > > Thank you for providing a new application scenario. You have described a > new per-memcg approach, but a simple introduction cannot explain the > details of your approach clearly. If you could compare and analyze my > patches for possible defects, or if your new approach has advantages > that my patches do not have, I would greatly appreciate it. Sorry if I was not clear, I am not implying in any way that the approach I am describing is better than your patches. I am guilty of not conducting the proper analysis you are requesting. I just saw the thread and thought it might be interesting to you or others to know the approach that we have been using for years in our production. I guess the target is the same, be able to tell the OOM killer which memcgs/processes are more important to protect. The fundamental difference is that instead of tuning this based on the memory usage of the memcg (your approach), we essentially give the OOM killer the ordering in which we want memcgs/processes to be OOM killed. This maps to jobs priorities essentially. If this approach works for you (or any other audience), that's great, I can share more details and perhaps we can reach something that we can both use :) > > >This has been brought up before in other discussions without much > >interest [1], but just thought it may be relevant here. > > > >[1]https://lore.kernel.org/lkml/CAHS8izN3ej1mqUpnNQ8c-1Bx5EeO7q5NOkh0qrY= _4PLqc8rkHA@mail.gmail.com/#t > > -- > Thanks for your comment! > chengkaitao >