From patchwork Tue Sep 10 23:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13799495 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 A70D6EE01F2 for ; Tue, 10 Sep 2024 23:45:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B74118D00E0; Tue, 10 Sep 2024 19:45:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A856B8D00E4; 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 751038D00E0; 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 A30A08D00E1 for ; Tue, 10 Sep 2024 19:45:16 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5916FA0EAD for ; Tue, 10 Sep 2024 23:45:16 +0000 (UTC) X-FDA: 82550462232.06.461B24D Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf27.hostedemail.com (Postfix) with ESMTP id 9140C40008 for ; Tue, 10 Sep 2024 23:45:14 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="VHuqBmE/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of 3B9rgZgsKCHwfhpjwqj3ysllttlqj.htrqnsz2-rrp0fhp.twl@flex--ackerleytng.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3B9rgZgsKCHwfhpjwqj3ysllttlqj.htrqnsz2-rrp0fhp.twl@flex--ackerleytng.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726011910; a=rsa-sha256; cv=none; b=LiKUdgV6DZ94jj19ITy0ObE3yimyV7QdGtFYosSons8hSlpR+m8CD8ycB9RvoiLxfWehJ5 ABl7WLGb5Ptdt0fi62fmEgznzLfRH2AlXvpf6GS+HxrfaH3+QqPX5z1XEHJ+lLesInZ4kM I+RBMYi2LC3LorTdrJQf6lQCNzx64fU= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="VHuqBmE/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of 3B9rgZgsKCHwfhpjwqj3ysllttlqj.htrqnsz2-rrp0fhp.twl@flex--ackerleytng.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3B9rgZgsKCHwfhpjwqj3ysllttlqj.htrqnsz2-rrp0fhp.twl@flex--ackerleytng.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726011910; 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=XJnVJ3hPk966+JzwkBdvbRfaDiCGChJRXNWj1r0A/AI=; b=NTGU7jYjKfx/AvgxSbl7UgKREMXiDGFaiG/UgBbwmZGg0BHGc+xIi6oXERiMFQxUtu7/hY WECwsnCiGwC/QrSENRZKbhxIHWsRiRlmuhS57LkL/XBqr0jidmKmE5SuHgC+1B3BfwRkG3 +yizP73REvMP7A2bxX+/pOpLwFkO1Tk= Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-7d50c3d0f1aso5097216a12.3 for ; Tue, 10 Sep 2024 16:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011913; x=1726616713; 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=XJnVJ3hPk966+JzwkBdvbRfaDiCGChJRXNWj1r0A/AI=; b=VHuqBmE/+DJuAyavGZ0/CGT5oZNUZt3h2Pur4y6Rgil7Ug8c4fb4AE3tqAvhHh15fp hTAhFd710mjqiw6gmVqLODI+y2R24izJjroxPHws9qj4rUZkNg33XLAnCLEBW4IKDh/l K2B7I4GvGYaJjz1xC1Ui89mZs5WAAPEXLnXqjOURotC6YeamQqQWuEYe8uqM0/8gFMja G77cl9H7d//pUl4RlUdLoI5+ozmjZdWk1u82sC+EK4K08+ZWqKt10oIrRhM3MR4aPHjY j1/so1vRhlfNjIfS5+0hqq/yw8PiuXg0lve+KLQqJ+3i+oool9o5IF7EPTBfHC2fpgwE rSiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726011913; x=1726616713; 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=XJnVJ3hPk966+JzwkBdvbRfaDiCGChJRXNWj1r0A/AI=; b=Oc0sdAbSWZ6z4V4Kr8PMUKVOMEAQ4RqZqpuXASa5RwsBuTLRtMNhCtZi0WGC76mkEh mkV+aIaeCo9NzUtkdAmZi1LdCPg1jALNYxs/2yWLukyhXbRC1/QSiTOBTj9Do95P+74g BhIY5dQFTpJuf2hydlGZxMNvBQ/61lMKj2jCnmftgF+DmE39tfx0Y6Edz9A1hxds0waJ Bf/XKDUiyEw7RK3jyFsMMf+56h/RIcVEe6vLk6XZrOmCGVvipVuDxv9o6Q1u2X7R2sSV +J58R4MAfDnKIdb01jQyU4zNFqnfGXfbAPVr+bk9LRhpr+WfNEleAMNgFu8PE6+8ep0b oGUg== X-Forwarded-Encrypted: i=1; AJvYcCVhW0nf6rMFIyCbLRw2h9+p3BSqfWP1sZ4M0ETgRAGhFbEwDcn1lsA8epxggXLbsteG1JnZjPK2Hg==@kvack.org X-Gm-Message-State: AOJu0Yz+IToYqaiWNuTrNWX4F3eHepfKbc5xAhYEQAQIUn72rCLhoNOY 9isvxBrVohdppGZAHmgV3rKWCBCwbl0gnFDz8yRYOvAD4XjDAi4mFKu1E+t7cUI5AsGOSvpS6+v sHF2dqD/zsPwcxUa8SutWFg== X-Google-Smtp-Source: AGHT+IFupyBy4ChWh4+QQZzDjp/0RDwyZGNbYZlLigdfa+9eTsAjgorPIS9wF7AAjJqg5MMFYi7bl04vejqoUPfawA== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a17:903:244d:b0:206:cace:ae9c with SMTP id d9443c01a7336-2074c6a44aamr66745ad.6.1726011911534; Tue, 10 Sep 2024 16:45:11 -0700 (PDT) Date: Tue, 10 Sep 2024 23:43:54 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <226a836ca381824cfe17ed42be5cbf9972b09ab1.1726009989.git.ackerleytng@google.com> Subject: [RFC PATCH 23/39] mm: hugetlb: Expose HugeTLB functions for promoting/demoting 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: s5bztqbbp5a3mdm8nxrki1688egjqym7 X-Rspamd-Queue-Id: 9140C40008 X-Rspamd-Server: rspam02 X-HE-Tag: 1726011914-155752 X-HE-Meta: U2FsdGVkX18PvgXYoVA3lKIOM9ccNFJoh56KuKQ8dJNOIUS2jFVI00Yhai5LmygCRxYZt9jnKsoIxWkkU6530yhkSCZouIsGh6KyUZ4reYX1EHYFfGmrYPYlDTQmQDLc//Eju01a0qJ/38mKCTodbdf1z4xPiDJa5+4DRXE1sOQTcmlDGVP/0G51NwKTVSMD3dnwA5j+qc/Q7PPovVNZNHBpwvuSxHbXmUpJd4mCmXqwMEsjljiJxkUF4NhV/GiSx0fP3BI6oeycjakYLIpczxiDK7u305ZdvCqHFwa11JNenJsbjuNKi6vZRw1zUUV+tULaoTc/rM0lkDFB8UZ4ACVq7h6MVxP8zY6yQe80fY/SpS+Mog/QsxWUInMNg9Uco9wfxO074+qLHvIXhsmzA764n2C8Pi++HsNpJH0IiseMn75QBLMrdKFmdt8WSKOx92HFHkvIQUwib00M4pOTygK6VGoA22k5h8KO6ZJp/Z7llGCYHsOqysDFd6bv7qBxBoCopQaq675aGNnbrjfD7cEu4JUaSiatqPXgJnD0nFQLqAuOMvUCAAfOJsI0g8ZeRyhhwj9pVhu4U8gbRVapVjLsLVG37MECYGcIMEtOYvk0nIaU8qNGvOYF2JWZKBEWNeGMoZHyf07RnbZlozuiVvhLi/0sgFKDFaKpXaW6Y8xFEbr4acCiGnyLGIy1FpelzQn+wNeQJUtDeh/bD5ZaejhhHRPy1FZGjLx2CJMVXJaVM4bB50JzsJ+4mzJlslQuPftnYoA3bhDc9BKN4LQJX/B+3O37xsxZcSXfBnhN0V8EJR3ewIOK0Zmdik1rqhmRzYTzdhXYYUk7ttMnFsYjPla1Ar7jIpzyaMqf4qCbdIqqPskDV83VhXr7/E/SWcW/8Ih1KQ1SUUeaMctUTIFV39pD+9GfVKst+tkALVyB4oX3CUuUfngCQuyAGzXCUGOibK/DtWx/S1y7YzUVaBt GpTigNeb GIOeHou2lhKLeaz61KkBp5Jpp86J4/e5562MZw1SKHu++3WG2Ft4PriOkTH93k7093Lx55rSJyCtsDYO9w2TOiQuMFCR0BmTsuqhRc6MQ4pwRcTmqnh3XH3LnpMSwMcd2IoGz83cD6jlA8U13naQ0eSXrTcu6Ik8pgZHUx+YoaYuVy20Q/hdEoSXrtf0ALCxPjg2BTAKCRCRy4olevo0G0zNPWqDZ1a28XoaG7cquqTZDVWCPAGoLR6kKAbtbkJ6Lxzu9Vr8vSCDg3K1By8k0mNoO5tVMdVhdivDw+Tgbv8PEA0EtFwJhIvxS38XGs/wMlmV3FK5CZzy0zS95+uFU78GmPluZN63ShupIs808pyN88oUmbWVa2izv1pSFYFZs2IxJIf7+v5z9NTDxV7hXCxyaUqOSNZGnNAi+dejtB6f/04+hQqPg6XJ7cFJoWJl17a1YIz7sa8jU/IkOyyiTxt2JC1HtbE6ffzuluCm59qTvY21+X0brJKfAPF7ux+V7sgLcfb60ygstSJ6bMMCbuhfVu59jviFJCt3cAXG2sSIuVwQ1Q1xy7Hur7ON3Qk+bJc+XBwSUK6jiQ2LvRN95fLyrw8uCtIshlA/cGi6EoQ4QUceGK4owXCpl/wfZLYNtaIL2o6Sqpn3WCZ2lvHtWN0A8dWwe3L2Jrc3H X-Bogosity: Ham, tests=bogofilter, spamicity=0.000363, 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 be used by guest_memfd to split/reconstruct 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 | 15 +++++++++++++++ mm/hugetlb.c | 8 ++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 7ba4ed9e0001..ac9d4ada52bd 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -298,6 +298,21 @@ static inline void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct } #endif +#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE +bool prep_compound_gigantic_folio(struct folio *folio, unsigned int order); +void destroy_compound_gigantic_folio(struct folio *folio, unsigned int order); +#else +bool prep_compound_gigantic_folio(struct folio *folio, unsigned int order) +{ + return false; +} + +static inline void destroy_compound_gigantic_folio(struct folio *folio, + unsigned int order) +{ +} +#endif + #else /* !CONFIG_HUGETLB_PAGE */ static inline void hugetlb_dup_vma_private(struct vm_area_struct *vma) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 372d8294fb2f..8f2b7b411b60 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1533,8 +1533,7 @@ static void destroy_compound_hugetlb_folio_for_demote(struct folio *folio, } #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE -static void destroy_compound_gigantic_folio(struct folio *folio, - unsigned int order) +void destroy_compound_gigantic_folio(struct folio *folio, unsigned int order) { __destroy_compound_gigantic_folio(folio, order, false); } @@ -1609,8 +1608,6 @@ static struct folio *alloc_gigantic_folio(struct hstate *h, gfp_t gfp_mask, } static inline void free_gigantic_folio(struct folio *folio, unsigned int order) { } -static inline void destroy_compound_gigantic_folio(struct folio *folio, - unsigned int order) { } #endif /* @@ -2120,8 +2117,7 @@ static bool __prep_compound_gigantic_folio(struct folio *folio, return false; } -static bool prep_compound_gigantic_folio(struct folio *folio, - unsigned int order) +bool prep_compound_gigantic_folio(struct folio *folio, unsigned int order) { return __prep_compound_gigantic_folio(folio, order, false); }