From patchwork Tue Sep 10 23:43:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13799484 Return-Path: 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 71B85EE01F1 for ; Tue, 10 Sep 2024 23:45:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C4898D00D6; Tue, 10 Sep 2024 19:44:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 958A68D0002; Tue, 10 Sep 2024 19:44:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7792B8D00D6; Tue, 10 Sep 2024 19:44:54 -0400 (EDT) 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 503D38D0002 for ; Tue, 10 Sep 2024 19:44:54 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1B25680897 for ; Tue, 10 Sep 2024 23:44:54 +0000 (UTC) X-FDA: 82550461308.26.311966D Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf02.hostedemail.com (Postfix) with ESMTP id 5176580009 for ; Tue, 10 Sep 2024 23:44:52 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=C4oCybm9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.hostedemail.com: domain of 38tngZgsKCGcFHPJWQJdYSLLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--ackerleytng.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=38tngZgsKCGcFHPJWQJdYSLLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--ackerleytng.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726011888; a=rsa-sha256; cv=none; b=uEDXYgfVTiCBZ6lNtDVrY+9yrZKG9U1/bX4DNXOygks8OgTBB+69XVGA1Hm5xvdjvzjtXh naDVccenUTAQWpIRrwdy80/WZ7bzTn5Ppc/2EAQB4UhZzKFtx/RT8v2sGQI/aY80Acs8XK /BR2DuFR9pmiqZgLYYNoXbCW42EEzak= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=C4oCybm9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.hostedemail.com: domain of 38tngZgsKCGcFHPJWQJdYSLLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--ackerleytng.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=38tngZgsKCGcFHPJWQJdYSLLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--ackerleytng.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726011888; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2ar3js6y/uqSuZ8kEtPgJYc0vWuZF8j/b1JF25slk+c=; b=4jYnjBgSef919DCxwG42COhrpc3AQ/uTA8XWlKlICtmI/X8Ihz+tTMG9kXgeZ5y+7iO69X hr+7usy/D+01/6tKiqFwGAEwihc/u6/XUlPP89BdGgTGF/Mgvx7ij/G2P/38PrKdG51Pwn SoJ4SWmcdxHU/6wClc9JY6p1ZJGWSp8= Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2da511a99e1so1522249a91.2 for ; Tue, 10 Sep 2024 16:44:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011891; x=1726616691; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2ar3js6y/uqSuZ8kEtPgJYc0vWuZF8j/b1JF25slk+c=; b=C4oCybm902+ItkWYP4v/uPnSKXXSVBD/2mhgkGIWJQyOu3r4io2DAHK6IggHDVGezO RRA06pcnU4cD+ER//40NXeVL4+lg5Mra5NUc58NP/flQCdpmBwsuadT3g//3XPrI+/SO loyyQ1jS33IwXsGd189BXIIXeoNy2RpMrwAfYm4c+vDPxGk5/MTzNxnJLln8d62iS64P ogfigRK1c0HCb1KDdYFldEBBaBiixq3t73qk9dL+dYj0N67UniLSH340Eb2s5g9Wn8yu ugatj2uJW9bW0guSj8kMDRc4YKFOjeRLvPYic6zB7cqZI7u0PMXy8jIk86oUnXDQbV/r OS0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726011891; x=1726616691; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2ar3js6y/uqSuZ8kEtPgJYc0vWuZF8j/b1JF25slk+c=; b=JLlGOb8WB1KNo+VorlJCJOLWGXnYZbLJAkwQ/SENCPttP9FPdjfSLfiwjS5PevKZGx vObr9vdh+D39NInvNu8u1v1nUWmq3MTmfj35xVezmv0dy3Wfz84wICbqDvhCg3aiYQxm zFywlh0mLhzEdpO2RkTTttyeEDehdrzhL+ZcekSrtjY1DXF+YQxVTS0dpmqW8nbzYLSI VSh1zyjCF/lKfJ/6ThP5xWt4BqKWNk+/rmjKBZm+hV4o2uZhhT+CsFMMTbwjzVQPc6m1 O27Nnwaq8NQDE3/5eWnFgItDDUsUc4kMqAGD32+ki08TrzwAYY0IsjmajA6u5yVnbuB3 2JZQ== X-Forwarded-Encrypted: i=1; AJvYcCXmiBeQGgCPw5dbCewo/5LuujmvldpQSNp7n5f0XMxhTWY8Ru+ifdchB7rmbDEXTBGwA28zCVr9pQ==@kvack.org X-Gm-Message-State: AOJu0Yz3Lpl5/yFoX4KjIX5FTpZUs6rpSMLeQkd7rn/gvGNL4jQnxqfW W/v9n6Z/b73w4O5KFmwwBWHa9/qQV7Nq9jV38AuHZmzdXZpyzFf69G79XH3q8ZS2hT6vbsTlR/y mg7lHkqZSDB+MxY38CNDClQ== X-Google-Smtp-Source: AGHT+IFJTKDezjG0ZGixJJEKykOQcK4Q2RdFfnGKlypTv43g1OIUEWvOedTsxO4Flime3+ygfPrCyueBrEPlyPHzTg== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a17:90b:1e50:b0:2d2:453:1501 with SMTP id 98e67ed59e1d1-2db82e64986mr2443a91.2.1726011890733; Tue, 10 Sep 2024 16:44:50 -0700 (PDT) Date: Tue, 10 Sep 2024 23:43:42 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <3b49aeaa7ec0a91f601cde00b9e183bc75dc37a6.1726009989.git.ackerleytng@google.com> Subject: [RFC PATCH 11/39] mm: hugetlb: Expose hugetlb_acct_memory() From: Ackerley Tng To: tabba@google.com, quic_eberman@quicinc.com, roypat@amazon.co.uk, jgg@nvidia.com, peterx@redhat.com, david@redhat.com, rientjes@google.com, fvdl@google.com, jthoughton@google.com, seanjc@google.com, pbonzini@redhat.com, zhiquan1.li@intel.com, fan.du@intel.com, jun.miao@intel.com, isaku.yamahata@intel.com, muchun.song@linux.dev, mike.kravetz@oracle.com Cc: erdemaktas@google.com, vannapurve@google.com, ackerleytng@google.com, qperret@google.com, jhubbard@nvidia.com, willy@infradead.org, shuah@kernel.org, brauner@kernel.org, bfoster@redhat.com, kent.overstreet@linux.dev, pvorel@suse.cz, rppt@kernel.org, richard.weiyang@gmail.com, anup@brainfault.org, haibo1.xu@intel.com, ajones@ventanamicro.com, vkuznets@redhat.com, maciej.wieczor-retman@intel.com, pgonda@google.com, oliver.upton@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-fsdevel@kvack.org X-Rspam-User: X-Stat-Signature: 5ey8ii485bqoj368us47rfymedbdpokg X-Rspamd-Queue-Id: 5176580009 X-Rspamd-Server: rspam02 X-HE-Tag: 1726011892-469757 X-HE-Meta: U2FsdGVkX18I6UL9lfbLsbaJ8xVwRLnkhb0GOVnfuez0SqPIfVOCaI5pscZcqBoilRihD8r8uFkUYqtqt6JoTe6gR6hfWStT9RNG9/rJ2z5rj4bQ9HPm3jrLwIMHFDs6e03pW4AbRMCechskT3Gkymot6X+PtZFz1VfCuIF2BexAKDvwksHeEYiYBV52I57TLZd4R/4+kucytwi/B415mbB4HKY+Zq16vbEOV0CCx0CiACbJCI3H+guGUPSWly2O543bPllnPAbAH+BJS+HNGK/l2qwfMMwnoNeBqkvraeD+QKsUQsmZVJ/6+U3l5ImLlH2xEekBVZjMhyYqfh8k0nENsoNJj4bN4qGvfmptA5Amf5PNUKNnJogZLAAaWMVa/4VazVYRC4gMmGc+se9hQsCcmTGTJrH8FZztsabM2g/WqqWJ+0bmnNW/jLVceoPhinWVAfCooLUoBY3wCheF1rJbs2FKNLdhgAq2zdkt1JYbTEq0mFWjKlmX4iUsYmGWZXkih6Bz6q/ku1+REoobyL7A9RlITHeZ1Dzc9R5FcESwkFakVWWES/btuGX9n1YiSKoJsWcJvEVhE8K461NrPZjHF0FFj92zOKRxoshMmFfEPh/Bqzz2i+ubhg6hEQwdSGduzraDtBARmk1UtcGS33fUeHyt9/hP4/8TQ3SuQS6URv5stthKFupiLFnKtQusEo8cELd/XWjH2p1o2e0x+65tuq4BRq6vtUEcZcvEsCnONfMCSY8uSWFs7kyuFKJbgnc20S7qcTxfXLzG9zUzwEGeG6FUlMJQKtmdRWwAKz9CR9fY6IUsWKCP8NG4OZ3H/dMLjmSCY4nTCteYBSV3ujApzXOlXUEm0pVaW+2fEPC0TR8hC9MqPzVLLUbE0aniAsLA/6ebxH8z61AHTC1cYUeOL54jghWSDuNA2XAEY2u3DwOsepzFyrLt3Cw6rMpu5YAXpIEluRrnOjrufYB pQicXVRw nDJcCJObk0ha8bMqQihnr29BFy7naUzG3ANf0Xe7+pO4UUP6i7utu4EpseqHBaVjHE/Mdu6hNHxBqHk4NFa/XpDRjRw9ZdFEcId02iRbKqjbwDy5Noq3AjLMcZtGDNvIg/+sTHzvRL4tm+4PThDSF+P1KKqaM7fsaGmbi6u5GyBB8ikEOr1+C8nxc91UJqcQUwrNJUQFZnTLCzK6zI+X0BrLFw+dDnNf8yPFhuJxFkSWM6345WHyzEMexsKEVdnSOqu0kJMFOhQc1FFGIQAd0UAaUkX7c6eZ0DP3GgeDUykORngHlySfSjHSmw/X2EyHCF7lYKRaYqGO65DCKEgOY9gkDz4cwrK5c0+7qU7N3ZWcWmFeuHFSK/HjfWHcVV7/RJCIjCqMcxtXRuHmgODcY9JfUXDRrPl1+lDuNyJao8SF+P/RgjdWSj+7hn82r2FVMLNIH2V1EAcfGmzXpMxr7JJsn3H9kI1A1qABVp9UlymZOgZLtC4Mm0MBh9Wu9WiMVambprGgXkhG1g4lqgzG4SDvO4ahh5tatouL2YFLiwrZQeTN8SGXINcmKqqzVwVdnTU1xPN5x95PhWJKuVv1tvSKBDXjQIJjathUfj7T/H7KvWIm7JtE9KQso8aRMqc/ktUtScHc50M6xDHB7/QvfoeS3/AGkpfQWaeZ+2Gtfu3X0oB8X/uK0SM08gXknWlfOMwKJ9SG1KtJT2ao= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000371, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This will used by guest_memfd in a later patch. Signed-off-by: Ackerley Tng --- include/linux/hugetlb.h | 2 ++ mm/hugetlb.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 9ef1adbd3207..4d47bf94c211 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -122,6 +122,8 @@ void hugepage_put_subpool(struct hugepage_subpool *spool); long hugepage_subpool_get_pages(struct hugepage_subpool *spool, long delta); long hugepage_subpool_put_pages(struct hugepage_subpool *spool, long delta); +int hugetlb_acct_memory(struct hstate *h, long delta); + void hugetlb_dup_vma_private(struct vm_area_struct *vma); void clear_vma_resv_huge_pages(struct vm_area_struct *vma); int move_hugetlb_page_tables(struct vm_area_struct *vma, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index efdb5772b367..5a37b03e1361 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -93,7 +93,7 @@ struct mutex *hugetlb_fault_mutex_table ____cacheline_aligned_in_smp; /* Forward declaration */ static int __hugetlb_acct_memory(struct hstate *h, long delta, bool use_surplus); -static int hugetlb_acct_memory(struct hstate *h, long delta); +int hugetlb_acct_memory(struct hstate *h, long delta); static void hugetlb_vma_lock_free(struct vm_area_struct *vma); static void hugetlb_vma_lock_alloc(struct vm_area_struct *vma); static void __hugetlb_vma_unlock_write_free(struct vm_area_struct *vma); @@ -5170,7 +5170,7 @@ static int __hugetlb_acct_memory(struct hstate *h, long delta, bool use_surplus) return ret; } -static int hugetlb_acct_memory(struct hstate *h, long delta) +int hugetlb_acct_memory(struct hstate *h, long delta) { return __hugetlb_acct_memory(h, delta, true); }