Message ID | 20241108212946.2642085-1-joshua.hahnjy@gmail.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24586D6408E for <linux-mm@archiver.kernel.org>; Fri, 8 Nov 2024 21:29:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87C716B008C; Fri, 8 Nov 2024 16:29:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 82CB16B00C5; Fri, 8 Nov 2024 16:29:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CDA66B00CA; Fri, 8 Nov 2024 16:29:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4DC946B008C for <linux-mm@kvack.org>; Fri, 8 Nov 2024 16:29:50 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 05148AC435 for <linux-mm@kvack.org>; Fri, 8 Nov 2024 21:29:50 +0000 (UTC) X-FDA: 82764219384.16.6E418B0 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) by imf16.hostedemail.com (Postfix) with ESMTP id 47AD2180007 for <linux-mm@kvack.org>; Fri, 8 Nov 2024 21:29:11 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ZIYz9o73; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.128.176 as permitted sender) smtp.mailfrom=joshua.hahnjy@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731101217; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=oMoVwyKx9EibI93AzasoaRWiT17pCAJ8KSTbCwA4rwI=; b=LmoVVoWdyOlEIAMWfcPmqiMqiS2i8svpf5PFHwWetU6QZt+PaW7RQqZTSL/IP+O3u+tdIx Zh6FLtvnwDDedSaIxSBmT1vjVOMZ4TyidpEGOBTBg763mHJ6u0Ha1F/GsvoYH7OdwhXPyM I5OuIF7+O6H7b/IZGy+LHln0yB/PAUU= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ZIYz9o73; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.128.176 as permitted sender) smtp.mailfrom=joshua.hahnjy@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731101217; a=rsa-sha256; cv=none; b=wDRiWEDKB0qrV+EF4u7XTCYHm3wp06mlXhadYn8wYRVsKVxzCYxlzHjJ0SbFtXb5+O9pGU Y7pjkJZGPF633zoJNy33Ip4kdHYaP2zph0Pn6tYTN1a4GXyckj41g5s2EzaYC73ffZHaDx JBk3sJuHAdfC2bVZXismCy/nEqfZ3DI= Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-6e5cec98cceso21926177b3.2 for <linux-mm@kvack.org>; Fri, 08 Nov 2024 13:29:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731101387; x=1731706187; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=oMoVwyKx9EibI93AzasoaRWiT17pCAJ8KSTbCwA4rwI=; b=ZIYz9o73bhTtSs99dGYuZQXymWZ9NgvgeNhOlhBSDdEgKW4LKlT6VDT6g48QMCKku7 L3/785eBH33FsuQsxK8Ry7Qs4nff3PFteIESLNgw1iIJymhVUcgLpqvHZRjozAwO01qs 99ePc+ZPCcaGYmk16JtDgjghojXU2q+7cwWbsV39h5jj3KESkvdir5g8t7qUHQ9wh0XJ H8gYeYH3+a6fyCgh51UnRpCBncfaFBzIqxJAkwgZoqF/pTnJXBkex0CN8mqizMnIv16z G5zFBdk6vl5eUMdr+3XVKTZ0xa2CaAWZbsSDVEH0Szi3O7FDetI1byw7/fFgbhXRcIYp n0Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731101387; x=1731706187; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oMoVwyKx9EibI93AzasoaRWiT17pCAJ8KSTbCwA4rwI=; b=p8Iz2PYP3ubPzjRSNB9jldPbi1opwphvHpTKHNAzUV+YGBO9ECgONXq5qTxsgumye2 5sqSl/zuYglHVjjg730riNi2wbj2FKLrFrxZ2VsUn71D1UxErqiWWmB8tFVLDbUtSR93 vt/vDt8ZKearftsvfRzhiSydRpvT//+SxnXHm7ueyNHYv7xljFXIWGujpTBIe42IOH8/ 1+0rbrPpG0KMPf7ur+cCxF3L/doF739YwjgCrtWl/zV+S7CWj7JkgBgeznES5JEPOXB7 I+Ncck9sXwzaSBwgQq44U8YR3LJiZ0qe4MXxH6yFowrdm85+KzTjT6pcALnEq1OCcf2x fecw== X-Forwarded-Encrypted: i=1; AJvYcCU7DXdhakuIbINReuhgG3Il5WnxhuFlKRVS1+6GuRuDgzirm40Zz2oLOdnkj2VlaFcGLL3KGOIZMQ==@kvack.org X-Gm-Message-State: AOJu0Yx6EInllgfn23aqr5i4/ZsfTRyQqjxYdWqzTmL6wNtXhYdmoQML twIKsK0IPP8FVDGIrhHCs3/A8JAMcFvwEcaiC95BRzIKGLHs5z2f X-Google-Smtp-Source: AGHT+IHwMeuH9AhWabEeGAZIaMw/d1MyU/3YuOvKGu/9O7X4oRAyW6t81YL0CaXeGHwWDLTrTna9RQ== X-Received: by 2002:a05:690c:7282:b0:6ea:47cb:c870 with SMTP id 00721157ae682-6eadde44dd0mr57163067b3.33.1731101387352; Fri, 08 Nov 2024 13:29:47 -0800 (PST) Received: from localhost (fwdproxy-frc-013.fbsv.net. [2a03:2880:21ff:d::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eaceb9025fsm8615747b3.130.2024.11.08.13.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 13:29:46 -0800 (PST) From: Joshua Hahn <joshua.hahnjy@gmail.com> To: shakeel.butt@linux.dev Cc: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, muchun.song@linux.dev, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH 0/3] memcg/hugetlb: Rework memcg hugetlb charging Date: Fri, 8 Nov 2024 13:29:43 -0800 Message-ID: <20241108212946.2642085-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 47AD2180007 X-Stat-Signature: nr1aa87pxf14x6xjs5yd6somxchgh65w X-Rspam-User: X-HE-Tag: 1731101351-578618 X-HE-Meta: U2FsdGVkX18Xdcf+GkauLNKRHIiEutblvMGWixuupNrHnLDTIyYFS4WiI1dxt8pTWyuDRdz8WzOTfsOcOpPwDwEpbZlZgXEBilfZIIPZmdodFywEIsuXp9HoD/yO8I7Qwl/WzdHvnbCSpSuHlH1Y/W77kuhJmcc8wds8WEkinHqUjv5cip3OnlXuPlQBRS2RXPYj6jBgzltNwctU2PfQYMr3UTdc8/9H3+RpEpzzq/i5t4CN0nSpkcnreaoOJi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82NfE2rYvtcleRrycUHO7a3S/abb X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
memcg/hugetlb: Rework memcg hugetlb charging
|
expand
|
This series cleans up memcg's hugetlb charging logic by deprecating the current memcg hugetlb try-charge + {commit, cancel} logic present in alloc_hugetlb_folio. A single function mem_cgroup_charge_hugetlb takes its place instead. This makes the code more maintainable by simplifying the error path and reduces memcg's footprint in hugetlb logic. This patch introduces a few changes in the hugetlb folio allocation error path: (a) Instead of having multiple return points, we consolidate them to two: one for reaching the memcg limit or running out of memory (-ENOMEM) and one for hugetlb allocation fails / limit being reached (-ENOSPC). (b) Previously, the memcg limit was checked before the folio is acquired, meaning the hugeTLB folio isn't acquired if the limit is reached. This patch performs the charging after the folio is reached, meaning if memcg's limit is reached, the acquired folio is freed right away. This patch builds on two earlier patch series: [2] which adds memcg hugeTLB counters, and [3] which deprecates charge moving and removes the last references to mem_cgroup_cancel_charge. The request for this cleanup can be found in [2]. Suggested-by: Shakeel Butt <shakeel.butt@linux.dev> Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com> [1] https://lore.kernel.org/all/20231006184629.155543-1-nphamcs@gmail.com/ [2] https://lore.kernel.org/all/20241101204402.1885383-1-joshua.hahnjy@gmail.com/ [3] https://lore.kernel.org/linux-mm/20241025012304.2473312-1-shakeel.butt@linux.dev/ --- Changelog v2: * Removed declaration of memcg_accounts_hugetlb from memcontrol.h * Moved second call to memcg_accounts_hugetlb from 2nd patch to 1st * Changed error behavior in alloc_hugetlb_folio: v1 included a bug that uncharged hugetlb_cgroup twice when memecg's limit was reached * mem_cgroup_charge_hugetlb no longer called with hugetlb_lock held * Moved mem_cgroup_hugetlb_{try, charge} deprecation to patch 3 * mem_cgroup_charge_hugetlb always decrements memcg's refcount * Fully cleaned up mem_cgroup_{cancel,commit}_charge * Fixed typos Joshua Hahn (3): memcg/hugetlb: Introduce memcg_accounts_hugetlb memcg/hugetlb: Introduce mem_cgroup_charge_hugetlb memcg/hugetlb: Deprecate memcg hugetlb try-commit-cancel protocol include/linux/memcontrol.h | 22 +--------- mm/hugetlb.c | 34 +++++---------- mm/memcontrol.c | 89 +++++++++++++------------------------- 3 files changed, 43 insertions(+), 102 deletions(-)