Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp896312rdf; Fri, 3 Nov 2023 20:56:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIpuPA+zZPajk6xc9a4No82xIcXaiQERZ9pcy5C+L1Fsyd/Z+aEH+tfloSTgDmCSKPozbL X-Received: by 2002:a17:903:7c6:b0:1cc:630d:8a5e with SMTP id ko6-20020a17090307c600b001cc630d8a5emr12312199plb.48.1699070178283; Fri, 03 Nov 2023 20:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699070178; cv=none; d=google.com; s=arc-20160816; b=czJUC8Vr03FZbGV4xW5sS2yNFIq4Ao3kKQOaXyUaTxMA2+SdBSa/XREJEVtidHqMmg Lr2V7xKCM5+ayXTDk8WHhjnnEyTnIgU0u10+9k2z7NgrBz1bC4bmoPfxwVzO05I0roEn UE4b9/kcjvD0tXVwg6gMdA3S/CIbls1IMsCRMe0V2h3zsHZAMziXXTTbkYHIVV1L7fUE dJ8vaDC5SegE13UxFLAWoQa6RaWbps94/ULo4YUKJcZdokeIX7kQfFkEVU6KNak+lC+7 +3qcK6cmq2k57ol4pcTVIX32yUN6FomvG24mYHcw3CXysv3yw/72o4T99OfiiNqhLKws uqyQ== 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=MPGmfuGIWa6O6otMqJXbXH0YFlYM5vFEP+zlcU8Yh7w=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=U2CL/4C3jqBmjZ446Ww7moEbRmnr3ka6S7l+h8UTBms4VKWlimt3/9kxdlQauEUAFe uQvma7DlrCi8f/AGpV9yhmFTVo6PiiGTVKCcFoqR1hLQVX1gZsMosBKat93pUnut6Q2c H/dHAFE+W6HZ4lLzzgnQDPJfJclV0OlsBZl8iwpVTEhKYc+NHunbAerW6wCa9bpfBsxK 3t8r/dAPtT0aexTsZNk+9gUerxWAHLqAEffyyU0lcDLyTffXeRLlSB+VoF9zBQDb9nSi Yx5flLSLdAHScps/Of8u+nrakJsTja44DbeUZdYYrV5KUfZVs/uPWxfc9o1ykfv/gNPQ O9ZQ== 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 Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id k20-20020a170902ba9400b001bb8c4279f5si2816820pls.148.2023.11.03.20.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 20:56:18 -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 6A7FA8293C72; Fri, 3 Nov 2023 20:56:15 -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 S232749AbjKDD4E (ORCPT + 99 others); Fri, 3 Nov 2023 23:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234308AbjKDDzs (ORCPT ); Fri, 3 Nov 2023 23:55:48 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B3CD1A8; Fri, 3 Nov 2023 20:55:44 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMkGD3sw9zrTX9; Sat, 4 Nov 2023 11:52:36 +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; Sat, 4 Nov 2023 11:55:41 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH v2 03/10] mm: huge_memory: use a folio in __split_huge_pmd_locked() Date: Sat, 4 Nov 2023 11:55:15 +0800 Message-ID: <20231104035522.2418660-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> References: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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]); Fri, 03 Nov 2023 20:56:15 -0700 (PDT) Use a folio in __split_huge_pmd_locked() which replaces five compound_head() call with two page_folio() calls. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f31f02472396..34dd01970927 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2117,6 +2117,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, count_vm_event(THP_SPLIT_PMD); if (!vma_is_anonymous(vma)) { + struct folio *folio; old_pmd = pmdp_huge_clear_flush(vma, haddr, pmd); /* * We are going to unmap this huge page. So @@ -2130,17 +2131,17 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, swp_entry_t entry; entry = pmd_to_swp_entry(old_pmd); - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); } else { - page = pmd_page(old_pmd); - if (!PageDirty(page) && pmd_dirty(old_pmd)) - set_page_dirty(page); - if (!PageReferenced(page) && pmd_young(old_pmd)) - SetPageReferenced(page); - page_remove_rmap(page, vma, true); - put_page(page); + folio = page_folio(pmd_page(old_pmd)); + if (!folio_test_dirty(folio) && pmd_dirty(old_pmd)) + folio_set_dirty(folio); + if (!folio_test_referenced(folio) && pmd_young(old_pmd)) + folio_set_referenced(folio); + page_remove_rmap(&folio->page, vma, true); + folio_put(folio); } - add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(mm, mm_counter_file(&folio->page), -HPAGE_PMD_NR); return; } -- 2.27.0