Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1967370rwd; Thu, 15 Jun 2023 19:22:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Dxbr+gX7LCdjXaxJoTRv1XST1gXALhY6EHTR119VlbC3lfLLZ5h8NMA9j1UuPD8PWWa4x X-Received: by 2002:a17:902:ead1:b0:1b1:9993:a0e1 with SMTP id p17-20020a170902ead100b001b19993a0e1mr543915pld.59.1686882173612; Thu, 15 Jun 2023 19:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686882173; cv=none; d=google.com; s=arc-20160816; b=SacUB6KB/ft4UPNCxSoWvdPF6CmlxNHUicIuNnlTne9929XZZaYcKfMEGCjcBcVi/D wWYifayjYmdC5yT/3j1T/je/69CdK+Le7qvRR2ou0ahoxYRS67Bj9n3tX4kFm1naxOA0 y0fBtDTWTVCpVNbvO3vTg2AH1jUMk6lcWGgbQck36njtiTfMSubUWLjigA/ww8oumm0B uKp4Le47y2LacrmjZPx8xRwxe/kpaigFLZuizLnGQGOOkXph5XuZUXDI7ENrqyiwVpiX YVG4SJRvXincVGAQ0jchivNKQzbUcXSvri6q6IaYyWkp16SP63M7eoZ7dTFGMFUWKPKP X6qQ== 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=TTYhjgjxFSXf3VV7TigycNG8AweXhCpfWjk/TzQLXHc=; b=soKnunHCKY5CCl6B8a/zs7buOKCk9LsT8uk7u7kwivWilGehTpYaStHs+5z6wf9n9F cwZ7mxYSXtgjnI1UUPvCJ0qPP6R84t4pX+m17MHdYShEpSvqALSjMLglhyaLuS4O6Vrn coywskVYF5YFBWAagdihwYrbDOH/6jfYkicCGD8CwxODYjREC+7uffRZ8J2zCJIA6DRO a8GSFwp0vqkeAeVUuvmXKIUfeZu8YyiUSbNGEgqcVaSUjKkN3bRcc76hXa3FAgZptRqz rPuzDd7XhYQs7wNc7TxPzl2ODjRXKNShORBBr0uwE1gmMN2XlbeFPdvjulqlL+2XrTYL kGvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=S3sEkwkM; 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 c15-20020a170903234f00b001ab09a66f8dsi14288439plh.106.2023.06.15.19.22.39; Thu, 15 Jun 2023 19:22:53 -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=S3sEkwkM; 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 S235146AbjFPBpe (ORCPT + 99 others); Thu, 15 Jun 2023 21:45:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232752AbjFPBp3 (ORCPT ); Thu, 15 Jun 2023 21:45:29 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FA962D59 for ; Thu, 15 Jun 2023 18:45:25 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-983f499fc81so14517766b.3 for ; Thu, 15 Jun 2023 18:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686879923; x=1689471923; 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=TTYhjgjxFSXf3VV7TigycNG8AweXhCpfWjk/TzQLXHc=; b=S3sEkwkMSll1Qn9sm5LHOkOGyqa9IWwEh1o6Y2R2ElKB5bZkFZpm65z7B/tJRybHER yTY2PIEZH0eR3Po6ZzHc16OeGyVIkYmwtCdXTjriszEjXtNBantUF2Ozi0mpVcPOGbQR VgvxxP+s36cJ6ooAMxS1X3+6p3goyhZP/H5vJrbNfsyKpR2M7tBc+v8IN6GtYfyfbbta ICo8LaY+2xcwDkL7DVIETr6Y4ilhpY6Yewxp7bD4HTMOHcQrYq25VgUL9Z1BeZ7c2lQW a+FSy7QJEBUbtpKMDq5KKPiz2RtmaJRgAFtsxBoSZ+nKhq+XI8wXK4yAB4bxQZC1j+qn v45Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686879923; x=1689471923; 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=TTYhjgjxFSXf3VV7TigycNG8AweXhCpfWjk/TzQLXHc=; b=Y7lNNZTifOOtajcAtXQGJCfBfMHG1aAP6UzhF8cvVUH4OqNxcZys4zLWfxnqDLGr9l P3UgFtj+iedwLWU/zv9dhEjt1aMs0cPG40RjvmU9Nfcac+qoUtc92xiB91kfxyoAWcLr w50qIBe3oHjHWTcQVlSxzv9tnty/jRC61EmmNPUt7N8fA2UkFHTWqvS6WpfgiSw5yEFf S/g2RceBTKSRQ2CY3s/8dY6TNzfE1QLRtgljKFbHeWhZtN1cKk505erSnJ5BFXbyPrxy vjqT4huWARuJk6ZUEbswFuveYEtP0mJrD3Vmyn8EOlARF72kS7UMXKm8qWWOLv2yoKTH x0sQ== X-Gm-Message-State: AC+VfDy1xT7APZda9cyaWLLS4U30pYMS2x3IKvLulaZfqM4+PDtrH/S8 CyddpOhwCLihPf4lvqpUbZcDaY+kAP2BPgM4eB+ViA== X-Received: by 2002:a17:906:730d:b0:974:b15:fcd9 with SMTP id di13-20020a170906730d00b009740b15fcd9mr615087ejc.53.1686879923492; Thu, 15 Jun 2023 18:45:23 -0700 (PDT) MIME-Version: 1.0 References: <66F9BB37-3BE1-4B0F-8DE1-97085AF4BED2@didiglobal.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 15 Jun 2023 18:44:46 -0700 Message-ID: Subject: Re: [PATCH v3 0/2] memcontrol: support cgroup level OOM protection To: Michal Hocko Cc: =?UTF-8?B?56iL5Z6y5rabIENoZW5na2FpdGFvIENoZW5n?= , "tj@kernel.org" , "lizefan.x@bytedance.com" , "hannes@cmpxchg.org" , "corbet@lwn.net" , "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" , "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" , 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=unavailable 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 Thu, Jun 15, 2023 at 3:39=E2=80=AFAM Michal Hocko wrot= e: > > On Tue 13-06-23 13:24:24, Yosry Ahmed wrote: > > On Tue, Jun 13, 2023 at 5:06=E2=80=AFAM Michal Hocko = wrote: > > > > > > On Tue 13-06-23 01:36:51, Yosry Ahmed wrote: > > > > +David Rientjes > > > > > > > > On Tue, Jun 13, 2023 at 1:27=E2=80=AFAM Michal Hocko wrote: > > > > > > > > > > On Sun 04-06-23 01:25:42, Yosry Ahmed wrote: > > > > > [...] > > > > > > There has been a parallel discussion in the cover letter thread= of v4 > > > > > > [1]. To summarize, at Google, we have been using OOM scores to > > > > > > describe different job priorities in a more explicit way -- reg= ardless > > > > > > of memory usage. It is strictly priority-based OOM killing. Tie= s are > > > > > > broken based on memory usage. > > > > > > > > > > > > We understand that something like memory.oom.protect has an adv= antage > > > > > > in the sense that you can skip killing a process if you know th= at it > > > > > > won't free enough memory anyway, but for an environment where m= ultiple > > > > > > jobs of different priorities are running, we find it crucial to= be > > > > > > able to define strict ordering. Some jobs are simply more impor= tant > > > > > > than others, regardless of their memory usage. > > > > > > > > > > I do remember that discussion. I am not a great fan of simple pri= ority > > > > > based interfaces TBH. It sounds as an easy interface but it hits > > > > > complications as soon as you try to define a proper/sensible > > > > > hierarchical semantic. I can see how they might work on leaf memc= gs with > > > > > statically assigned priorities but that sounds like a very narrow > > > > > usecase IMHO. > > > > > > > > Do you mind elaborating the problem with the hierarchical semantics= ? > > > > > > Well, let me be more specific. If you have a simple hierarchical nume= ric > > > enforcement (assume higher priority more likely to be chosen and the > > > effective priority to be max(self, max(parents)) then the semantic > > > itslef is straightforward. > > > > > > I am not really sure about the practical manageability though. I have > > > hard time to imagine priority assignment on something like a shared > > > workload with a more complex hierarchy. For example: > > > root > > > / | \ > > > cont_A cont_B cont_C > > > > > > each container running its workload with own hierarchy structures tha= t > > > might be rather dynamic during the lifetime. In order to have a > > > predictable OOM behavior you need to watch and reassign priorities al= l > > > the time, no? > > > > In our case we don't really manage the entire hierarchy in a > > centralized fashion. Each container gets a score based on their > > relative priority, and each container is free to set scores within its > > subcontainers if needed. Isn't this what the hierarchy is all about? > > Each parent only cares about its direct children. On the system level, > > we care about the priority ordering of containers. Ordering within > > containers can be deferred to containers. > > This really depends on the workload. This might be working for your > setup but as I've said above, many workloads would be struggling with > re-prioritizing as soon as a new workload is started and oom priorities > would need to be reorganized as a result. The setup is just too static > to be generally useful IMHO. > You can avoid that by essentially making mid-layers no priority and only > rely on leaf memcgs when this would become more flexible. This is > something even more complicated with the top-down approach. I agree that other setups may find it more difficult if one entity needs to manage the entire tree, although if the scores range is large enough, I don't really think it's that static. When a new workload is started you decide what its priority is compared to the existing workloads and set its score as such. We use a range of scores from 0 to 10,000 (and it can easily be larger), so it's easy to assign new scores without reorganizing the existing scores. > > That being said, I can see workloads which could benefit from a > priority (essentially user spaced controlled oom pre-selection) based > policy. But there are many other policies like that that would be > usecase specific and not generic enough so I do not think this is worth > a generic interface and would fall into BPF or alike based policies. That's reasonable. I can't speak for other folks. Perhaps no single policy will be generic enough, and we should focus on enabling customized policy. Perhaps other userspace OOM agents can benefit from this as well. > > -- > Michal Hocko > SUSE Labs