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: 152410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1751667vqb; Fri, 13 Oct 2023 01:59:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnZTCYhU5U2TUQ4pGR1bYYJdRjCUvb97x1FPIKDhZ5U4lVyekZ1my9dOEF8VUdXLI6dYYh X-Received: by 2002:a17:90a:1:b0:27d:1f88:3cd with SMTP id 1-20020a17090a000100b0027d1f8803cdmr4174567pja.4.1697187546937; Fri, 13 Oct 2023 01:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697187546; cv=none; d=google.com; s=arc-20160816; b=ZeiYQf/V9sXo9jhTsduCNohsdhbpIX5ZkiR0e5dlNU+x/yYtAcVVpSAhe6eE+vEX3V +aiI+z0zKuIEnehx8zFg7wAwA4mwLRMOfbzcSgQw6Hl4kt+PGrbF8xZAvEecJxDJGh7X qhaeIzXm6XbsNqnc9UUrF2iiWCZRf8UFD3To7nfnmT5taZbU11jephrqadbPJ1Zs3I4T e6zmXlpahWg6Z1N8vMtdRt9yJAuaVPq36oO5vAGH1FS4RAKj0VisppgndSjY9s7GTzu8 RqCEwLy5UlQY4MJuOg5eQiqtpYs05+zTTW+V/yIjqTxIxpxieIW2Bx2qLVBF54LEdaml KXHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=M5rq17p38CIoi/oLZwLhZN5sMfFvqUf+eMJ9W4f1uNU=; fh=Q+Hibf2y+6rOlBpt37Lm5i0wTMmcQsnxMBqJTtvbZCs=; b=ixC7kqbz1baVtdrDgH+t57iD3QGb2J1Yxu7z+wx3e2c1zdDgqodU76idfBmmcTRZAF vZXFfwff0sxx4Veo0wr10wwUqdlX4T33Gr50YXI4CjZNWLcE674aXlgTYJ+gCtBNW/ob nTy8E8y2w2bvyIKrZjShaXq6zRtP7R7LUYUyaVAVyBHOasS3dhKEetoLAmVCSD3q+90c w99i/l99t/LblJnsBUYe0IjHzIjdYPkDU5k9Cc5e/jY7Y9Aacaf9wq5oD60QMpvV9vWk i5O3/E8TVJyKzp8TmB1+TBFqwHz6ChMyuc+4g0oM6Zo7UKLyN5jepdvBUDCoq2ne5Y2g QeSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id nv10-20020a17090b1b4a00b0026305080a6fsi4571459pjb.63.2023.10.13.01.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:59:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 45A9A82F08FD; Fri, 13 Oct 2023 01:59:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231174AbjJMI6z (ORCPT + 19 others); Fri, 13 Oct 2023 04:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbjJMI6a (ORCPT ); Fri, 13 Oct 2023 04:58:30 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81DB995 for ; Fri, 13 Oct 2023 01:58:28 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 13 Oct 2023 01:59:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779630129306756714 X-GMAIL-MSGID: 1779630129306756714 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)); }