From patchwork Mon Nov 6 15:49:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 162058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2750200vqu; Mon, 6 Nov 2023 07:51:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVIPXqCIRJeUGMVO79ncOgGWDrFAGqw+3Z6j+EQ1Vm5NhhmeR45YDt2uLE+eYVnp2BXRjj X-Received: by 2002:a17:903:18a:b0:1cc:76c4:5144 with SMTP id z10-20020a170903018a00b001cc76c45144mr16732195plg.12.1699285881103; Mon, 06 Nov 2023 07:51:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699285881; cv=none; d=google.com; s=arc-20160816; b=AtLlelWTGdUpaE5Kw5Lx0jQOBJvjxHScQ0CV2CkOX1YNtlxxUGGLqsUX6taOjkTSH+ qdMns2n80ovOp81CUuURhdrbaL+ZIOGbqS6BDn9W4XUVZGA+cEysBiYuX+57cQyVJlaz eFjScbWww3uixDH4S5gLq8/4AlAha2/lJfog/yXyOKo1cqLU7J5XH3NW277Estf9zfIN fzK6biCyw0XirIl54vbODyChnWpai65blsdJyzvE2FQy/Mc3MTxsnF/3iuQiJXoQ/jJE ttyZruAm2bU2bCi780y2IJ3deqDhbhAa0xa3zCBbLZqJFFGIbj7/nX0GUzzZQ0Fe+mP1 X/AA== 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=tP9NWM/ekJcLRFo0kqQKalmLDZuh2TT+P+my24sgZwk=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=pLYg3vHkEkDs4GXz2p7L+P4SiDDQ4ipE1MtyrPoEAhzzAI/AzbncTp43X7BGFgqXKV /p1WLnZHaIZtEiBwJ9AeSrLlsWSHFUQ5oU7XgSWOA4L8YcN5RLUbyEef6oaZTDY75+zI q/O8i1wzmyO5anvXFU0QiJa914xeY+wiseoYQ7QUfFmUEsvB9Riyig7iwf1HoU6J9IDg j3srfzPGsq4nlDUgtAVR1X4385W/2iN4qcyEqP4iV1LqTn0yOSU8xYlkpJcRqwZvjbPw CJRlM8jD27Wjqo9GQ1DqiBDGvPUnLFQoeJ82hRY8zrJd8GpJG+/8NBJ84TeRue1H0403 MPOQ== 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:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id d16-20020a170902ced000b001cc5029e3c1si8978351plg.370.2023.11.06.07.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 07:51:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 8DD318082DDF; Mon, 6 Nov 2023 07:50:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232696AbjKFPuN (ORCPT + 35 others); Mon, 6 Nov 2023 10:50:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbjKFPuF (ORCPT ); Mon, 6 Nov 2023 10:50:05 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDCB6D61; Mon, 6 Nov 2023 07:50:02 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SPG4x5P3BzvQTB; Mon, 6 Nov 2023 23:49:53 +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; Mon, 6 Nov 2023 23:50:00 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 04/10] mm: huge_memory: use a folio in zap_huge_pmd() Date: Mon, 6 Nov 2023 23:49:44 +0800 Message-ID: <20231106154950.3399469-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> References: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 06 Nov 2023 07:50:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781830391841469585 X-GMAIL-MSGID: 1781830391841469585 Use a folio in zap_huge_pmd(), which is a preparetion for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 34dd01970927..78a00fe22c2d 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1716,11 +1716,13 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, zap_deposited_table(tlb->mm, pmd); spin_unlock(ptl); } else { - struct page *page = NULL; + struct folio *folio = NULL; int flush_needed = 1; if (pmd_present(orig_pmd)) { - page = pmd_page(orig_pmd); + struct page *page = pmd_page(orig_pmd); + + folio = page_folio(page); page_remove_rmap(page, vma, true); VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); VM_BUG_ON_PAGE(!PageHead(page), page); @@ -1729,12 +1731,12 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, VM_BUG_ON(!is_pmd_migration_entry(orig_pmd)); entry = pmd_to_swp_entry(orig_pmd); - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); flush_needed = 0; } else WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!"); - if (PageAnon(page)) { + if (folio_test_anon(folio)) { zap_deposited_table(tlb->mm, pmd); add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); } else { @@ -1745,7 +1747,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, spin_unlock(ptl); if (flush_needed) - tlb_remove_page_size(tlb, page, HPAGE_PMD_SIZE); + tlb_remove_page_size(tlb, &folio->page, HPAGE_PMD_SIZE); } return 1; }