From patchwork Fri Oct 13 08:55:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13420523 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 9A4AACDB47E for ; Fri, 13 Oct 2023 08:58:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93F0A8E0011; Fri, 13 Oct 2023 04:58:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 876818E0010; Fri, 13 Oct 2023 04:58:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 715AF8E0014; Fri, 13 Oct 2023 04:58:32 -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 508688E0010 for ; Fri, 13 Oct 2023 04:58:32 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2E5EE1CA76E for ; Fri, 13 Oct 2023 08:58:32 +0000 (UTC) X-FDA: 81339837264.24.D9E6084 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf05.hostedemail.com (Postfix) with ESMTP id E3A7A100002 for ; Fri, 13 Oct 2023 08:58:29 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1697187510; 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=M5rq17p38CIoi/oLZwLhZN5sMfFvqUf+eMJ9W4f1uNU=; b=a71d9rvpLHH2NHhW+O0OybZmIZOxy1LDY7M2/pfudD9cW7iRGvJi7AIa0E6lKtZtFlF1aX TWyaXC9TqT5i3IuXKs+mv1jobCzts1uipO6zP9XdQQ81Z9oeWwwuA7if8jNRRvRt51DQMh RsbvIJgKd2jrhQGJOo2tAJQ2OslqEns= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697187510; a=rsa-sha256; cv=none; b=LZev9RBU631fpqh+VOsIY5CuGaHVAqL61DpGLE+SfsArQy0mx1E23A3hRXeIpT/9A1cU1K EMyip9y/iauRSPKtRX4PiYXYplRlkm89qxkU4QEdVzxHkZWY+jDZfcuaB44NEwu6lWdJij M9t7OE9z6qdSwhldG6Ui/wkV8MA1yXA= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4S6L2G3p2Lz15NSb; Fri, 13 Oct 2023 16:55:50 +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; Fri, 13 Oct 2023 16:58:26 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Kefeng Wang Subject: [PATCH -next v2 09/19] mm: mprotect: use a folio in change_pte_range() Date: Fri, 13 Oct 2023 16:55:53 +0800 Message-ID: <20231013085603.1227349-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231013085603.1227349-1-wangkefeng.wang@huawei.com> References: <20231013085603.1227349-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: E3A7A100002 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5dkjjrszrpenhw8d6fk9ao9kox38cb4g X-HE-Tag: 1697187509-832848 X-HE-Meta: U2FsdGVkX19+we3oKUwwhVdvz+8oYWUYfqrb2o/M6gWleelSw58Da/ns1LA3HItEhTv/8UJM2TaEnbUDx8ESzwlZafhvJFLmSg4YTaKEy2OoA0o2tx2KjW5F6G5iV5K9mG+4mzVS29BqdLRm08PpTnPCTW/EYQICaX/KRuSKrD8U1iVYyVRyvLdnHV6uQwzs0DSWe/RYDG5I5ITR3qS/pc/DHDinNC8urCx/s1wJuRNW8EXlUuhSkmZ820DtZyVxJeNJ7O5v/LVDvBQE0sXPmj4AUqoSa3iSHUG6194jca29cEWBxBa7to1Kx37RXdiZjzLHTIB2FbaR+TjdNitWyrhBW1/g1FzvvF3vgJpDl8cNlNEqX2cpoQPsDJlpoEPuZ9mZKjPRdbql0YL8o3/4R8o3M5HCLPDC2JTZEpNdW2Bs/b0RCbhSUJc3jv2ODI7Ddon0soVlsT9PRqA6SwEnuaBb79CrRrh35tKuayW/ROujiFHcTnk9RYq81IyKoeE3uPYwioYM/doFRxhylYpOKF+D/jAbRzMKB8ufowsme/bfE7F8LPhQWulaC4H5dXTd9ZjKMmvJgaWW2v3K0b9zkk/jagtNsVEIMV/UUG9im0fM1RxtUVJbBzuRlYgVcOPt51uaQ7PmVIlthrkLRIwdw652dtqEpn6TmhxoXEFqIn6ASg8ZxW6lROhk7iGHugThDytjz9y0mUhS16komxS1mSONtTqZY7Ad6OqcjjKSXpZGGGt4x1isQ7pDRYLfpet0JymF4GB4VeZjhxsJSqhU7eM5zKGT2cmARe2plUT6F3zmxR6w6PeDiAv5kowMZfnxQXQAKD1tneCwCD0YbHiKJwA3ZQFd9gLJzovJJVGjgLWAY///2MHeQUdm9dogiE4o8x4X1ztjfi12cwm/06bbeyIJscWOnnsYM+M6phxaOAcMkPhG5cKtNkkSsQx4FsKI6qubweOt3eT2DkbQSDe kB945qkD gzKJJhSoMNU6r6TueAIX7B42c6YNIQgimyKrzn8X/sFG3c3zHFClZB5nhhgyAnpG55Y4o9gVCpZpUM8rIf0U+qS3dZJOp7XSNNVsXQfWEbVvww1mFP6C4ZHLasn/sE0OXoQdpxvGqKdtClnsOD4+mlaEbIKbW2ulMVhIo8/j3OcUkoJJB76k3hUn9dUNaExMM8K6C 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 f1dc8f8c84ef..81991102f785 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, + folio_xchg_access_time(folio, jiffies_to_msecs(jiffies)); }