From patchwork Tue Sep 26 00:52:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13398586 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 95010E81806 for ; Tue, 26 Sep 2023 00:53:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6A818D005C; Mon, 25 Sep 2023 20:53:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF3558D0005; Mon, 25 Sep 2023 20:53:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBA958D005C; Mon, 25 Sep 2023 20:53:17 -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 A8BFB8D0005 for ; Mon, 25 Sep 2023 20:53:17 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7CE6480D39 for ; Tue, 26 Sep 2023 00:53:17 +0000 (UTC) X-FDA: 81276924834.17.5AD7DDF Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf03.hostedemail.com (Postfix) with ESMTP id 762A920013 for ; Tue, 26 Sep 2023 00:53:13 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.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=1695689595; 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=CBn4tkjPz1LGc3aXGdMoZ9rxjPmGrtaY+7oDcghpVHwQrO2ryVn87lSeXYmRVrsPTithv0 zgIvA1S824hJun9JeGUtaV0jcfTag0ZMxVgNGrWtn0qP8ZrEmB7oWDx1XAwiw7Oq4cpUWL MiWeM8wewX6wS9rsWRNIquIAxeNloXQ= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.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=1695689595; a=rsa-sha256; cv=none; b=arU7lbmt7oxSWaqjw5ujEIjEyIfv9hWlmCnUDN02S56hokas8u5fV3BDDXBwSrSHL1KWIv TKA799CRaXyRopj0xY7dVt1xJO9CBHLJNhtEFw72GW1zdRoeAts7bGb4Gs7/N873bV0N+f xaX1EbrFPXU48huX3huyQv8QNVffLr0= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Rvh286hNcztT42; Tue, 26 Sep 2023 08:48:48 +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, 26 Sep 2023 08:53:08 +0800 From: Kefeng Wang To: Andrew Morton CC: Mike Rapoport , Matthew Wilcox , David Hildenbrand , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 2/9] mm: mprotect: use a folio in change_pte_range() Date: Tue, 26 Sep 2023 08:52:47 +0800 Message-ID: <20230926005254.2861577-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230926005254.2861577-1-wangkefeng.wang@huawei.com> References: <20230926005254.2861577-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 762A920013 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: tps5jhgxb35zyqhkxwmnnr7rdbjwby5c X-HE-Tag: 1695689593-247053 X-HE-Meta: U2FsdGVkX19PYxWKvjIWnWd+wPFAQWb6OBL0FDukiCJblS0FAHB2QQM3WfOB4lzNui+eFUobIt52PoGbL7WHQua9RScbE01A1hCw659dn/CF8+lrcHDPyqTse+8RkUx2+b0r89t3DfTS9c3EGVGxU1AlwCcb9fdZ7sHvNdrPJwnLdsR9HMPynbOew9IadF2ubrOSIFJ6jdAZFwBeMYxy3Mx8eWFvCDAdd7as2XUZ2Bt3cINISupZQE2MmkHOQH2cfndv5zgTu2Mv0WbN+jqCQ2mqW8VpZ+7WWe9YW0f02bTx77cPyjQ6fcClLOxI92tHJgr4Zdxc2PNHVp6p2uNtstlCf2oYsYpGBy98rI9qWTP1mv6ezRCtgiXN/iEcLlphIFjEd0Co7Anuhxzuej/qjl3bUZcp4rlWPZUxn/TNQ37j9ob+Egz2QXJnSe6p1X2C9jd/rUZvRDvm002wgKpanR5I1YTM9f8cm3P0HvxmT41JJft4jiZhCpzSNbY49ZkhrAlToZ9Gi4IDrCyLprkHrSrwfVmQeI6/+a73I+0y1h1qxGSyW+naNT7CwlIfPPkXnc23K97YrAKlqcZuZ8SbkzYu7LrWRIaip2d/VWNHjevf0fdFVnt9swWXb9HSogYWiys0aKgi04YE4qe4QNftcjjalLcXO1tTaDSSnbjOW+sbyYrKV9NuaNmmevBQ2exA9Zp8o0dVbvCwz8j6trZ9YYo0i0+MgEkVwAv8SDqHdpK5ZF5+91JQ4hXRmtNwBr7heQnBnD7gNYGpncJ94PcLcgv45uyoTfbsQkzMzRdrAgSLNxTukOuQOH9nQQe8zlaPPVZDU4Q8fyQAse1050NtGk+LDikX3z8Uv9ke7Qf0Z1VCdVYofHsaNvh2qSfUmBb7ozH6wsZC1j/wlkZ9uJFOxqAkIO95s49d0N6NwmCShGGh9tlVfdzwhevPmRf9nzwXiTsyPmEkhsJ06o6X+iP ZgudCu1c wP5kY1tVRozB6A8Wl5P8oC5hpqTqT2sOnh5Gj0AT6xxLm6X3OHxcwXH3nw6ERIv8J2aBqmVKjThkaUXC/almtkym9kQUfJEXP4yhNp2WwgZsHyVM8Cgfv4mnB5s28Kxleypha7cX1oR6V3SioUxZbMOffRAsTzBpruhf+0YIxh7f0N7ef+LZ66mKQjZnDIBqswfq1 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)); }