From patchwork Fri Nov 3 14:01:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1088580vqu; Fri, 3 Nov 2023 07:47:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm3Q/ENvvew87Ec0DQFBgz9pMqty+r2DkB8xLlp+1JL5uYDE6hHFxvxJivS52qf6CZO/27 X-Received: by 2002:a17:902:c951:b0:1cc:70dd:62e7 with SMTP id i17-20020a170902c95100b001cc70dd62e7mr9984389pla.32.1699022853448; Fri, 03 Nov 2023 07:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022853; cv=none; d=google.com; s=arc-20160816; b=KNcZRaG44BPD4ms8WrPtfQjT8OyBVxsm4drso+YwOzKX7v0i7CTmx7KttAanDoEP/M 7ch+9JsP5++vNKZ25X0WiuHf2pA9Ys5jTJkk3IKfyyiv/lZW2n8mFi4dLuFOS3UK30BR Flp3W2Ayl1vaKSBlZBmPfVdcDgF9DwVNeQzhgN1xR0Y88SJ36V0gGEsp5Z14Ugjluc4s 6nkqmAfnN5i2QrgBPfQ2cBbWEi+VuqLuxX2wVYMqtBVtAViiYuY6puIvopVjJCx9k6+N NOb+PbdEBIp6XIOUba4Uqnegwh9P69AnajQoq0dv/ORB75HL3tXR9JTQq/MH72NOWNaN Oq9A== 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 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id o6-20020a17090323c600b001cc6529c7besi1578189plh.88.2023.11.03.07.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:47:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 65F088095014; Fri, 3 Nov 2023 07:46:03 -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 S229729AbjKCOp4 (ORCPT + 36 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 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=-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,T_SCC_BODY_TEXT_LINE 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, 03 Nov 2023 07:46:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781554587363513039 X-GMAIL-MSGID: 1781554587363513039 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; }