From patchwork Mon Dec 16 16:50:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dev Jain X-Patchwork-Id: 13910077 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 7736CE7717F for ; Mon, 16 Dec 2024 16:52:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 115496B00BF; Mon, 16 Dec 2024 11:52:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09EAF6B00C0; Mon, 16 Dec 2024 11:52:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5A036B00C1; Mon, 16 Dec 2024 11:52:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C746B6B00BF for ; Mon, 16 Dec 2024 11:52:10 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 900571A0E2F for ; Mon, 16 Dec 2024 16:52:10 +0000 (UTC) X-FDA: 82901413434.01.D150DAC Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf29.hostedemail.com (Postfix) with ESMTP id AA788120003 for ; Mon, 16 Dec 2024 16:51:27 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734367915; 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; bh=fK2KeTT9twhZXnPuM8UHgnUOyCXICzvhJCew7lsKW+E=; b=pXzTBjNHo0We8MpkM9JzmyGFN6OA2cuFE9NNfwYCrCFqLsLH4GXlWgigLNCeexdPVfMBfv 9xHxCicRp4KlObjN9rekMUSgdqP8rGaSm9qb1tO2DEX26T/I+TKvKiYulCH/aUvZ6vsEx0 oXxx99YEnJI6fCumePWAPiQODG92e+E= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734367915; a=rsa-sha256; cv=none; b=A9ltOOzqMS+JZx2S0SC7X3m+8RSqs2hZkVBCelJi+OjvwFxqDa1NGwUdISgIn1inSPnOu6 EME/hcDBebBr94NqurVw7VJywbeYaTD7Y40C/1RObRjmSrQmRcW87xtyexUSEPzxw0Usan v/L5Fq7YaHUciwTV9grGQgCVt5qGsAU= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4136B16F2; Mon, 16 Dec 2024 08:52:36 -0800 (PST) Received: from K4MQJ0H1H2.arm.com (unknown [10.163.78.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 527BB3F528; Mon, 16 Dec 2024 08:51:57 -0800 (PST) From: Dev Jain To: akpm@linux-foundation.org, david@redhat.com, willy@infradead.org, kirill.shutemov@linux.intel.com 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, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dev Jain Subject: [RFC PATCH 03/12] khugepaged: Generalize hugepage_vma_revalidate() Date: Mon, 16 Dec 2024 22:20:56 +0530 Message-Id: <20241216165105.56185-4-dev.jain@arm.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241216165105.56185-1-dev.jain@arm.com> References: <20241216165105.56185-1-dev.jain@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: AA788120003 X-Stat-Signature: x6w6mm7hm8nfsa57yqx9ntzwud4bheaz X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734367887-724545 X-HE-Meta: U2FsdGVkX196h4dyUQYyCrIeAxbGdB5QRfEZMkLCUaSc38USal6eCb7Xou4Qne4RmfIMif7DRhxpPEIgfEKAzCBoWUnZCBrS10SMVrTke4fkxFcSi9DhdEe6Qj3tsiL3Fv2+QkG+ZZdnolWkGAYxujv1HjqcBcNfxXphYu4I4XdVe2LtL0jAkz09bRLljqUqgC6L5erQKsTjCHuIuiL8MLZykFefoYYJu/LiHJ89DW9n/g4+BCT8uDjv1JCTZotw0Uy4AtIGjDLaLoFMYKfMAzMm1cTyackvnH6+MLnJ+4RtzfeiLB95L9MkPkSTDWjdNmrANqNotG8mcy13Ywg4Bh7coHoHGT+/3F8B1vntd8oFZglPcB+tgPk8S1SmvypJLkgA6XXH1QFKKK3FQ10W6TMl952iTdW9k5oG17Bqf/goHphfiMbekLwQc6j+sVIyzq+hkQTT070xuRE/5B5ZLjHchPGoViJKmS+i+RVEg32nUEzlpUgR7Fh7n8HEmu8FFPvcXl2C7OuzF2/dhjHY8IgsIAjvdRH1/pi9HDToUWHIjUwTRuN+sFdRQcH5ssFkTPQ82MsaRLPYweTygLDqF2RUOhXWoqPvFTYQh1TbCi4BhhWZr+2mRpHx8aGeAxF/S2aFbv9/VWNWSR2sTjZ/iY1kWw22xjCdU/9qmQfWxJUJCcTJ97/fMSNFps4iN2CvNB9aOOWSmHIZs4EoWq1zh8qMn1afojqTUdTqEEhXOvn885pU2+okh5xqIo0aBIcdtumtga0W0CNoZA+t7+7YQO3VZS/3wZhrGsHOVxKGng1B4s10UPrCB2SAJNtCrhJ7Pfn9xoXgEtOo1uWCeCQ3UE4y37qL+vXlWRwlfEIWDQQCcY3uZC5f//2B0SMxQkbSmjPJ9w+3jZ0So9DEutkyLQMsD/thJLOuuMi2SPwyAEariePDNbcbE2DWangntH0fWKFkXVpo1FU8KBdtY8v N7cNgXWX 2Scpy3Z8/fsjy931ccfDF/0mHGeANCEbrZIELWzwtA2IN0MNXBzqfLytPGXEzX2x9uDuhkHsWIG2Gaj/aX/fV5N3jJSYjroNzZHE7JuDw+oDLjgsMo8Wk91rf90yPZrbeciQHE6WtQAOQQQTxsijyQDTAiwH066zOBOgxZ5Ql46LMOz4XmmCSFrp1RDVs3gU3p5Dsg/wxh5xLRSZQBz7oe+GTne4LHjr0msP71JfpCV3PpG4t6ccaSDDvYeI6Q3cg/iHtR3oOZdH9O7HDqSl36M/itSOUb7AYAFEbFQMlDBPUYfRW/+S8SOHVG3P/KAtuiQDM+DfJFEqQmJtsQY8Gj/A3eVW9sA5/zBp3xeZFeJlDVvevgOFR6WA7ycestcNRNy6yhK6OrzzSGz0= 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: Post retaking the lock, it must be checked that the VMA is suitable for our scan order. Hence, generalize hugepage_vma_revalidate(). Signed-off-by: Dev Jain --- mm/khugepaged.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 02cd424b8e48..2f0601795471 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -918,7 +918,7 @@ static int hpage_collapse_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 vm_area_struct **vmap, int order, struct collapse_control *cc) { struct vm_area_struct *vma; @@ -931,9 +931,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 @@ -1134,7 +1134,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, order, cc); if (result != SCAN_SUCCEED) { mmap_read_unlock(mm); goto out_nolock; @@ -1168,7 +1168,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, order, cc); if (result != SCAN_SUCCEED) goto out_up_write; /* check if the pmd is still valid */ @@ -2776,7 +2776,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); + HPAGE_PMD_ORDER, cc); if (result != SCAN_SUCCEED) { last_fail = result; goto out_nolock;