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: 150497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1568vqb; Mon, 9 Oct 2023 23:47:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXTm6JjDoydU87wJ9LuCZdq1O8eEHtAwILmtOtW+l0CYNb+e8SU7eTbirTizLn543iYkjC X-Received: by 2002:a05:6a00:17a1:b0:691:fd26:f54a with SMTP id s33-20020a056a0017a100b00691fd26f54amr20932296pfg.20.1696920454580; Mon, 09 Oct 2023 23:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696920454; cv=none; d=google.com; s=arc-20160816; b=iGbS6pNe6lj5P3unEpJU769FxcNFRU5FF8hqT5gmokjtbAlvIDQtwewMSLnwQmE9hj J3HVwtS1W8OoAop2mpWpQOCZF5mzO8Zl9vfrA77uRFXmgWP8+VQ6dlJtnB2hLKzOBdpH Ho/nX0HGgj+vuvdBm677ynjAWD41Hjrdxu50MxscvWQ/mfJUEDADFnmo8fU5VilJw3X3 g/4zownGN45qikV0HJegklDDB4MEzrFotyMRKLnxmS/qUDhP1LkBhy+i1ivixQbiudi0 UdwTfSZlTixdrt/ueOv9RF8wTkQ0uTCknfQ9CgAgzo8K0T/WeafkUEPiSMTyQAMcIwhL EzmA== 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=fVfwzDbo5Kc4i4rlTbkYOzLkB4fLvg8axYuIJPcNuUQ=; fh=wFvkM9osNU8sYLmqaGTuFInFBWzcJKoGp+WLNOXGmbE=; b=p2E25p9Tjw340wTr0sUkGpNLQAMfWBigZlFUq+Ue6LoQWcfxMyQhurx4uUBd2xvmJK AsrUndaASf49eKdxLmHr4vJP8gsVfu9xv0+6vUaH18IVRaa6aZETf2KHlc3tzKQSFNCK PGyEPH9gBxsSUXf8VYatJDMw62cJ+XikXGhrAVLtt2z3VHW+zJOlg2t5yW4OXuUIFVL5 Fb/LaCaJPeOvhcRtUrsgKTdz5i1lnLSqDYdCy5Eg7BxnnXzuZAYWFnPiYlZNDv7rq/S9 Td7xKd3qHZiYgVi8t0GuprrloqPy1/qKF7qK+ucH2eucMTflL/EIA4YW3gFu6K7goopd pOPQ== 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:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id q9-20020a056a00084900b0069347c30c86si9293592pfk.253.2023.10.09.23.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 23:47:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id CDB21802542B; Mon, 9 Oct 2023 23:47:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442324AbjJJGrQ (ORCPT + 20 others); Tue, 10 Oct 2023 02:47:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442275AbjJJGrK (ORCPT ); Tue, 10 Oct 2023 02:47:10 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3436A9E for ; Mon, 9 Oct 2023 23:47:08 -0700 (PDT) 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-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 23:47:29 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779350062164328200 X-GMAIL-MSGID: 1779350062164328200 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)); }