From patchwork Wed Jan 8 23:31:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 13931715 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 2E95DE77188 for ; Wed, 8 Jan 2025 23:33:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8DD26B0096; Wed, 8 Jan 2025 18:33:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B3CF86B0098; Wed, 8 Jan 2025 18:33:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DDF46B0099; Wed, 8 Jan 2025 18:33:49 -0500 (EST) 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 80B976B0096 for ; Wed, 8 Jan 2025 18:33:49 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E6AEC120B3A for ; Wed, 8 Jan 2025 23:33:48 +0000 (UTC) X-FDA: 82985889336.23.4F1D106 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 304D94000F for ; Wed, 8 Jan 2025 23:33:47 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Khc5r2/z"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of npache@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736379227; a=rsa-sha256; cv=none; b=OQMu0r5Zpt+qnQTGhnKvHeLCuxn+OCnex+8DxzGDDpfZwrBHodwX/g9jexQANJHUX4r5n8 CqZUk9VwoRrU+hxq+Fs2Cn8Si+Gxh2XsAD2bTPgd97wtAeGzZ/3/y8hlr5WAt+wcAYBpoL RK7Ic9YrGqJ4C417Ur1EQbQIe2TjZFs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Khc5r2/z"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of npache@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736379227; 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:in-reply-to:references:references:dkim-signature; bh=LYWZaPy1kd0tcw2Lw/njF3yTpmJS5BgOSyQhXLKd6xQ=; b=DT4Q7xdPkT2suKvS5IITzqbgl1HR/iY6tp9XhTQ/iS/3q+xWPTs7UEGBki8LR+Ub5efcfS 4vO7D0H0vv+OnS4Ho/T/BTGECkwz7f5gMIvTZSToH69AhMPHenbPE4iSeXrD/49LBoAoIR g1jTaZO0QEuT/4xTDiJ6wV/7DfnJNgY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736379226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LYWZaPy1kd0tcw2Lw/njF3yTpmJS5BgOSyQhXLKd6xQ=; b=Khc5r2/zXw7o6w7Z2cdbXuY1ggnhvsooA+xh81FhWeVDfWdefsgDZ5uxGyTI9p51OYX4MI P2D7z2TKOvA4B2ZzII+uny8m5gKRS5QAIJyrfvujH9k4cL+nsz+huKSSGt2/qiVWE9CbHX H36MA8mUPMrqkwxa2vhBTOa5OwlOzug= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-425-jTdYKgYgNhSn6U_dgUqwTQ-1; Wed, 08 Jan 2025 18:33:42 -0500 X-MC-Unique: jTdYKgYgNhSn6U_dgUqwTQ-1 X-Mimecast-MFC-AGG-ID: jTdYKgYgNhSn6U_dgUqwTQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 916F619560AF; Wed, 8 Jan 2025 23:33:38 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.80.41]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D82DC19560AE; Wed, 8 Jan 2025 23:33:30 +0000 (UTC) From: Nico Pache To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, anshuman.khandual@arm.com, catalin.marinas@arm.com, cl@gentwo.org, vbabka@suse.cz, mhocko@suse.com, apopple@nvidia.com, dave.hansen@linux.intel.com, will@kernel.org, baohua@kernel.org, jack@suse.cz, srivatsa@csail.mit.edu, haowenchao22@gmail.com, hughd@google.com, aneesh.kumar@kernel.org, yang@os.amperecomputing.com, peterx@redhat.com, ioworker0@gmail.com, wangkefeng.wang@huawei.com, ziy@nvidia.com, jglisse@google.com, surenb@google.com, vishal.moola@gmail.com, zokeefe@google.com, zhengqi.arch@bytedance.com, jhubbard@nvidia.com, 21cnbao@gmail.com, willy@infradead.org, kirill.shutemov@linux.intel.com, david@redhat.com, aarcange@redhat.com, raquini@redhat.com, dev.jain@arm.com, sunnanyong@huawei.com, usamaarif642@gmail.com, audra@redhat.com, akpm@linux-foundation.org Subject: [RFC 05/11] khugepaged: generalize hugepage_vma_revalidate for mTHP support Date: Wed, 8 Jan 2025 16:31:21 -0700 Message-ID: <20250108233128.14484-6-npache@redhat.com> In-Reply-To: <20250108233128.14484-1-npache@redhat.com> References: <20250108233128.14484-1-npache@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 304D94000F X-Stat-Signature: z3mbqycr47u5swgpmsp7p3p4eqi9asde X-HE-Tag: 1736379227-570814 X-HE-Meta: U2FsdGVkX19zNxmPaKu5Lqos7KfAk0P9WbPB5bXfieia3zirDwit49xWjgtU4xt5rq2DmORQYshnBobohnYoWu64I1eTtsUbcFDjWj/b/Rqf9YOMxF1IYBKXWcr13zj++j5xvE9RIV/eZ45GtUOcq8H/+Lep7x3H7zhG4QI8/87PxnVdDkXe5zQpBR1BPWihBWzCpmYA0Sn35UQ7XMHjav7/kvJNxLI4oyIJLEVH9H7gf4OE/OLSds/wxfDvFFQc0tBg12lwFq3KCR/9QUB33ESo/aV2UDMj49ZzkaqURsyXOifGW2U6ebdSmWEDnjTnWuxl5PEeQ/xyHGPKhkN1vRUkViaFBSgoOLuSVF+tJ8AB5+db0P18/mD5PK69+Xcew4KeCW+mZEsCsXnZzlmrAu09k3xRv6SlUejdPK5gvM/RcjZLVvPiwLjM7Q79OH4MMQxYU2A/mStBsOSGLInIaFbioxpJEZLbHQVrXbGqCn9Gi+euQwz0vIOlWketBr7FTpYm0hDyCxiaeG2t1x9AerwCjzH9zAgaCaD0Qtdm9Xk9wcXTd+zszJcyEtqlkVehGNzENcH+iqq4an7CWfRxtKu6LFuuxTygShSSMuONYtUQjyyd8AqqwEGoX4rxE9rwafIJ8fCNMYjDguGEl4xgAowGY09jIHJkRyIpVQYVBKraj/3RlKnr+HT08T7gjtAsCmwx0vNkVB4PJyLT3ZyLRE0HSb4M5v+KfYJt4l7Yru4wYTZOJOrG9jn0k1iECoBSknbiMzRmiymCF+xgtI6gOKEE+Vjpux1Swe+QMwW511wH2rutvPutMuHjtO0kY1V2Xt/OlK5GFDi21Vwnd0icDpbvfUCc5D7MA7AxHCjZBv6mjGrcm9cOA0hYpZzrFq97W+e6bdwkfculUppadni+OBxnZpjNj1TtpM9IIqiSA9Vlfk9PrOB0HjIRw9M7ShAUrP/9dkdRRHopa0xSF7C Ge4GuYxR /Ee1aBrsuTB468HmZT9CkeF9rz1XhYT5rnCN3WnbvjN+X8cK8T5gknrRLzA3UbFRGZzYWlRIgRJfyin8HgLX6ZPZt2MgSgPB1ZG0TTdUmGmyKomsU1wpp3EKm30EBx34B8K+IbsdRjjr/oTlYjUdxntkYIWSFZBQkeWeqrePdmObRhzSq1qwHmPlmHFiq0GjHBQA/SxeU60bKqX4qu3hZ6dxdDEiAd5l3hhQP00VNnQruresdAMK4iUwOnCvdYT2Ku1WA7cQ009FTewH2Vj6ESzCp3rJQbbBesokCVIr5Sx9GSYHVzghMtapn5l2XoUS0g5HSzK3J5N1WEHp/DAEnint4ARqFYjA5j3QphfuYDzeIBQsde7JgivBvvN7IutAzGEgLF3vuOfrAwT5HqgznImKtME9cE7wBjtiHpQLlDPDOaTrDg3gKQmEqtVfh9YgbYpcu 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: List-Subscribe: List-Unsubscribe: For khugepaged to support different mTHP orders, we must generalize this function for arbitrary orders. No functional change in this patch. Signed-off-by: Nico Pache --- mm/khugepaged.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 90de49d11a98..e2e6ca9265ab 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -920,7 +920,7 @@ static int khugepaged_find_target_node(struct collapse_control *cc) static int hugepage_vma_revalidate(struct mm_struct *mm, unsigned long address, bool expect_anon, struct vm_area_struct **vmap, - struct collapse_control *cc) + struct collapse_control *cc, int order) { struct vm_area_struct *vma; unsigned long tva_flags = cc->is_khugepaged ? TVA_ENFORCE_SYSFS : 0; @@ -932,9 +932,9 @@ static int hugepage_vma_revalidate(struct mm_struct *mm, unsigned long address, if (!vma) return SCAN_VMA_NULL; - if (!thp_vma_suitable_order(vma, address, PMD_ORDER)) + if (!thp_vma_suitable_order(vma, address, order)) return SCAN_ADDRESS_RANGE; - if (!thp_vma_allowable_order(vma, vma->vm_flags, tva_flags, PMD_ORDER)) + if (!thp_vma_allowable_order(vma, vma->vm_flags, tva_flags, order)) return SCAN_VMA_CHECK; /* * Anon VMA expected, the address may be unmapped then @@ -1126,7 +1126,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, goto out_nolock; mmap_read_lock(mm); - result = hugepage_vma_revalidate(mm, address, true, &vma, cc); + result = hugepage_vma_revalidate(mm, address, true, &vma, cc, HPAGE_PMD_ORDER); if (result != SCAN_SUCCEED) { mmap_read_unlock(mm); goto out_nolock; @@ -1160,7 +1160,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, * mmap_lock. */ mmap_write_lock(mm); - result = hugepage_vma_revalidate(mm, address, true, &vma, cc); + result = hugepage_vma_revalidate(mm, address, true, &vma, cc, HPAGE_PMD_ORDER); if (result != SCAN_SUCCEED) goto out_up_write; /* check if the pmd is still valid */ @@ -2779,7 +2779,7 @@ int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev, mmap_read_lock(mm); mmap_locked = true; result = hugepage_vma_revalidate(mm, addr, false, &vma, - cc); + cc, HPAGE_PMD_ORDER); if (result != SCAN_SUCCEED) { last_fail = result; goto out_nolock;