Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp532714rdf; Fri, 3 Nov 2023 07:46:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJHZ6E9JMxLsIj1Wg/MCoahmtNVk/z3a2Ww0KPq/3MYNiHmE73zR3T9R9fEjmtNyUImQXa X-Received: by 2002:a17:902:db10:b0:1cc:5833:cf5e with SMTP id m16-20020a170902db1000b001cc5833cf5emr14492359plx.27.1699022791656; Fri, 03 Nov 2023 07:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022791; cv=none; d=google.com; s=arc-20160816; b=Qy3SCiliMMppHJi/JfulC88+uKWot2C23LBQFuIyIoB9MGIbKjP54aDFFnWmr44K9h F3l7L/VObsXW7w0xB4yMraA+b3XeTtupXsJEr0yBtg+IX3TJ/czIkVZ7dpRUUtgulaF+ jq8uAtPzD8BynAZRGpwHQRLMSlkRBg3n7bbc0XaQHmRY+jNLkDk8wTCgXwDpd3km8VL5 2qc8G+Nuftlu+2enkxKMT8hNovNECVMDC5n7VySCUcLjLC8IcjkiPOi1HTeFh9rg0rti i9GG09zm+9rV8BTj0XICS7Wo5bAw7Y4deByIsTzWC9BTlyCzXPl/lyhRvr9dIKhnbiAA +J1A== 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=NB5R7sYpytkiUmaxuKrNkniyxkHRPvjeB+cXDTFDb28=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=CvPBElToS7ZiYB0+C9xCxqCvU8u2tVY+WDoPuIhgIw3nyAJE1KHR2DDy+Ats1W98W3 vhnqoYBqxS5doRCFfOINn3FH1HQZ1mamNdJGbGcdY8ekyBX4eEfPnzdWeNX3+BAPfc6x VgoK1T90XYzFpxQ1+YjhYgE42nCBhn90HUSadbknLqIfxnZJb28/kL7eTCquxNZ+ZfnR m9axVW0Y1RvhloBwdt0kK7j8YBXavXzfXyh9xuwlzz1Msxs+JSLUo2qOLQ+lLfHrDZ6h 2G8XGq3JIumxpjBOFlEhjcDsEMcSa2uikN+GB1dem7PvxGWxnFN5d9UOE5d532JcqQYx vcnA== 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:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t13-20020a17090aba8d00b002791baa4729si1651802pjr.57.2023.11.03.07.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:46:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 5EDFF8385EF4; Fri, 3 Nov 2023 07:46:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbjKCOp4 (ORCPT + 99 others); Fri, 3 Nov 2023 10:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377817AbjKCODz (ORCPT ); Fri, 3 Nov 2023 10:03:55 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45AF9D61; Fri, 3 Nov 2023 07:03:51 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP4lT5z1P7Sl; Fri, 3 Nov 2023 22:00:45 +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, 3 Nov 2023 22:03:45 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 06/18] mm: huge_memory: use a folio in __split_huge_pmd_locked() Date: Fri, 3 Nov 2023 22:01:07 +0800 Message-ID: <20231103140119.2306578-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-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: dggems706-chm.china.huawei.com (10.3.19.183) 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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:46:12 -0700 (PDT) Use a folio in __split_huge_pmd_locked() which replaces six 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 34001ef9d029..054336ecab0a 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(folio), -HPAGE_PMD_NR); return; } -- 2.27.0