From patchwork Wed Aug 30 18:50:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13370636 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 5BF94C83F01 for ; Wed, 30 Aug 2023 18:50:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80C6B44017F; Wed, 30 Aug 2023 14:50:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BB36440178; Wed, 30 Aug 2023 14:50:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 636FF44017F; Wed, 30 Aug 2023 14:50:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4D4D3440178 for ; Wed, 30 Aug 2023 14:50:50 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2DC75160163 for ; Wed, 30 Aug 2023 18:50:50 +0000 (UTC) X-FDA: 81181662660.25.8F33D0E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id 09548100012 for ; Wed, 30 Aug 2023 18:50:47 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ZSJuCTff; dmarc=none; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693421448; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aMVqL4Ehyjcg7Nve1A90aSK4UDcsnIcdpQ7y3+6SNlc=; b=T5ytr5Wt/muFNJwRfGOmndamQCeo7dFlQ4E+INmKvAPvdYMEjPAn5iVx+fHXQ6WLtAxTXn +FwLaeOdWejcOr63h/SgapUHtkX9xMAMIi1OKpiRRYwmHUlXoXg2Smo0vERSPwIeqeCEAO dcT465pglYW9GbZP5Rsjc7P15PXG1Ug= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ZSJuCTff; dmarc=none; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693421448; a=rsa-sha256; cv=none; b=dF3SGAiEpUoYA0BmlFTwwNrS7pGGag6qQOO0l9IhDi/eZnITPahSPRQy7SC6Hj+9pZdO0c C2b8ThNipQgaduf2++3UVb32UARcumx56z0bR3DLF63teC0RjkXGKkxNF0R7MyhSnJ0u5a R+kz23wq7Yl3SVIYB/lDLlLnOxzyIGk= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=aMVqL4Ehyjcg7Nve1A90aSK4UDcsnIcdpQ7y3+6SNlc=; b=ZSJuCTff4SjyU768LyDk0256Ip wEVPxTECHoUW1qcrQsjBfTVcCSzVxzXpx5AUvv1ojzKbj9XzuL3d7Ntp4Q3CLdmunmxmBGbz9A0+h 4VMPoVZzHQHDFsTSJRBoEpYXyqgIguPFQZ5LVhqI32IWQDwhNaRUJILqVjYUJr590WwHNfqWvDIW+ r1y8BJ6kPeyE4CwA3aSxExLauOH5O6cN5YDXyoB11dFv44p8nxntkW5F23d5T658S8Gu2Os6GGZky ysn7B9ek/svHSqct4yHwDIl0ZHNDW3TFoCujrxa4EXE79BjCTp8E1ZGdFnSzriqCN9cxIzQdWILTq uZh5WtJw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qbQH7-00ENfW-26; Wed, 30 Aug 2023 18:50:45 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Ryan Roberts Subject: [RFC PATCH 16/18] mm: Use a folio in __collapse_huge_page_copy_succeeded() Date: Wed, 30 Aug 2023 19:50:39 +0100 Message-Id: <20230830185041.3427464-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230825135918.4164671-1-willy@infradead.org> References: <20230825135918.4164671-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 09548100012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: asx7ni56qe3j85ezgeu5xxd8qp3m3ikt X-HE-Tag: 1693421447-311595 X-HE-Meta: U2FsdGVkX1+W8ayEdeiJc8YU64iH7i8McNKuEySo0y+qhYoS6DTw+snAhBfFaDnEEFwTQn7ncqQ0RMWY+FogF4KnDmIzGdHld4yzYE1Eo6XJS5WwED3pcXnhMAIsrsf63fNJE+yRAnUWaO6NFrwjYk4qXICTQBmSuzi/sxRVnKrFfPxWdtlwlZZ+zIrmd/HsdskUzzzjEVKusvSdf9ZSFYAAew2PTTzz7MWw83m94GCEPDL9t2YlyBt0qVySX6G8iXlO4Wr1K1CX76eHFbsS+OIkK1WWwWSjQRGputk9u0kmOu+J4FUHxOd1A/vtQLhUBg1hRWeg2/zR90fC9LDuN+QAhuw+9ld/siFM14Pg0WzwD6subT0Gdi8ygmpUIj4+Bb7MzNuy9C25vtLj+59/ctWwQMUuE4e6JILgLmsQ5Veigf3LXR83IWVFXEjK8UVfyGMyEVNbJQVs2MJVvQd7o57wH2a/esCNe3WwFligTko0Y84DdR5db+irYkfnl77ze/6G+WXGm6E/szHcWHHtmg7HktoJzN3wRLmMFHxK/rCO4qErXebokqWCE3RlKPuW4wDi6Zze6LLkN0pUls4TwLkroWyyIwiybowvcv7rbNj2oR7EnT8z0EZuUq/StnUEtmnNNS9JFA6tvyp6qSQPKUOQt4jrw9q+NuA7Zt4mZZ79Cy2F79bWzFGnWFrtpGk+o1RqYYAsaWdNkiMqog8Qym4HOYYDnmrEJo6EVjWo6uuaAQWVZoN5RKGxGPBgOEg8LGnUzpBQtbtuTxB2v8exa75g4DdagkQ4VfY/iH3TNUPmUx7r4OsWCuh7Xq3bk6aUnsKJeezf21tpRU+08PVgt2rS4R5SWT2EpO2/VyQ2HjvpCHL0wedehin5O8ecWkmn5dV7w/tg0SsGoOJt75Z45Qp7+3Qb/vT9taScWjB655r875KgOe/pxiEf1uVx8KH0ZaeDkRAKNHtQ7Xjwk5J xPAw8qZV yMgtdsOKSa6ybiXMOvsCO9vHq3I03fxq6/sFLYQQy11lqLaHupokuciNFdE7LENW1w/zUiOMsxbt7QTZJDAiObVkaA3tfGUrZcEhg7RAP7Fn+Eo56YZvops4DmsXpCGJwmfz3cwOgAceuJ+YaFmTW0yBQdhL6LeHGGs1j7lqE+B7i7D5f9pfqkIx/rlFr3nbnJc0OmSmDBcl5JPlR2j3c7Jtht2ujkXqCH2zH 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: These pages are all chained together through the lru list, so we know they're folios. Use the folio APIs to save three hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/khugepaged.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 88433cc25d8a..afc94c281035 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -685,8 +685,7 @@ static void __collapse_huge_page_copy_succeeded(pte_t *pte, spinlock_t *ptl, struct list_head *compound_pagelist) { - struct page *src_page; - struct page *tmp; + struct folio *src, *tmp; pte_t *_pte; pte_t pteval; @@ -705,7 +704,7 @@ static void __collapse_huge_page_copy_succeeded(pte_t *pte, ksm_might_unmap_zero_page(vma->vm_mm, pteval); } } else { - src_page = pte_page(pteval); + struct page *src_page = pte_page(pteval); if (!PageCompound(src_page)) release_pte_page(src_page); /* @@ -721,14 +720,13 @@ static void __collapse_huge_page_copy_succeeded(pte_t *pte, } } - list_for_each_entry_safe(src_page, tmp, compound_pagelist, lru) { - list_del(&src_page->lru); - mod_node_page_state(page_pgdat(src_page), - NR_ISOLATED_ANON + page_is_file_lru(src_page), - -compound_nr(src_page)); - unlock_page(src_page); - free_swap_cache(src_page); - putback_lru_page(src_page); + list_for_each_entry_safe(src, tmp, compound_pagelist, lru) { + list_del(&src->lru); + node_stat_sub_folio(src, NR_ISOLATED_ANON + + folio_is_file_lru(src)); + folio_unlock(src); + free_swap_cache(&src->page); + folio_putback_lru(src); } }