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: 13444567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 425ADC4332F for ; Fri, 3 Nov 2023 14:04:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 483EF280023; Fri, 3 Nov 2023 10:03:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 435D0280021; Fri, 3 Nov 2023 10:03:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 286F5280023; Fri, 3 Nov 2023 10:03:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1AD4C280021 for ; Fri, 3 Nov 2023 10:03:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9AC241A0400 for ; Fri, 3 Nov 2023 14:03:58 +0000 (UTC) X-FDA: 81416811756.23.E3E22C4 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf17.hostedemail.com (Postfix) with ESMTP id E06F040022 for ; Fri, 3 Nov 2023 14:03:55 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699020236; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/HAJ8XbTBaLTFFDB1GrLQZOkpvtPmYqj4jF+Og1D+HM=; b=bL5aKOTezQt7HaeqYXT1Of1rUprDsW1m4E7jZwCsCtXfYGqiRqpGWM2KQh59ksx4ZoKM8J FDHvgc9EaUTe7ImfkbTtPZaeTAX0+cJea3MJ4yao/fy8tqX+DXcLasAMSZUmqtyJBmavQ2 UxmKBQT4dd6KGxyOFSZd/v4Iz41Zk14= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020236; a=rsa-sha256; cv=none; b=WEb3Ks9z3ffw9DMLdLUR7WaN1+cSS8sqz9wFHbjkA5NIgrlCXE+PnHcn5pGuTCSKrKbLTt ucmI80z5C2P6cxJh1Td1Vhc3oeL5qoJhNBCFNGMrxMnOjo8DN6vnfirXmQKc4UfeJy3W4T B4Stv4AgTkd38lexoTuUyWnaE3lQprk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com 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-Rspamd-Queue-Id: E06F040022 X-Rspam-User: X-Stat-Signature: g9fcwaidwqm4p89arxfmdyyhqsc98cw9 X-Rspamd-Server: rspam03 X-HE-Tag: 1699020235-764742 X-HE-Meta: U2FsdGVkX1+pdpQwKyFc6DRnEo7MbC0XsJnghQzG1/4bcB71IbnFoi2A4Un9FMj7UIku7Q5sB7GB++dPCTlJq90ZT22sgPgudd8WH+q5yXzXHVmrlf8c8Qf4Jyd5hXZOefl8jk6EyHKItIZ+DTU5VhGWztt3GS1Ux2ApNwCoPKU+ZS+P58dboL6HHBPIorMGL0+1RD8DdJ7/oMJ0jLC466N3u34uBHu7/h67xXrlGhUTOqstsVRa7sR2v/IBGIXa+lR4K9ac2AS27QrPpSPyoIiSLUe6Un729GHqqg23awweLVKOBVgtr1fZxNwu5YG3vdp0gkfYnN7Z5u5Ku+Jm+xhgCHU8IywHVzVl14P52czTRrBglU8ZNWrTg5JfHmXGv+pZdxPaHghK7HK5F5iWv/XCjTEGuxqvJZliu3sbprMNu4UQp0idDDY93d2jAjKgynq0R8tibuHm+kj/6dOHgbsVyUHCM8i69Vb1bJvZ1KPW/VhvMgkvU11nvb8EUzpGVV9HLEUBe8XzchyGBz7MP8NJBhbrYiF0aP1P1CeXiBUbvxDbMoq8tTUS1re11oNt7N3iI5y4O7Xe8oNK/Eo3vebYtAV2f4veb8vwUyahy0l1oZ/Ids3Bkz6ZTaYs527mhTYwk6AHTkoFMkbkyxtwSgyGjHZSbx3XKYlnXhANEQ8E5Y/x4DrD5taWDsVuikFDzWqiayiweiv4UBDuDl/rmnKuWH0NH5ypnABG9qmwefCcnncMODJgG3KSQMMEzbcZ43tWw3xi/Zz7gnqOG+zh62o7IDoQA6QBVAPf4rQnMlk+K3YdvF65dhx5auid7SJPFk2Lf4ssfJcQl/fvwei2E1B9duB23BoHszG27UEL9Jm6c47ZUkR3nBlc6ACiwm10L4zRKKLLdiYleIfR5FCOnkjKEbOGBX391GTtDG6VA9WDIpSMEwlD6fihZwDX/Vm+WVnCIZOQb2oq9AFnf0N dtrqNANs zslDiI14f3QdLanDYZFFUPUzH65iZpCA0aQ2QzDzo//0+JYKh+4Mg+uKfnOz6XS3R+r0si6L7hieEzIwT3xeY9rQ3PsP8Q99upmcde3JDECengt7CcfgMY5FyVnRow3w9Jw70Rxl1uAp1/E/zIG6R6pYp7AQFbyOKnaWpJHNksymy7IjJ1ekkmPBzT3RnRZ3/tCic X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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);