From patchwork Tue Sep 10 23:43:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13799482 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 A8C50EE01F1 for ; Tue, 10 Sep 2024 23:45:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 445BC8D00D4; Tue, 10 Sep 2024 19:44:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F6538D0002; Tue, 10 Sep 2024 19:44:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2711F8D00D4; Tue, 10 Sep 2024 19:44:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id F417D8D0002 for ; Tue, 10 Sep 2024 19:44:50 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A178D140D4C for ; Tue, 10 Sep 2024 23:44:50 +0000 (UTC) X-FDA: 82550461140.29.B6D371D Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf25.hostedemail.com (Postfix) with ESMTP id DBE9AA0011 for ; Tue, 10 Sep 2024 23:44:48 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=4C2bF8tr; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of 379ngZgsKCGQCEMGTNGaVPIIQQING.EQONKPWZ-OOMXCEM.QTI@flex--ackerleytng.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=379ngZgsKCGQCEMGTNGaVPIIQQING.EQONKPWZ-OOMXCEM.QTI@flex--ackerleytng.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726011884; a=rsa-sha256; cv=none; b=L1tzoEiKgZ59GrAQ0VpGhNRGXifV8gvti3dodBG+c5btmWqz353Sxg3IovZ5JIw+QrbQXO CYGKT47LIRnEZrV0IiRW4VoDdn7+kAXc5Y314WHqDTnTIlOVkhVxW4ERzZ6F6XrJk1nwIe Wk2P6xrBt1V7Uqlui/5/B2qCJW0RzK8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=4C2bF8tr; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of 379ngZgsKCGQCEMGTNGaVPIIQQING.EQONKPWZ-OOMXCEM.QTI@flex--ackerleytng.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=379ngZgsKCGQCEMGTNGaVPIIQQING.EQONKPWZ-OOMXCEM.QTI@flex--ackerleytng.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726011884; 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=wON4ebge/JtWXTatH36Oz8RnYdWXk0aZ0I0s+pE884Y=; b=w6oGcaSk4FHoH4azwjXJ8vXLYfqJGyLtj4jYhKRhIJL4jfTYCCZhW5k6tNFstuiSMnXqeJ dwnzeRBle/HAjP9uTE5UqWb2x8KeqyFh+lggWltNfMPD6mNAEktktHiXeb+NdDn5r/zxLD hg7u/6871MHax1/iC130oXiPOM+0yAY= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e1cfb9d655eso12469181276.0 for ; Tue, 10 Sep 2024 16:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011888; x=1726616688; 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=wON4ebge/JtWXTatH36Oz8RnYdWXk0aZ0I0s+pE884Y=; b=4C2bF8trQH1S1IdSGmWS3dc3q74o7T6V5LSeDoW6Weu1Vuosqt7ppkvGMNlyDaFVSr +jqFzqHf8XH3kKYuUDR77D9pdzyuQWhC7usqs7OlfsmeqBlLJ+s8CcUnYuF4bTBn3yW1 3h4PAaZFv9tq3WgHpStOTspt9rjbzBEgcuVnMt8ngYJhNWiIDfWm/a+PhY9Vhe6U3GlA WYhVbhb3AjfielQBvRTcAg6YBUBSQmV5XUnDp105Wg1FydKddQjeam1fmYh/1GKRJBOn t8AU3bOkWHk/mrmaCo2vAQEa/WxHAsmGlkbUflyhk6c+euONL40Y+73yUFwQzdIVleng 3wYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726011888; x=1726616688; 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=wON4ebge/JtWXTatH36Oz8RnYdWXk0aZ0I0s+pE884Y=; b=S+s36/gdSOkO1s7gaUWoVD1QVJ6O4p9q0eqcshrkN96X0w+SN7MNyYepw0Fk1Yu4nV 6S2gIaux2jLFNJaoKTYTviJG45xeYkVbxiJiVCSCurMYSV9I5aDJ+xKc7yWu6JSdfDQv 2/WZApWoVvoRahU/pqfShCgstv1fzcOfceA9sRe/wuJ7dHeJMlrojJl2CjNzlKxLZ8wC KO/HGaVammbK6M+0JQvM4R4yFpr4rnznm/QdOVJQmpV95MT5aKKlYFSOowaICDC1i0Oc m9g2uJZrO58kaWLQzrOioRGygh/nJ5K9/mnGYw2z9yOKKty+Yxd9oZr9/CgE2dRzLacW lg/w== X-Forwarded-Encrypted: i=1; AJvYcCXKIHleTZ9r2zmoUOTkKYO1WCenStqGTzexQ67O5Lgxx5Mcie/F/8QETXwiU9Kiag7gnJy4y/DG0Q==@kvack.org X-Gm-Message-State: AOJu0YzS3lhin5txhvGswtJuia2Sg/OO1SjcInd8B0K7uDi1xgQaTGG/ DXEIiuFJdA0xXYtJyAgPlQZEBV/kJMRb49GVI/sf4j5PII1rxsXVjeJCwnaY/RJUJfTQ7S9Hf4C 4tRaTht8PiktcrG935oorxw== X-Google-Smtp-Source: AGHT+IGifFJzomPV42kuvxwSOW6D8KRl1ZUZcLgu/9vMTp3RDdNsVY265K9HmTBfWg/leXDMNAyCn73aN71Ukp8ufA== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a25:d347:0:b0:e16:51f9:59da with SMTP id 3f1490d57ef6-e1d349e2dd5mr43068276.6.1726011887733; Tue, 10 Sep 2024 16:44:47 -0700 (PDT) Date: Tue, 10 Sep 2024 23:43:40 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: Subject: [RFC PATCH 09/39] mm: hugetlb: Expose hugetlb_subpool_{get,put}_pages() 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: td75dfk8p71ohnqzjne6mo3dnjtxwdr3 X-Rspamd-Queue-Id: DBE9AA0011 X-Rspamd-Server: rspam02 X-HE-Tag: 1726011888-531044 X-HE-Meta: U2FsdGVkX1/jBRr4fWC2WtmYOgXwvaklcFasepSpOm5XqaaL86MSz7JW0UREWbU9bSbuPOyhEq4RDmrOFkd3IoIpRNvqNPa6BpqmKs/cOLFjModsNtL8P/A/YoVtPn61ochTjj36iLNnrqbfGsAQfQqo+aVIWrGcO2+qeQ+/XNd5QFpDHshhlRwMy6CSbhWdZOqlgbiNeDI4QoxHKHX0MkLkFVnlpeesazoOqAP4n9FsQ69GQVOGE+O2VgFo0BcmVQWvFaNB8UOd5M4bK9d8MBw5/znkxni9J5GOrx3zfH0K41qlKySGsrMZUqvXUjbrHpsjaCmVDByIIZFwiZzVUBVnGD8l9KLbjfjQ8b53A+Nj+bFD6W541NKroaumax2MuS6NRJzEhcpFm5Jth5JuEqt+98mH+mge2CmC1Qa7QlYPI2aqH5FCPvIpCLe/1vQZ6GezxVC9CH3WVnJqfNjEg/qhYPj2ZnDSSHJjl54NQ7xkF3GYZGTddX0gCLfvfD7x20oV015H3dIlk1bONZGZLXo9jWaMRSWFJENxd0Tz4m72vh8A/ML7xGzHoEEEe0dnFy7oYS2m7TXIIgKL00hSBR9exP9qC8qm1ozIjoLeIBdcB0lU5U7x7rNA3ePUgqDsp3tAqadDOL3JlUKjnR4UNZJs12xolmEvxMnYJ9Fd8j9HiJYM5yOpysENoeUE7kl3sLUqhdiFjRVMCzsaJVGJ7QFoNhkwKTL8ZWMF+pC4QDt2lxEswhngEAcHQHxYP3dpQb0zCw8O3VUyxqWYoNmpZqK6bZ8J9cZz2p3Z4ihQIrfVVsfrbeDcsc+vxJSug2LV62XAmNr2nIewni69af89vEsG0CsqQ/s25tD0cGilrJSwqfntkcn5KvlUpXWOMdx1q2hbs4UEXbk4a6a07pdTG/Rzp7UYJxlogC5lQwg+pgQweC5SPyk868QFtXsVm2uchVcKIrRAuKID3+joDJc RVuxZDPi 3lgs9aQ9s4GfGsWIpyZlfDLCjWXNHqmLvO6YqCaJD6JYWzloM5qXeX3gmYhjUwTvKg8ytjQ21A8YluvncdLfMtRuzvUi/q7VOSL5Bt3kaOQXnXox14eQQeRiRyAJouUA6dtU05yUaoDcezIHizkksulQJsE6mvT8iJ03B+Pr5hljgvLvBLCpGKC980RiqfiFXYev54boe6SwGewkVzE0Y3qAKfNXrcsjkIeziuKDgMnh4o1l+LiplZD92WmOTdG8uGzA/dB2nvufVhwUUWQCEnz0TEBXRgNwl7CYL0GXmYVGZe56uD7qiQ1QANFhJE5YS5yhz51ff6AKQ4RYpXvzFp3LGy00gCSMexGaiMBClXgOypbjGPJT2SEyARLcuHMbsRXQjKfNODrgcLKwR7azdBvtox9Qny367y2wigZQm36tYyLZRKzdbiy8nkcVk/eSO0PHPpxI1ugV0FR37AiTxwkGt+5VVvSVOX1j1vynrZkzUsTaI86CC2a9luk98Ab902Yxd55pTQW+yVU5C90uGNAtOdCIeTj8zsQlSi2P1rwNK//Rn4j2j0lHqKuXXaBj1Tn4HCEE1FfWudWX3LAmZlSvgyoxWceV0YqJ1XkYicU1jSXxAT5oeb++rFsPH9mzxNHYOFL2U9uzoiPfiN5k9Y+K5UxElYZ8AUQEk X-Bogosity: Ham, tests=bogofilter, spamicity=0.005365, 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 allow hugetlb subpools to be used by guest_memfd. Signed-off-by: Ackerley Tng --- include/linux/hugetlb.h | 3 +++ mm/hugetlb.c | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index e4a05a421623..907cfbbd9e24 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -119,6 +119,9 @@ struct hugepage_subpool *hugepage_new_subpool(struct hstate *h, long max_hpages, long min_hpages); 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); + 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 7e73ebcc0f26..808915108126 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -170,8 +170,7 @@ void hugepage_put_subpool(struct hugepage_subpool *spool) * only be different than the passed value (delta) in the case where * a subpool minimum size must be maintained. */ -static long hugepage_subpool_get_pages(struct hugepage_subpool *spool, - long delta) +long hugepage_subpool_get_pages(struct hugepage_subpool *spool, long delta) { long ret = delta; @@ -215,8 +214,7 @@ static long hugepage_subpool_get_pages(struct hugepage_subpool *spool, * The return value may only be different than the passed value (delta) * in the case where a subpool minimum size must be maintained. */ -static long hugepage_subpool_put_pages(struct hugepage_subpool *spool, - long delta) +long hugepage_subpool_put_pages(struct hugepage_subpool *spool, long delta) { long ret = delta; unsigned long flags;