Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2978914rdh; Wed, 27 Sep 2023 21:06:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOivTJDqjKt/lZ9hJKS/cm9PEMyV/EP2s1Q3DFkU1z96iiL00LLXlUHHx1uIL3czFR8eje X-Received: by 2002:a05:6870:ea8d:b0:1bb:8333:ab8a with SMTP id s13-20020a056870ea8d00b001bb8333ab8amr140069oap.4.1695874014644; Wed, 27 Sep 2023 21:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695874014; cv=none; d=google.com; s=arc-20160816; b=DmafCfv0E+5FXxB9bZg1Gu6usFnfPAzTTzQ+kxrk3hc3DEZFtd73S7Ik0n4Xtj3rbG dh0Hrx6Ubd0d+mcMz3Mt5T73LS/WtTuKryqpvklD2MyBi5+ZmyFbXpq0SVEpcIP2s0LD O6bskajqUMW9oxjWHxpmwCNH1pQEwpU9pSdNK4hRIpAWhl1KquAwZVullqDCEjyB3uWc mXWCI5XHYj7IArq/JxfsHb+XYjrEIsF/Qdz29iweaeQSo762OWlVJ8s2Pl6ELER/hSv8 vI6lFzuuCG7oDu94Py+ARUJug0ZsXHP95H1P9AqMpeRaOESt26wIPHu/dobS9i0fGLrT bJJQ== 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=KbmQXiIb/6ha3RbpQiPYuun60PQSJ8nGNO0HCRh4zk8=; fh=dr01barU9xhgfmkh9W9wZxPUiBGNGqZfFlS6t/GIbLY=; b=KZiiMT8LqsJtr6KXyfe+5zjqn7qv1pPixGJMkXeXmNSqgf+72sA3af2vJ/rmKxBiwg WDKK8RL650rxqNcK1gGVoQ6yF7JgZkvEQlJ3fSGbj1QArAdiceGLu3Z7mCtRyt/vrMM6 MlamKjafb7hA3FQe2QZDkgoLUTOnu+do2Odre3v0eMWHXS+Y9/MiqTPZ+LeBHCwR6fJu S3B9YXsULPxItBmJTeewM5Z2Mlqj//ZMkh3uaAz9tgXm2yg5VvDK2B5YtzWB67cqc2aV i3X7EAtonxIblXAvgT9QQMk108sZKxOaNEuGu0GV9nY+9ok0AVgpebMWo04s9BKdAOAO DpgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HWAriZ+5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id w4-20020a634744000000b0056433b221b9si17161998pgk.477.2023.09.27.21.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 21:06:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HWAriZ+5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 89EEF80A7CF0; Wed, 27 Sep 2023 18:00:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbjI1BAp (ORCPT + 99 others); Wed, 27 Sep 2023 21:00:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbjI1BAp (ORCPT ); Wed, 27 Sep 2023 21:00:45 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBDB6BF; Wed, 27 Sep 2023 18:00:43 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-79fe87cd74eso130877339f.3; Wed, 27 Sep 2023 18:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695862843; x=1696467643; darn=vger.kernel.org; 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=KbmQXiIb/6ha3RbpQiPYuun60PQSJ8nGNO0HCRh4zk8=; b=HWAriZ+5MDXJAtj8hgfCKsjlPcGz5oeqLoykvHA/LOIBF+1osXCCtRUhVpe11QxPqz eOFwMulLf1+KxceCZoTdiV0aM58hqvpGsxymlKhWslFvYvro07UuQDl9RR5G2iz+z+Aa RVvZrDMGh1p4QyDtPWaXPNWuCSTpWVtcjCfHoLGR2GZTU8eRmxCaiTaftYorSzf5j/z4 9SNSWbeKV6lRfpZ51E/6zWaV8A14yoKMJW0AzXilZuAdNBqRBVeuFZj/UQTN2SxP/Xs2 hdCheLdg8Vh0BnAJHsoouUaCXl2naFSNufIPVLqmuoPc53mwqF+8Zt+fHB+QDgosU2A5 38yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695862843; x=1696467643; 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=KbmQXiIb/6ha3RbpQiPYuun60PQSJ8nGNO0HCRh4zk8=; b=UN6hrjamlUtJh6lhfe4rksz/22fv6qtTWjSZptgAWiES5+KbX2mEICfDibJjqSfrOM Ibz6whti0U9+zNsJibgLOMeZKILJ40id1+ZOqFRV4kFHqZBnLf3OwXdWbRe1YTfkYtIb /O+JMSvOO8J1pzfQUAvDNtCvqz7oYyr9nMapeADOEmlyeFoV8/KWglvElZ2h6m3FexSH /kM4QO/zSEHmgc5Drsp9skK8IXh7p7/zNiVU92tXyFTzMlkWMejzY1W20yFp1A0eNk7B g8IafxFLKtPoO4202vOX8acuJ3mGAijb0l0ObIvkfIG47tCNUTb9JcvTMpQiJiz3mFh7 aIOQ== X-Gm-Message-State: AOJu0YxBR37FG9EqDg+QHXXsZLp7dprtNP4UIcUk81Gql2CwVtM65aLE 4Y42oznlkA/2Vto/bF8L2IVZT6g2CYo30vrJT4U= X-Received: by 2002:a5e:8706:0:b0:798:134a:44b with SMTP id y6-20020a5e8706000000b00798134a044bmr3574638ioj.21.1695862843166; Wed, 27 Sep 2023 18:00:43 -0700 (PDT) MIME-Version: 1.0 References: <20230926194949.2637078-1-nphamcs@gmail.com> In-Reply-To: <20230926194949.2637078-1-nphamcs@gmail.com> From: Nhat Pham Date: Wed, 27 Sep 2023 18:00:32 -0700 Message-ID: Subject: Re: [PATCH 0/2] hugetlb memcg accounting To: akpm@linux-foundation.org Cc: riel@surriel.com, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, tj@kernel.org, lizefan.x@bytedance.com, shuah@kernel.org, mike.kravetz@oracle.com, yosryahmed@google.com, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 18:00:53 -0700 (PDT) On Tue, Sep 26, 2023 at 12:49=E2=80=AFPM Nhat Pham wrot= e: > > Currently, hugetlb memory usage is not acounted for in the memory > controller, which could lead to memory overprotection for cgroups with > hugetlb-backed memory. This has been observed in our production system. > > This patch series rectifies this issue by charging the memcg when the > hugetlb folio is allocated, and uncharging when the folio is freed. In > addition, a new selftest is added to demonstrate and verify this new > behavior. > > Nhat Pham (2): > hugetlb: memcg: account hugetlb-backed memory in memory controller > selftests: add a selftest to verify hugetlb usage in memcg > > MAINTAINERS | 2 + > fs/hugetlbfs/inode.c | 2 +- > include/linux/hugetlb.h | 6 +- > include/linux/memcontrol.h | 8 + > mm/hugetlb.c | 23 +- > mm/memcontrol.c | 40 ++++ > tools/testing/selftests/cgroup/.gitignore | 1 + > tools/testing/selftests/cgroup/Makefile | 2 + > .../selftests/cgroup/test_hugetlb_memcg.c | 222 ++++++++++++++++++ > 9 files changed, 297 insertions(+), 9 deletions(-) > create mode 100644 tools/testing/selftests/cgroup/test_hugetlb_memcg.c > > -- > 2.34.1 Thanks for all the comments and suggestions everyone! FYI, I have sent out a second version of the patch series with the new mount flag: https://lore.kernel.org/lkml/20230928005723.1709119-1-nphamcs@gmail.com/T/#= t Feel free to check it out and discuss it over there too!