Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1610145rdb; Mon, 2 Oct 2023 15:26:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZbsmsOW6o2EAVIJSdQtNgW6Ocop/w4sB++MgQUdXx6NudaxR9xi6JCHXWUH50Qz0kN4UM X-Received: by 2002:a05:6a00:b81:b0:691:fd26:f54a with SMTP id g1-20020a056a000b8100b00691fd26f54amr14993505pfj.20.1696285560979; Mon, 02 Oct 2023 15:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696285560; cv=none; d=google.com; s=arc-20160816; b=buoxsSlewW59uE9gor+HsTZCcZdTpp5kRpzgi47tettpEJWnl8kO/C3vpKY2T9gfRk 14Vv8l57bs4ug+G7WzvjloeR+U3E73Ytswzem8lDgQWLPfZhi8inZpZ6MmLUSS4xqkXH cIucbrYq5gSQ+TKa4Fnks5m1SnZZ7Pm59R40Q3AHPzJBymTs+A7fu2eUlqjbREHoJfe6 w03QD6i9VjsI6dXjAJpZLVSJ4VKE0pYY+aDkLt392KX5KOQbwXERRJGETRpytw6Dxd1m gYvYb6JwvmaUdlBsSylTZ/yTvwbDG+NyM9owD7fz5/aXzQafp8zEZf9h8WHzVqzXor8p hxJA== 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=m9gT0sJ6bxJ7LFGJ3qcn0lur/HHwUZlrfxhEFRGE3Lc=; fh=V+HDT4lsVnO6hkNUEuUpEp/FsWH4nezAK06RDCQ0NxU=; b=mbT8QNwpkf1fmxBJ5I+PgDnG8likZr84ixLPXxcKaGfzN3YlPnam2tCFMkfGlhN8sO pcLp1bLswwbafFNyk9u0K5gBZkII60VQORifvGafc7MAoyN+2uqfVy0X4GGUUAI8z2r/ v21dP969rWE7AzZCysvAubry4LzHkX6px5xCOpw6IBiUKR+ODJf3FDdv6bBVi8W3Sv3A FFO8xbTeRtEQxTfSLUtW8R41HCno4zUla0SBoxrXuNFHPKSa5oC5Db6V0i8kGQlB4cUC KhjIOhbOy2ZuQvEyQM18pjDXHvsUI1mVqf7uO64hOc8wgU9QJuDiCXrEgCtsxur7Q6ec Hcvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=c6OXd9YF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id fo11-20020a056a00600b00b0068896ba4a3fsi27938556pfb.129.2023.10.02.15.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:26:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=c6OXd9YF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7B9758074CA2; Mon, 2 Oct 2023 07:43:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237704AbjJBOm5 (ORCPT + 99 others); Mon, 2 Oct 2023 10:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237697AbjJBOmz (ORCPT ); Mon, 2 Oct 2023 10:42:55 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADB3CAD for ; Mon, 2 Oct 2023 07:42:52 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-4196ae80fc3so31793121cf.0 for ; Mon, 02 Oct 2023 07:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1696257772; x=1696862572; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=m9gT0sJ6bxJ7LFGJ3qcn0lur/HHwUZlrfxhEFRGE3Lc=; b=c6OXd9YFBsot277vrDT83xXwBobB0wm3QiKoEK3jxGefiNII0hx0/53I6hHHWBXXVI PjFknMvxds4R53+FJpAlBJ054OExLeKNeXw7qmnc4NxhEvXGplheOaY1MxMALVEdpnEm W9xaYOEaB8aSe+ML2F/9TOrJtMvONMM7IqgjwKu4XXCQXF2/cTBOxwCBeOnLp3QkJYMR JT0J8y/YwBi84rPL28BZJBtN5ohIIA/Rz8NRLRykwAuige0IT+Hi03kYU4VokLkQ+4dT su6T6pt0wlQHfEpCPdEAQscQR4fNXz7ttI3OKWzyE9lr6OI8GD7BTbehBqmSuPE8mkIC kwGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696257772; x=1696862572; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=m9gT0sJ6bxJ7LFGJ3qcn0lur/HHwUZlrfxhEFRGE3Lc=; b=v61kcplc8qyxAnRGBlXflZZe16u5fPn7LPz3kHjPr/ZXu12aYnL3XSqgjgO45lEcqg zLWKDjtoSQYHj+4TEAyiCoMc94TWVpUygRPKdJrzNm/t7X9OwDjK5RW/yql27nhE2/HT vt49Q14LCEQWx8vVdQ7smB86SvDuZHktAsC8BWet+co2kaqzCYQAKb7Ie3slnOLXj/Xw 5SEUgeVik5JUoNLfCcOrU1LvNvRRXI9NosPawAw/W1dZkmiQUTIANWmI/Fi/gYccEJcm up1qvuJsT9GzqGoBrBoq25AfBg/hMIVkDxXYArwLVyj1Ltw9JOhV/p/H68TEILNJ3QcM 3AyA== X-Gm-Message-State: AOJu0YwfOZaNmA9bj/EW5LSjJezSDA9nFRdFun/0Xl50rng0BhqM2saB 7h+eaQ0i9cRzgnx459QaEL0rhw== X-Received: by 2002:ac8:588a:0:b0:417:95e7:a2f7 with SMTP id t10-20020ac8588a000000b0041795e7a2f7mr12774184qta.19.1696257771693; Mon, 02 Oct 2023 07:42:51 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-3012-16a2-6bc2-2937.res6.spectrum.com. [2603:7000:c01:2716:3012:16a2:6bc2:2937]) by smtp.gmail.com with ESMTPSA id h20-20020ac846d4000000b0041812600a47sm6261207qto.59.2023.10.02.07.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 07:42:51 -0700 (PDT) Date: Mon, 2 Oct 2023 10:42:50 -0400 From: Johannes Weiner To: Mike Kravetz Cc: Michal Hocko , Nhat Pham , akpm@linux-foundation.org, riel@surriel.com, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, tj@kernel.org, lizefan.x@bytedance.com, shuah@kernel.org, yosryahmed@google.com, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH 0/2] hugetlb memcg accounting Message-ID: <20231002144250.GA4414@cmpxchg.org> References: <20230926194949.2637078-1-nphamcs@gmail.com> <20230927184738.GC365513@cmpxchg.org> <20231001232730.GA11194@monkey> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231001232730.GA11194@monkey> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 02 Oct 2023 07:43:09 -0700 (PDT) On Sun, Oct 01, 2023 at 04:27:30PM -0700, Mike Kravetz wrote: > On 09/27/23 14:47, Johannes Weiner wrote: > > On Wed, Sep 27, 2023 at 01:21:20PM +0200, Michal Hocko wrote: > > > On Tue 26-09-23 12:49:47, Nhat Pham wrote: > > > > So that if you use 80% hugetlb, the other memory is forced to stay in > > the remaining 20%, or it OOMs; and that if you don't use hugetlb, the > > group is still allowed to use the full 100% of its host memory > > allowance, without requiring some outside agent continuously > > monitoring and adjusting the container limits. > > Jumping in late here as I was traveling last week. In addition, I want > to state my limited cgroup knowledge up front. > > I was thinking of your scenario above a little differently. Suppose a > group is up and running at almost 100% memory usage. However, the majority > of that memory is reclaimable. Now, someone wants to allocate a 2M hugetlb > page. There is not 2MB free, but we could easily reclaim 2MB to make room > for the hugetlb page. I may be missing something, but I do not see how that > is going to happen. It seems like we would really want that behavior. But that is actually what it does, no? alloc_hugetlb_folio mem_cgroup_hugetlb_charge_folio charge_memcg try_charge !page_counter_try_charge ? !try_to_free_mem_cgroup_pages ? mem_cgroup_oom So it does reclaim when the hugetlb hits the cgroup limit. And if that fails to make room, it OOMs the cgroup. Or maybe I'm missing something?