From patchwork Wed Oct 18 14:07:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13427127 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 E2E21C41513 for ; Wed, 18 Oct 2023 14:09:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA64B80012; Wed, 18 Oct 2023 10:09:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B54066B01A7; Wed, 18 Oct 2023 10:09:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F5BF80014; Wed, 18 Oct 2023 10:09:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8BA7280012 for ; Wed, 18 Oct 2023 10:09:12 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 524E814027D for ; Wed, 18 Oct 2023 14:09:12 +0000 (UTC) X-FDA: 81358764144.20.1416653 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf05.hostedemail.com (Postfix) with ESMTP id 27309100016 for ; Wed, 18 Oct 2023 14:09:08 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; 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; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697638149; 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=+SExSAFdXGenEFq34IiGWjXXWvTPNv7RgaHg/hl0yTY=; b=iYgx4WQm8DYmgC2ra5lv6pQLbptzXkUaInkW6+95T3bl7Jn5/jQsryt7y4EMbYn2AtIIBE GZbk4WHD2Sa1MmwZHBBKxdtADEl+fIuXuvOzfuL+ZF9J7edWmoHthSQludY+UjuHlbS74l 4bV3uzaSOjTxZYmuIJ65luDfmujRapo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697638149; a=rsa-sha256; cv=none; b=AUXkvSx+sv5QoOEOjCrm23OAMjfYogP1iXNlZYLjalA1PSA1VyKn9/STAH0chsmFe/VDsY UT+qWTO7htuzK6+8a1RQfAq6oUXyTugyDP8TsD5ApoArfqzqkL+TAZ1wG+O9HzvYYFwWdu 0Rg+uapguEYa//OtTer2BxBnoEOIZrs= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; 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; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4S9XhF6Tn5z15NWX; Wed, 18 Oct 2023 22:06:21 +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; Wed, 18 Oct 2023 22:09:04 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Kefeng Wang Subject: [PATCH v3 09/19] mm: mprotect: use a folio in change_pte_range() Date: Wed, 18 Oct 2023 22:07:56 +0800 Message-ID: <20231018140806.2783514-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231018140806.2783514-1-wangkefeng.wang@huawei.com> References: <20231018140806.2783514-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 27309100016 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 6dtrss1okwrqbebkqxb4pu5wggzxagu3 X-HE-Tag: 1697638148-155970 X-HE-Meta: U2FsdGVkX19Xo9s/9k5vBX4ABCrKel6Cb0uODNsl3NaW8Fg2q3HmFzziEI4S7RyxEy5gU2u/XHq4OxWmS85GWZHGOrW+ifTl/UCtThPB9+phUXTwnPUp50f8N9mMMgiGLuGABqbG5p7KF1qIA3a5Ldn5F+WE8rfF/nP2Tl2m6Y0kN44boCRdUTSq2WedsF8UosckaarRU/uNyyUDZ5a6snB3dyLQ4rk8mr5+l2af3KpuX2VbQv/TB3WGT38xvyrQhORW6iqc0O5JqOcwgrNIz1YwFQzW4LJwWHVwjjyCFECj/w723jQiX2VdvrSsyQa6p/FvtHsuaDZXT0pdsLQQSslDvdTY78P27ljH1UOZ2hWfHCqbvJz4KAKEd4BaA9zJScwYvA5uEmIp8pESRZ2KI6G1FBGFhqJ23dV7gFkJWkYkb8M9RydbMuDEz3j9VUg6Z3CnS+Rys8lLo2WH4H6Yfsj9JqVBUUumcSqOKNjtjmCL18asunqFnA7pEJrMryroFM7YqpVp5WJjpjRk+bU07rhnAHXQ3nghzxmyZyEQw/c254sZ9y8rN1b/9fg1lSra5JIoqyPL1d+ZAjtCAPx2wwK3Z8fLsMaLlwVi+TTSiHSU7/zgiXO3Z4T39akUOYj1ZMq7X7yvyl86a3gYAyLrRcDlDZ7SkaU1cwF/s61tSGhIJ+lB1dKAA7Ekd/YsLPXZ41YpBZFgzqKu0xRnMgR4ql4/zBQ0rQWwKNzAzLjPZNet7JZKxS6F1gutvooXTTpHftv+Xdxb+XZS0V17i42rJXOMbKCx0QE9ZQ9Ffmf96jIkBg2w184veYc14q60KfY/BcJ+guZvZjqU0vzFaJO6JhqvBY9b7wgQGdV0BvFzN8Xor2nddBHqzM1Yd8FBvqGWwwK3D2T8Tn3DQDSd5jvX4JyTHrnWKOp1l5wYST3LNzizSaA6JSLkYIXeW3PK1Hh2KfFSSyho1mSDfaUxOyq 5PQMKdI3 4/nn7iOuIqU2a3vbL1jo7RiqeQIKvbCEfhtfj09eI1nMyh0aoUHlsTiBW1P1Qn6/ri299l5vZJgVaY6VoG0ZYoRrx68hqW7+O8o/EAozkweWVNOPH0EAFor+a10uPauJBZwkLjU28WXGGaKjx6j51Sa5m8N7C8GVfN5VG363hS0NsnFzuD72L4Cbf2T0mylITGvJc 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. Since now only normal and PMD-mapped page is handled by numa balancing, it is enough to only update the entire folio's access time. 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)); }