From patchwork Fri Aug 25 13:59:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13365799 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 4FE3DC3DA6F for ; Fri, 25 Aug 2023 13:59:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0C388E0016; Fri, 25 Aug 2023 09:59:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CD0B2800C1; Fri, 25 Aug 2023 09:59:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFD082800BB; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3B1A72800C0 for ; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F3EEFB267C for ; Fri, 25 Aug 2023 13:59:25 +0000 (UTC) X-FDA: 81162784332.11.A69E6B7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP id B04C24000A for ; Fri, 25 Aug 2023 13:59:23 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cC8hYhXO; dmarc=none; spf=none (imf11.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=1692971964; 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=IbN4ox6XAesra77WmyaM3MdMG44S5bDbvXnZH45zTdw=; b=22obXB0Vu2E11xbfmt00Jd/RZ05iMa84JU9NDY3sI79/8MAA6IDxdH+rEYn3eB48H2yEvY kFd3bj9bpaEUOoPfS10elb1LEr0ppdWWX6PLT92LKx2w2B6ZJA5hIx911caTV2dxm0fDXB ogPh83oJ4mCnbi7//GKhMfZMWJKYCsI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cC8hYhXO; dmarc=none; spf=none (imf11.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=1692971964; a=rsa-sha256; cv=none; b=8bZ0Xq/OtktyKQI/ibnHggLRCp+jm1AtMLY6RVzdd8hfyTdJNqUEpupNUnmvkKV193HJsa H/iQ5r9yjd5NOy+KakMMA1z5iOaRzry1QJz9ayEsU5Nrtkfu5etnkahox64b9o08BMPAR8 VXtFPGUrG3PoJK5+KpYwzpoj97Fw3mM= 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=IbN4ox6XAesra77WmyaM3MdMG44S5bDbvXnZH45zTdw=; b=cC8hYhXOiS++B1m4VY0rS6TpUc wArYFQ/eD8PM10XdEwiK2b/xS7z0z5v3UsfDUn0tU6WKoB6XArj78sEDEfF8h9FNDkrPAGzOEpzwZ NUaxtJCX2TFg1ZISHMdrAhDdRKjibM3dm8NyV1zKlXIdpS+Fk5Z2OWIhAiI3p5xwMLSstncQe7104 9eh2+KPtKTxpIgRAPLvX5MrOHtR5G3s/iyFC7Vn0yzw2cc4CmXELXXVUBkcWQoOUU0X91pNw4jN4K 7zdLMBtmnHxth7r6iy+eUKkhAYJqfIg4LpbDWPtdyxjmm1RvOMzNZ6UNAkV+HEUw8OrV+vDn1m5FS gKfTF+Kg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qZXLN-00HTQY-3M; Fri, 25 Aug 2023 13:59:21 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [RFC PATCH 02/14] mm: Convert free_unref_page_list() to use folios Date: Fri, 25 Aug 2023 14:59:06 +0100 Message-Id: <20230825135918.4164671-3-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: B04C24000A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 76piinf8yt6jf6y99isbqs6bctwxriba X-HE-Tag: 1692971963-575802 X-HE-Meta: U2FsdGVkX1+WEVF4FDERwpS8iXuZ7iEOyqbf2IPH57wGVJfjes+aZYcwAMDv68Z/fC0L9SSzwE85hDLV9HGUtI0lkXynfBAQjbEetz02WygKYmi7P7XeAutn5N7taoDjpekUr4s7x19Z/EF/EUl7SBbKv8z5EdrI+8W6qjI5f9HoDaUu8ntDf5BxvWK9n7vBuFVH8IitVVuQFRd7i3f8AYErOLFEkEAKibdjz/vjdcU8Z2BJqJaniax8ZJduSDNuuatzTmoq/J7oCWOLb5GZ62B8/tLEYhMnrjsdOui+LR+ZQXpI8GqNxMV2OHqAUaUgGdb8Qu4vLcGmyQrMD7n0NAX9fPZ/c8HLuSycFGvna8vm05/5WjYt9uVivDZCxkWEDnlhham9elZ0OqoqNnDfWtzSlT0KStoMGlADHUfKUP+mgI8fh4MkBd8EYuGwGemYSaXxITloHBttdWlzdgXqSfl8mldPQcaaSVAGf790R9Fu6ET6JzH3YhzWRvy4idVkgcHuIgIpJUi8vIY2ZRO+fhCMhfQWuc+ihtUlaJaJTMvU87+NRqsVgMca1lXRq8O06KGn09nkTBKAI+5Btvm30YYsI84nadaZcnN9DqtH8uizF25CWvFNrHe6xXQ5DSJbe9Uh44FiUfceUeSrKdLTmFhtXnQ1YbgnQ/TIsKk/CtJlbFH5FUwZ7+qJLeU6nMOpDy8Oy1svH5zjdp1OBQJa27cy92kjHXH4mtMdN8NXB+WILfS4DyBoDssz9WwtraVkAmRRbSyZGcmooIcJGsh/iuNJKfhQcUCHB/5gHb84FtdXdV3shhF3m5PVqDveAp5E7fQFioFDY5MvLcysiogTJZaHA/dM++YIA5vGYc4JPxnJEdNOoFSens210ZEaQ1ehpJx3n9PbNdIYIDd1Kq1S45ELKORqooQPYYZp+y/zBDw3jC+LQ0RiuKNkerka+VDNrb+o03xQl27yyEda7B+ 2U0DhRRL tMNY4+c/RoVuKizrl/volhsnAoI1MNsfPR3VQaBFAV9QXhDIKTlxteDKUpXU+MQtMgrPuYsUgwPLQ4EoUbfxUeupj5PDXe6kaDdZimqCjsI+8lV71otSLRDlxydWC3Re6YjoUwAF9cbp6XFGV1B3XG/7cIdn8Bv2jbXEr6jO4On2JG3swTtyZBkC7yMxLDKfFvO8wvOtMkwNf2CT9oSaH0Jffi7Il+4yV8TtO 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: Most of its callees are not yet ready to accept a folio, but we know all of the pages passed in are actually folios because they're linked through ->lru. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Ryan Roberts --- mm/page_alloc.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 442c1b3480aa..f1ee96fd9bef 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2469,17 +2469,17 @@ void free_unref_page(struct page *page, unsigned int order) void free_unref_page_list(struct list_head *list) { unsigned long __maybe_unused UP_flags; - struct page *page, *next; + struct folio *folio, *next; struct per_cpu_pages *pcp = NULL; struct zone *locked_zone = NULL; int batch_count = 0; int migratetype; /* Prepare pages for freeing */ - list_for_each_entry_safe(page, next, list, lru) { - unsigned long pfn = page_to_pfn(page); - if (!free_unref_page_prepare(page, pfn, 0)) { - list_del(&page->lru); + list_for_each_entry_safe(folio, next, list, lru) { + unsigned long pfn = folio_pfn(folio); + if (!free_unref_page_prepare(&folio->page, pfn, 0)) { + list_del(&folio->lru); continue; } @@ -2487,24 +2487,25 @@ void free_unref_page_list(struct list_head *list) * Free isolated pages directly to the allocator, see * comment in free_unref_page. */ - migratetype = get_pcppage_migratetype(page); + migratetype = get_pcppage_migratetype(&folio->page); if (unlikely(is_migrate_isolate(migratetype))) { - list_del(&page->lru); - free_one_page(page_zone(page), page, pfn, 0, migratetype, FPI_NONE); + list_del(&folio->lru); + free_one_page(folio_zone(folio), &folio->page, pfn, + 0, migratetype, FPI_NONE); continue; } } - list_for_each_entry_safe(page, next, list, lru) { - struct zone *zone = page_zone(page); + list_for_each_entry_safe(folio, next, list, lru) { + struct zone *zone = folio_zone(folio); - list_del(&page->lru); - migratetype = get_pcppage_migratetype(page); + list_del(&folio->lru); + migratetype = get_pcppage_migratetype(&folio->page); /* * Either different zone requiring a different pcp lock or * excessive lock hold times when freeing a large list of - * pages. + * folios. */ if (zone != locked_zone || batch_count == SWAP_CLUSTER_MAX) { if (pcp) { @@ -2515,15 +2516,16 @@ void free_unref_page_list(struct list_head *list) batch_count = 0; /* - * trylock is necessary as pages may be getting freed + * trylock is necessary as folios may be getting freed * from IRQ or SoftIRQ context after an IO completion. */ pcp_trylock_prepare(UP_flags); pcp = pcp_spin_trylock(zone->per_cpu_pageset); if (unlikely(!pcp)) { pcp_trylock_finish(UP_flags); - free_one_page(zone, page, page_to_pfn(page), - 0, migratetype, FPI_NONE); + free_one_page(zone, &folio->page, + folio_pfn(folio), 0, + migratetype, FPI_NONE); locked_zone = NULL; continue; } @@ -2537,8 +2539,8 @@ void free_unref_page_list(struct list_head *list) if (unlikely(migratetype >= MIGRATE_PCPTYPES)) migratetype = MIGRATE_MOVABLE; - trace_mm_page_free_batched(page); - free_unref_page_commit(zone, pcp, page, migratetype, 0); + trace_mm_page_free_batched(&folio->page); + free_unref_page_commit(zone, pcp, &folio->page, migratetype, 0); batch_count++; }