From patchwork Fri Nov 3 14:01:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444574 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 3198AC4332F for ; Fri, 3 Nov 2023 14:04:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB035280022; Fri, 3 Nov 2023 10:04:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B607828001D; Fri, 3 Nov 2023 10:04:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A282B280022; Fri, 3 Nov 2023 10:04:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 910C728001D for ; Fri, 3 Nov 2023 10:04:28 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5887140429 for ; Fri, 3 Nov 2023 14:04:28 +0000 (UTC) X-FDA: 81416813016.02.449B40D Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf06.hostedemail.com (Postfix) with ESMTP id 09FB3180024 for ; Fri, 3 Nov 2023 14:04:24 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699020266; 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=ylqQuVj5ksYS6g4LV1U9DLXWq/46sIERK97vnxuNUQw=; b=5kLXLnZ9htPxiaQEj+f3Mrs5Vzck+N98IKBiAvlwlvV9RZtbjoANtPgcp0TklL76SbV4gR N+dSKwUIkHfqBxj7ust+O0mwVkMf4+mn3S1lZiQxZvhXt7HPcmbQZpPSo3a17bpWGEzhJ5 aR0ddeHD4x9dkawGFTVuj5VaMCP8IG0= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020266; a=rsa-sha256; cv=none; b=6ljB1NjfXYGUdPv+cpwKKcjv4QTjiQ+7vb0hp2zlS2QjESfQ9hhdY9KwRHdg0PiIAQAYF9 FV9l9wAELuJ5Q0Ts0ZYIzyidqO3RBbR4viI6C0Ym344tZ8Gj04AA8DqZrHzNMgSeKypab1 u1lIaZBnT/AFtgibAQRGy3OPC0nCKDk= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP5yQNz1P7pR; 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:46 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 09/18] mm: memory: use a folio in do_set_pmd() Date: Fri, 3 Nov 2023 22:01:10 +0800 Message-ID: <20231103140119.2306578-10-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-Rspam-User: X-Stat-Signature: samz3fxyh83an1woroyxmtht9jswigm5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 09FB3180024 X-HE-Tag: 1699020264-627793 X-HE-Meta: U2FsdGVkX1869LcuZdHrZI3XlAqDd1fyvV8wfdBXSI9ubZpPp85JVWReqpdlCuBAjnMr2pdfFSg83HEFH/WmkM8RXhcJmcHcyHpubFbF8c+hdjR9Z0Y9FnFa8B+iTnktLo9lWsW0zXVKiBBihJRYfVv7A4hG8iKcWhWFTGZDtUzLiC/uMrJE36ocAuo/rx5f4fBzygBW8KZIDuP3CQM8sqdKo9jL/I3/FIPzYs3YO70KPvxlJ1+/JS0fxqAUMTajveEJLd9ySSgYUTpzmSkohup5RMXMwrTpqvysdT0n3My+wH1f7uJ9JaG0G2AA8Opp/oPUJ1DBBsOK3xCYAXNzmzrk5kLa5BLZ8MGTzOITzPmCNRdUFPrbmyVDyq3VlWPt+Y99SDkafQWrk664xefPp87NSut+xVjYAN3auDNrDxEpID/lMiFUiaMa7itpArTzRxTecnJ4S1pRyEGDuflUG6XSZauUZWyLKox2ZSbZKtGkdIY0z1UObZUMzY0g4lv3EP5QVVxchBNk8ghui7iodyQNFnOzXiSExf5zLWjOlQMaLKq5LPaci4KYekieGAGIMVyo8bRdeT6cZPNfrqbOsbeoXU+SYWmPnQtLixo2xM1dcCtD6kO/2o7neS3B8MDmi+NNt+x1KkTtGRGyXxpA9Gy/TwaF42BWLLvHmSbGAjTdstX81ZUWVEki5X5gjCypYJ0UEhNoHU99jJrqjNOtQS/KIMFu8hfwJAdGq1nbb5rYxYxyAvX0gDnGdCSjBZD9nYA/1q7FQZMB2dSJRvX8DH70PoxZZkwgLECT8fHBSwF0uqWaTDyG0bpPTS8PD8iMHC7zNt5Xicihf91cCNvRVrJD0IKM88AyEIqUAnUigJG0+y7AY/E+KXXeX9Nzz98YJrmVk8Z3tGR8Lx2HzhQXxSHiVZfT41qvcUtLDx2UMKPDd+OS0+NySSD05btei21QIwCY/2j6wOyzQ0KicN3 hyiTloD0 pnrMxDAvmQi8y/03ciKHXg7SeGgdJhALG5HqFwCktxSq3Za5kalFIEiQqJD0xNYQt2zd2nmeC8SnKIS7y0OsSj/d3oYtwMC9X9IpQNWZ1mBKYXogcPIXtmHK5xI8rF6n/5XkPj6Bh88lthaH9MHKk0N45TQJpcDnE4HrNHTJCryFCGGBEcxQ5vTLVxkz1zRumrlJw 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 do_set_pmd(), which save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1f18ed4a5497..09009094a5f2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4313,12 +4313,13 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) unsigned long haddr = vmf->address & HPAGE_PMD_MASK; pmd_t entry; vm_fault_t ret = VM_FAULT_FALLBACK; + struct folio *folio; if (!transhuge_vma_suitable(vma, haddr)) return ret; - page = compound_head(page); - if (compound_order(page) != HPAGE_PMD_ORDER) + folio = page_folio(page); + if (folio_order(folio) != HPAGE_PMD_ORDER) return ret; /* @@ -4350,7 +4351,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) if (write) entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); - add_mm_counter(vma->vm_mm, mm_counter_file(page), HPAGE_PMD_NR); + add_mm_counter(vma->vm_mm, mm_counter_file_folio(folio), HPAGE_PMD_NR); page_add_file_rmap(page, vma, true); /*