From patchwork Tue Oct 10 06:45:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414848 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 650E3CD68ED for ; Tue, 10 Oct 2023 06:47:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBE8A6B01F3; Tue, 10 Oct 2023 02:47:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CED026B01F5; Tue, 10 Oct 2023 02:47:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB6636B01F6; Tue, 10 Oct 2023 02:47:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AC9196B01F3 for ; Tue, 10 Oct 2023 02:47:13 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6BA9D140199 for ; Tue, 10 Oct 2023 06:47:13 +0000 (UTC) X-FDA: 81328619946.16.8CF7389 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id ED646120013 for ; Tue, 10 Oct 2023 06:47:10 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696920431; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fVfwzDbo5Kc4i4rlTbkYOzLkB4fLvg8axYuIJPcNuUQ=; b=WIO47HvCG47k21RCy+gJW4NHuiQU/9i/Z9rRjXMnAREK1EnKya0+Z8+THSUk92AxWCbAdl i53FGZfIj+TCbhI7nYjHw24WXOIxc+xfmMgARgPt0s3+q5c90xuUTpuRvYAgguy3Zv+uQz TFDI3T14NCMvJdH/k2Jv0bJrzQeCF4o= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696920431; a=rsa-sha256; cv=none; b=gsCnw7R2s/UWZsW7VaiAUorJVw9WprIlmjAtp9TO5a7CySRleArWDiBIIsh54RO4wMv5yB c+D3JkvCZfSABkAR70yQpmrOWL38oANNGQ6Z3eVFAZE+tyhKAdHc+ZPYj0OYtvmLsCFGPE MQAqQnw9lssw3Ah6Hi8MJAurUSMGEkc= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S4RCp2SByztT2f; Tue, 10 Oct 2023 14:42:30 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 10 Oct 2023 14:47:05 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 2/7] mm: mprotect: use a folio in change_pte_range() Date: Tue, 10 Oct 2023 14:45:39 +0800 Message-ID: <20231010064544.4162286-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: ED646120013 X-Stat-Signature: cxiy6enkpzpfx6j7b7ed96z466z84czx X-HE-Tag: 1696920430-122846 X-HE-Meta: U2FsdGVkX1+K+sQ8PV5XVaLjDWyO9ADgUsekxksalw/0qG7WgYTYT4KzNal5UUhs9sBnFjHAvT8xDksnUww1+Qppg//FGxhtJ+ctO5XPMxODFuKTXBcbeEbpKwFW+yD59nInVXQd/mHi7598dvfuSxJ3DHP4rOUjNBQ1nDQJJ+CSGQqMuvOOUnp577+xB+kwHuV7XksDydPdpYKQYdjfBFqQt0bQ+N1RmzQnsxxFSyNnGjcbteqbJGPhpgWj3wcceUPLCaIyf3Jw6gjjSW7bFuB5+vbHoQAc71IxdpLRno9xI0O738IpSy135EuCRURXE0YA8gl/FFK3lrAIn1EG3X5ewvXDkcFFjyE+bF+5oRWB4zV0L3PTqlzaZPUWHwEkxECNEHT5jvJUXIE0tRfCBkt3U4K2oYbMJjo5UdGq3IyVQvBAQ/Kl0E2klz3QfzAAD2NXyT3k0G3JYPSZuEaYtBP9ivdGoQSRc1OE2b1rub1CJFL/kh0ZqxD5wI4YldBGjKq5xtUendO94Oo0WOAZhxao2CO8+ksi4hMje+1R/Hi/RMOcgR4Nm4t42tMrGLka7eLx21VycdhDYVpl4n1XFmH/6IlvdG9sebiomThqHv1lyNuzvurSryKl0pZGLcR3/ciz97Y4JGl+corfKLB0sUE8768xigM6wY16xjxtc+a11dX/mwFyUCNOkOvSd9C8cWuvdk5wtbgFi9Kk3NsLr4vPuMbxy6qBhQy/vEIRJNOIvIHFJqPuICfqPP4bd8Exy1aidqfKL59YW8N/X0UUwb612wDkWZh67XWxHraoMYz1SxkQGUmtdQ+hXi5lSkF3numX7o6jG7xyXpfYGa8Id2sc9o3Ej8u+qB0EmGpgnz5bQGxHO58rl5YCdaCyCfJNPugUSp+gqA0Yg1tCE5lesdu4mo4dtxvJk9s8UWfx5edtYfwVSqtAMWLODcPi5I/aAjDRKr4/yOzfaiWLV5G zCcJO5f9 ypLIXgoWoOLRItGOo4qIY2to84ijfraw7XW4ARBaMrJaCsWjBeX9xkmGz9W7xUjk72Py7NDvKx3A1WiR1X0G9kN/pGzqMetNVMTN8R/pojE/dc5Jq2klhAec9Q5t+LLOKD/KWcFJD7c6/SxMW1Gg1xp95IeQfYoLuTZ4YMknF1i7Jl1BhrkRIgpBypF2pygRT+jVmR4DH+a+sfWTnShpZLWo1o8JGnvDPeE39b/3k1Q3F2AZ+gIitrToE+0Nuhady/xphA2D4XblduoFpd3Kzc+C5StUz5Vt8e61O 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: Use a folio in change_pte_range() to save three compound_head() calls. Signed-off-by: Kefeng Wang --- mm/mprotect.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mm/mprotect.c b/mm/mprotect.c index b94fbb45d5c7..459daa987131 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -114,7 +114,7 @@ static long change_pte_range(struct mmu_gather *tlb, * pages. See similar comment in change_huge_pmd. */ if (prot_numa) { - struct page *page; + struct folio *folio; int nid; bool toptier; @@ -122,13 +122,14 @@ static long change_pte_range(struct mmu_gather *tlb, if (pte_protnone(oldpte)) continue; - page = vm_normal_page(vma, addr, oldpte); - if (!page || is_zone_device_page(page) || PageKsm(page)) + folio = vm_normal_folio(vma, addr, oldpte); + if (!folio || folio_is_zone_device(folio) || + folio_test_ksm(folio)) continue; /* Also skip shared copy-on-write pages */ if (is_cow_mapping(vma->vm_flags) && - page_count(page) != 1) + folio_ref_count(folio) != 1) continue; /* @@ -136,14 +137,15 @@ static long change_pte_range(struct mmu_gather *tlb, * it cannot move them all from MIGRATE_ASYNC * context. */ - if (page_is_file_lru(page) && PageDirty(page)) + if (folio_is_file_lru(folio) && + folio_test_dirty(folio)) continue; /* * Don't mess with PTEs if page is already on the node * a single-threaded process is running on. */ - nid = page_to_nid(page); + nid = folio_nid(folio); if (target_node == nid) continue; toptier = node_is_toptier(nid); @@ -157,7 +159,7 @@ static long change_pte_range(struct mmu_gather *tlb, continue; if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING && !toptier) - xchg_page_access_time(page, + xchg_page_access_time(&folio->page, jiffies_to_msecs(jiffies)); }