From patchwork Mon Dec 16 16:50:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dev Jain X-Patchwork-Id: 13910078 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 2C4BBE77180 for ; Mon, 16 Dec 2024 16:52:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8C356B00C1; Mon, 16 Dec 2024 11:52:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3BA56B00C2; Mon, 16 Dec 2024 11:52:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DC2B6B00C3; Mon, 16 Dec 2024 11:52:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6DEF86B00C1 for ; Mon, 16 Dec 2024 11:52:22 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1BC791209D4 for ; Mon, 16 Dec 2024 16:52:22 +0000 (UTC) X-FDA: 82901415030.29.431BB69 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 1A4A64001B for ; Mon, 16 Dec 2024 16:51:57 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734367921; 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=FLj2WcjZj7RXOkPAUGtCV/UiktiK1JzYIk2pp7vpSMQ=; b=phXFXvXLysmeyHadW13EuvIq/6ZDu43oCb9Fxy/IVtio6VeCCCJ1dygLXGSKtvCQhA3PAd 6bfhvVds7It6epFTYBuZW9OkaOw5xBnBREWy5kVf4dELZwWckvSSiIPapXoYNTU8wQ0Jfg +Fx1Zjlf77YJuTQQzxKSSmAmpULlwQQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734367921; a=rsa-sha256; cv=none; b=eRKsMb8K4qwED22vuKbQtNXKTCANhTBGckviO+HqJNZ4nudQMoC1bQ1nN2Spm3r4jMZTee uXMKuuoLq97jxHHOAyhklo1IjlJztp7srSw0apenVNIRktY7eJx8P1YP2+fmxpUU8It4G8 DSpL0YtxqL2eT/3Is8A+ZBnlnlliIp4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 81C5F16F3; Mon, 16 Dec 2024 08:52:47 -0800 (PST) Received: from K4MQJ0H1H2.arm.com (unknown [10.163.78.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C5BF03F528; Mon, 16 Dec 2024 08:52:08 -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 04/12] khugepaged: Generalize __collapse_huge_page_swapin() Date: Mon, 16 Dec 2024 22:20:57 +0530 Message-Id: <20241216165105.56185-5-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-Server: rspam02 X-Rspamd-Queue-Id: 1A4A64001B X-Stat-Signature: 5ksys34ytzesne8winuc9m577ubzcyqp X-Rspam-User: X-HE-Tag: 1734367917-847994 X-HE-Meta: U2FsdGVkX19+pRpmlc39Adam8bzbcqDA8C/E/BwP6eoeJBiWhhC/DKUSKtd0VEPz3kyG+TMm3dmSPj6RR+g+DY9YWf1vmT/kCJvEZ5YODbW0oKJyaPqKmCeDEq8P2XipRQMn+t1TdHLKhU1yYqn1gBvyNkw/V38N84ibnm++gluTW5nXxqyPFYh8wvU10NuP+aPj/m6BhRvlR9xr6lnWFMzHWeSEGQdaZsQdLcEMKlGtnYOaa8tYfEGO7iI9VvVlregpwU2fjBIQ9t1k3o4CuT1CPGqUgR1R9E44RmVwi81oVZVR59Swenc+TpKdI7QNdAGu41gZlRDHWhP+buvyYY7df8wEPJWzgLgkZo6dX5c+Lwgra8w358a+CcASn8oPTtYXYHtve/cwkVGkrHmups5ItkMGauFsjWmKG1DP4Vr+y8RhT5RAvSFV4bzd0hnrAsvSNK/2QQNmylAeEn1qyzDQ82Bntce9RO+odGrnx8VDC7siO/GU2oGE1bIjccsbF26QxmcTLqDwFzMn1FnQNjX+0D8++JnWWQNHrsGLa+yklSlDb/FOZuelxSDZ1hDdQvHbylktKKWSoGYHb072BJHpj6pGbi5NCBP/mviE8HD7fVELnmZgrnLl3l5ZYwzV7/D1e80X0khutbgaBxwswi968OrzZ86Qv8aP6cLUTJ/TpFCUgeUOofEA5SwUDySOkvL9bH7IRq9adYCqIs5lZ+HO954pioe3c02xygrTuu+dwhSs5/jP3q4b3NGcPGWbyx7MvQQ1KHjFuLrrFtl+XFp9imPuVJlZFSQq6IBsYxqIispdA/LriYEkVJy9gM5u5jy5GszVq2ixoKS4TQ0wtTga+8RIVcn+7rCwM9BA6/gOBYGpWxS6l5cseyGW1wUpMy6rX2CXMfCkmm0fz3ieVR1JxrhEJVqDUYSDWGjKcQleaEZ/hemcopHdP2ox/ITmzGyQhE2LrLTzKqNJdVV jfxeVG/f 7TP+vfOMaXINLqC9lGKnkJTIfPajqGPtJ013QdC1VdWfoC7EMwdDA6eKcHG5YPDZGzdbrBjlK65P8eUkO4hipk/V9H3gHVXssqTUxFqjRDnsG600STyT78aadw9bKx/RMZL7GKagOPkIA1pNhxN3c7dFsmzoTRngTEIpAuhyMh/+msGoNmXJXn9Ghuqcl0JvNqkhIVrbAZv6/aW0qP4z8DViq7EyxGn7+puQRpGIpEaogiTWrnKIuAA8nCs38BRgXedJwdTHb9IF6nQKqNUD3Rvuf5Ypr8eLCaZ9Ur685mikqYKE4eKzgKGCASSKKHjkkRbiA194pRtiF5nKGu5DiVkYyjhnAsgbr79uGoJzvc4MDCEdRjJnsi/83s0UWib7+InHDTQFYWgP3FeQ= 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: If any PTE in our scan range is a swap entry, then use do_swap_page() to swap-in the corresponding folio. Signed-off-by: Dev Jain --- mm/khugepaged.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 2f0601795471..f52dae7d5179 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -998,17 +998,17 @@ static int check_pmd_still_valid(struct mm_struct *mm, */ static int __collapse_huge_page_swapin(struct mm_struct *mm, struct vm_area_struct *vma, - unsigned long haddr, pmd_t *pmd, - int referenced) + unsigned long addr, pmd_t *pmd, + int referenced, int order) { int swapped_in = 0; vm_fault_t ret = 0; - unsigned long address, end = haddr + (HPAGE_PMD_NR * PAGE_SIZE); + unsigned long address, end = addr + ((1UL << order) * PAGE_SIZE); int result; pte_t *pte = NULL; spinlock_t *ptl; - for (address = haddr; address < end; address += PAGE_SIZE) { + for (address = addr; address < end; address += PAGE_SIZE) { struct vm_fault vmf = { .vma = vma, .address = address, @@ -1153,7 +1153,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, * that case. Continuing to collapse causes inconsistency. */ result = __collapse_huge_page_swapin(mm, vma, address, pmd, - referenced); + referenced, order); if (result != SCAN_SUCCEED) goto out_nolock; }