From patchwork Fri Nov 3 14:01:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1087765vqu; Fri, 3 Nov 2023 07:46:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGv8Eg5NKiibFYXPCirslWe3GVhsP/kIX49rX83jXoLAo4xUcwR8iEn89J3CRk1kA2yNIec X-Received: by 2002:a05:6a21:7785:b0:180:db7b:23f2 with SMTP id bd5-20020a056a21778500b00180db7b23f2mr16329668pzc.61.1699022776237; Fri, 03 Nov 2023 07:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022776; cv=none; d=google.com; s=arc-20160816; b=dLsboecsx3aH0t8mkRWsM77Z9x39cu8C4FRrizCjja1dCDd+DzaAvdweSPpVGDdnDU cBhSuOXT06cYARzxXhtTzbYtkStJaMTrWFnLpn+V5sm1TwsGp4lUik+VggQv9K1sm7OM dQQ0M2n0Xs9lVvlLTMhKgNhOfCufZ5YPMcUIudp932nbXW6tA7QEQ1DR6dDd+SzF4Y60 nwipG13zLF4ZYQncLLPzbS2GGufAG/KJGpLBEvcZzcaf2FRxPCLqRBBmuNHYL06qfpfs GNMQ2GyDML1XZotQ2XgazjQhWBjRJSX99wiKMwKdnnG2FoqJkl+KMV6lKrtyaZoG2AEU yoUg== 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=/HAJ8XbTBaLTFFDB1GrLQZOkpvtPmYqj4jF+Og1D+HM=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=xnCalo9kNsfTmExVIyMWnBFxljIqS6lw3POLs3LRbtnmRxaupq8+vaANryfZpKcrYG 69HIrMC04JIDf3Kk2ZeeuHKD/uMZEEAqcSwc5qNzbOGpsodsPOWdSFVsElFUtwVeIt9P 0QBEyQBPv7ZenHxBDgQlgq6FbCyr1d9ZfCtjZ0AXjRyLZo+YvY+OMDD+gS8YA780eqL9 aqSPs4jdd/pDX372tEkOj5dcgs3cYptV7cI5GchtfuOFPJcIz6d+iKqJS+LuPyh+b1Uc Q3qcUSLkKzuQore37Sq5n4L7ZbuAvAAgZG4iJU9Cb29yV3+lF2dlol52cNS4B41KQVaH YNQQ== 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 e24-20020a656798000000b00578ea9a0b93si1599047pgr.890.2023.11.03.07.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:46:16 -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 22EAE829EA36; Fri, 3 Nov 2023 07:46:12 -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 S229903AbjKCOp6 (ORCPT + 36 others); Fri, 3 Nov 2023 10:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377811AbjKCODz (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 45390D59; 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 4SMMpP5NHRz1P7nG; 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 07/18] mm: huge_memory: use a folio in zap_huge_pmd() Date: Fri, 3 Nov 2023 22:01:08 +0800 Message-ID: <20231103140119.2306578-8-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=-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 07:46:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781554506265264484 X-GMAIL-MSGID: 1781554506265264484 Use a folio in zap_huge_pmd() which replaces two compound_head() call with one page_folio() call. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 054336ecab0a..2dba4d3aa2d3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1717,6 +1717,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, spin_unlock(ptl); } else { struct page *page = NULL; + struct folio *folio = NULL; int flush_needed = 1; if (pmd_present(orig_pmd)) { @@ -1734,13 +1735,14 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, } else WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!"); - if (PageAnon(page)) { + folio = page_folio(page); + if (folio_test_anon(folio)) { zap_deposited_table(tlb->mm, pmd); add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); } else { if (arch_needs_pgtable_deposit()) zap_deposited_table(tlb->mm, pmd); - add_mm_counter(tlb->mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(tlb->mm, mm_counter_file_folio(folio), -HPAGE_PMD_NR); } spin_unlock(ptl);