From patchwork Tue Sep 10 23:43:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13799494 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 D65BFEE01F1 for ; Tue, 10 Sep 2024 23:45:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B5638D00E3; Tue, 10 Sep 2024 19:45:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 862748D00E1; Tue, 10 Sep 2024 19:45:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B70E8D00E2; Tue, 10 Sep 2024 19:45:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5CEFF8D00E0 for ; Tue, 10 Sep 2024 19:45:13 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1391140C20 for ; Tue, 10 Sep 2024 23:45:13 +0000 (UTC) X-FDA: 82550462106.26.42BBBAE Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf25.hostedemail.com (Postfix) with ESMTP id 4A968A0012 for ; Tue, 10 Sep 2024 23:45:11 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HO01hlm0; spf=pass (imf25.hostedemail.com: domain of 3BdrgZgsKCHoYaicpjcwrleemmejc.amkjglsv-kkitYai.mpe@flex--ackerleytng.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3BdrgZgsKCHoYaicpjcwrleemmejc.amkjglsv-kkitYai.mpe@flex--ackerleytng.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726011774; 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=v2byeEE5glf1HSY5uEmaELERh+IVrgf4yY9vZeuIn10=; b=qnUtaH3j/BvamlM39zMCMVrQRpgS/aYD48ecmsmqxQEdl17EADKg3+cjzOAwkahbMUgQj+ rfkbHMZQ4MIR1CX8YDz11fS/DtFao7CURyo4J1guOuIrJ0cqwaprB5FSXKI1p6MKm4lSlJ V+/40MbUHvNNrt9zFfm5ypuKiGOs4vE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HO01hlm0; spf=pass (imf25.hostedemail.com: domain of 3BdrgZgsKCHoYaicpjcwrleemmejc.amkjglsv-kkitYai.mpe@flex--ackerleytng.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3BdrgZgsKCHoYaicpjcwrleemmejc.amkjglsv-kkitYai.mpe@flex--ackerleytng.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726011774; a=rsa-sha256; cv=none; b=CsCf492M/SL7wEtdDZxi3ikfjQBjvh2sFi76v5XSBwSuhUAIOeCVD2V3qJRaIvlqotM1uL bQrjd0G1PgXMkGGGcVGyoYEwDrqhDvA3U2YXxUXL3bZUfWFsleSPHUHD8PqCFNHf35RLd9 R2rmolAd13HC9PryXxgfD+3PFR5ZGTw= Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-7cf58491fe9so5906081a12.0 for ; Tue, 10 Sep 2024 16:45:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011910; x=1726616710; 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=v2byeEE5glf1HSY5uEmaELERh+IVrgf4yY9vZeuIn10=; b=HO01hlm0UqCGMbbMhRlOPxo06cO30vVINpOVM9bRKAkiNF/g66Pnoq97+UOBPdzT/h kicwe0gvqiRgmKGKYQu2TgV7sSo6QOAcBeQVVf7pYWGWvSWJymyIkFTO9v+TaIEUv4D8 EC7jtl7ymL2/cIO/CTSuj0SwrfltrpY6sLmxNIXLKAPnUkEwGNGRkFlVrY88j/zln7Me HnfLCyPimHe1Or4Xbs+vAG1/iUW9gFDm/yrroImi3J8/CNDGtT5QnndOHiIfV9yKE7Ar XDPWKs/E0vX7v85KFb5TSGx1PAYexBKskpRL8fJICQMFsuycptylZ64ooyi/VqNVut7p 2UZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726011910; x=1726616710; 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=v2byeEE5glf1HSY5uEmaELERh+IVrgf4yY9vZeuIn10=; b=eciVQ0qI0GbrjWI187lnKvnJ/P6E2Mh/31Xb8yJ9bKIQ0C58jynzWhCvP9ZKTexf4r a0vL35GHHucb6hCm2aVHAnqOUgMGkcU3HVNmZQ5JpDuykdcThIRtWf9jAEGrJcegDtIZ Pk5fTjbTp07QEV1XL37lQJmshhvTtpVfBIlLTLRAuh2QSoi7hTWkmpVWgfD7QEB3qlbp HlNvbcP9KnDr2PaJWtVRR6c5BL8MArbBlYSdLSL8FcvvO/3BduTi2dDjPcRr0ydwurxW uAKt700Gd2IRFz3mQYSiPnRt2jBZ+z3i3b5U4coCm+5exYVQjGoDd9WVioIsMfeT34qC MX2Q== X-Forwarded-Encrypted: i=1; AJvYcCW0OhJ63jmv5ZHczLT8Gjrac1hC7iQv9AwK7tifoLVwjTkOEXOfZJZ8HTxwEeYpmWdvSugnVKeepA==@kvack.org X-Gm-Message-State: AOJu0YwcvZOubN6tri5pVgi7wGzRKSGfFB3P1ZwmBI/wYbXmkeVGcOhV IbBaAgq+FoTOfQB6C+RZipc516wkxtuSEZqLfVWnw+TlE8+qsB3xMUGh8s/61x9s5TIbRlmgc37 1UB2RnNjloUvKje2UxUun7A== X-Google-Smtp-Source: AGHT+IHRNRhjiY3twcj3iiSAd6sK0DpsvR2293BDcZR4oPPmoZmD0jtdld7lS7ASmX+XqQWY6/tAjSk1hpoqvcGWvg== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a17:902:eccb:b0:206:aa47:adb6 with SMTP id d9443c01a7336-2074c703af1mr2052395ad.6.1726011909816; Tue, 10 Sep 2024 16:45:09 -0700 (PDT) Date: Tue, 10 Sep 2024 23:43:53 +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 22/39] mm: hugetlb: Expose vmemmap optimization functions 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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4A968A0012 X-Stat-Signature: oenoccoqdcy8g7ohbwc8zety3mt3dqx9 X-Rspam-User: X-HE-Tag: 1726011911-253737 X-HE-Meta: U2FsdGVkX18e1BOxL1A/lYmGfCLY2/JcwKszreuP9sxpO5CNozb135IXvEm63W9JDtu9M7aqXnfKeBZKyq5PBEwvR0eSqMKk3R8qYjxvWoBvFJPhECjrrOHL4lw7XwCKpdlqfXgWNQqEWB9Z1U644XHDa1fWXNlUgr1Ignr+p/WH6KIqzOjbBUHgulgSCrhzDOoX2/m3bk9Rk/Ba0kIF5FOZVx2X/qyR3e5LmeLWBZIAauyxoJSZuolCb7+d0ALAZWXpzUoOWhsOd4VJuHun/5MnHNJvVYnIzXmz3+LmZXwji1WQILl8n+Psjsuqhm02sMpG1U4dTpUGc42DniufXAbhoac47d7jCvRdFoFGVoY7PygIsKlbkffyBvGww4xdVSVF5BMZLK8ciuhFXXL25dzWoYcGBirCuSdbIb8TJ5ChG/73p8pCIPIHaatpNANwi1vBh8zMSQav7VxE0b/GFmESdXrIDpwYCYfDSQN3DFTXJgud8G5RJ4hQlLqYQIzI24asLG9QTQemZriqrjd7rDuQvlCQxJxs/+K0uhBtsJuUq0ValzIYOSNquZOMQ0U/ndUMQjAmYdXfSLcDeUq7Uc4Bkw1qP/blPwM0Bd0hvqTb/dkSfWO2CBXGa9N0a48d1/2YbQxgTod3C+vC2wCgb4D9G+F3qLgR+q7gwiWrf0hgq/XI9nOP/Z2JmDD3ItfRBVmJD2M+LXq8AaDRQd0EkzTOE0hzCCe2LOCa4/+1dpSG7+wIKTJpRXelKQLdtHdXmhJ+LyA7QdGRqCfjOEa1JG3AMeUTgdsmhFV078nt8J4F/IOoZ2vOBiuyXrI7/PPFV1T5jJNRuwW9uUbjHUE+c+OnFCmHASRzbwHI2k3ufse1DgzeuvITQyfUy4u1O8qFNgFG8MSjJV1Gwa7+A7CAaTasP7yww4RaBeF7galFU1yNFcm0bUkTp9gH3lv9wyh7bNSrHyZzVybXyn21Rfm 05p44qQ9 IYW8T2qZmL0nUEl872vdVcSuwKF+gHpWDx8sZoW7rkTi55rg87BHbmhkhaw7ZdbXW5uuUaOEChd4VYQv4PbTA1xee8rqqr6D5E6igActBEQ3PYXPSEDRvDPgtjvLljygLL4OCYfm9P6Ju+Lm1K0zyjT7boDjc41fsdYcTsvFwvdFLyUJhLbt09K2LdWxHVIzhOgQ4m7qJF6DMwvEydKtcU0YrHsgiLDm5+TqXdFg1DtXQE12eDsejU96IS062jcs2sHsSgvirFEc274KVvuxKMsEYKSsRKtEzHBr6jtXkTGmPh0KTgPInp6d0rkIX/qsaoTRON4EjySvtuh1Zb6ZcUc7adW8t1Aojg6CvPaDpmsxmr2lHQTKN4p00+AFo6mmifAw0QsRxy/V1ikEnIvm2eUTq117qe967PkSIY8pPSaZrA6WAP/toHXvLMR0i/4hEsttexbEsAVfK+lXXtjShruIWUAUqVD/pME/YfA/56iBAucx3xZo+Vsmg9142Ru7qGvMFQzpueTNlI7ViRBdO/AgSk/iTWAQhq3K+55vcIxDRdxrjCvx7nyAGN5padUOu1vWD4UhXTlxb5NAt/hCnliwG+IhnS1Sz41LZy+b3WYLqahFplCEyUAGHFv0fQhMDVaO0qADktoagAaOhRhGnu97xzsAr2yU7yoI2qp9gyfkbubP0DX1N03X4rJL0IC4Jpike X-Bogosity: Ham, tests=bogofilter, spamicity=0.000621, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: These functions will need to be used by guest_memfd when splitting/reconstructing HugeTLB pages. Co-developed-by: Ackerley Tng Signed-off-by: Ackerley Tng Co-developed-by: Vishal Annapurve Signed-off-by: Vishal Annapurve --- include/linux/hugetlb.h | 14 ++++++++++++++ mm/hugetlb_vmemmap.h | 11 ----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 752062044b0b..7ba4ed9e0001 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -284,6 +284,20 @@ bool is_hugetlb_entry_migration(pte_t pte); bool is_hugetlb_entry_hwpoisoned(pte_t pte); void hugetlb_unshare_all_pmds(struct vm_area_struct *vma); +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP +int hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio); +void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct folio *folio); +#else +static inline int hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio) +{ + return 0; +} + +static inline void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct folio *folio) +{ +} +#endif + #else /* !CONFIG_HUGETLB_PAGE */ static inline void hugetlb_dup_vma_private(struct vm_area_struct *vma) diff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h index 2fcae92d3359..e702ace3b42f 100644 --- a/mm/hugetlb_vmemmap.h +++ b/mm/hugetlb_vmemmap.h @@ -18,11 +18,9 @@ #define HUGETLB_VMEMMAP_RESERVE_PAGES (HUGETLB_VMEMMAP_RESERVE_SIZE / sizeof(struct page)) #ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP -int hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio); long hugetlb_vmemmap_restore_folios(const struct hstate *h, struct list_head *folio_list, struct list_head *non_hvo_folios); -void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct folio *folio); void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_list); static inline unsigned int hugetlb_vmemmap_size(const struct hstate *h) @@ -43,11 +41,6 @@ static inline unsigned int hugetlb_vmemmap_optimizable_size(const struct hstate return size > 0 ? size : 0; } #else -static inline int hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio) -{ - return 0; -} - static long hugetlb_vmemmap_restore_folios(const struct hstate *h, struct list_head *folio_list, struct list_head *non_hvo_folios) @@ -56,10 +49,6 @@ static long hugetlb_vmemmap_restore_folios(const struct hstate *h, return 0; } -static inline void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct folio *folio) -{ -} - static inline void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_list) { }