From patchwork Sat Feb 17 02:25:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13561209 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 9FCD3C48260 for ; Sat, 17 Feb 2024 02:26:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8277A6B009C; Fri, 16 Feb 2024 21:25:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E53776B00A2; Fri, 16 Feb 2024 21:25:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB23B6B00A5; Fri, 16 Feb 2024 21:25:54 -0500 (EST) 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 90B7F6B009C for ; Fri, 16 Feb 2024 21:25:54 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6AD3240133 for ; Sat, 17 Feb 2024 02:25:54 +0000 (UTC) X-FDA: 81799705428.06.F981686 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id CB428A0002 for ; Sat, 17 Feb 2024 02:25:52 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=UowlmIBK; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708136752; 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=lqE1h+TV7PuhvcThUGfshDf8IYmuBERhJxDPw5eXVAI=; b=CTVN5kyyyKRjZpNJ8+3lQxup61DVJ9tHdBWKH1Fd/NNGfCRqcokEf4CKNESP4pBODH1jVk g30+cZ/NN2y0NSKU9V5UnHMFNyH8REvRpwyyKlaIopQZw6Kv5hkTZ8ee5jOrQKGH6GY5rM jManJ5/Vibu2RWot9Ts6+4PuSGW+AtQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708136752; a=rsa-sha256; cv=none; b=Eh9EoHuQrHgizTkqeSCvncMJFiuiDtdPyIKCkr+F/vVZkdt5qnhaQOkpRhncQ9Yf0rM52T 0f1WQDQO1zOesUP6emgBVY/Y8O82F/gs87XwN8RhbFvzHsm+8P+lwdRW5YqUJkbaBWdr51 uvLkeC7IWe/QICOFICJ1Z1a9ZCNYk/E= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=UowlmIBK; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=lqE1h+TV7PuhvcThUGfshDf8IYmuBERhJxDPw5eXVAI=; b=UowlmIBKxTgGIyCseqXthtDi5C dAxQBiyGIH3YaJ+O2a1zd9SY+skK60xKEbaski+YRuZe+GoAgy7UtGOAdadWrxdgkClx76mX3Z89g KdumithpSggzZIL7TYoCLVIcGWhGoM4yptw4ij4N1A92Yay5PGqE8ly48kSI0kd/G8fSWbln6rrFg XxCMDsbqx5NGOpf9bw0/u3df9oyxxQ6jqff6PyZJu1VQqOtx97M/PdSZZeLzF77FR94pLTm62d4T+ M3cZ+8VFsBlnBEw8eeSDiNvmuW4Zd6YrtznxOBxQ52muDZUqdoSb5y6xXZXihCFg6VK5KszJT+ax4 m8QDPLOQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbAOi-00000006HDH-2zqR; Sat, 17 Feb 2024 02:25:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Ryan Roberts Subject: [PATCH v2 06/18] mm: Remove use of folio list from folios_put() Date: Sat, 17 Feb 2024 02:25:32 +0000 Message-ID: <20240217022546.1496101-7-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217022546.1496101-1-willy@infradead.org> References: <20240217022546.1496101-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: CB428A0002 X-Rspam-User: X-Stat-Signature: jz39r6qbp81jw6ahpjuknypr4sd9jufe X-Rspamd-Server: rspam03 X-HE-Tag: 1708136752-137298 X-HE-Meta: U2FsdGVkX1899u7iz3btx/vUSYmHl0PsMfij+rOsWjlfx7uDbGby+sWJH5dv/TNcpjSVwCQ3BE4PfioyqS/+FZRSjEmlyZakp+3dTEiONdTgKYJriBQRYUewVD/TOOc/4EOkPEyuR9Kp+PQfmc3jLRCkFVe+L6xAdiolbv7QL0IkGhcE9WbRYGMfOyWOaz0cRi3hHA86zW6a0WjRLUW1kymkF6H185y63GIVTn89ODJ0ul2qUaBlTCrCa1m3BdpvMZJ5Vhmu4xXVFbDasRsRNX0mAoDwDhFf88cpDPjuVOlfTOmRhB0COG9heC3N6pkh6/EpdF1UkPOpJ/tQCQSChJfyn2isybzVjVe8jZ8QHuiTDuYwgBn6t60yo5LTIQ3F81vbcWy1IRI34A/ZJh+VpyD3ttS0YXv4U+MLQd0r7zq0v1ebNOEzGhBnPYKSY/BnoA0CfUZZTF1JxVOlHu6f0T6RJw7361dnYcRQvJb7JkyGdRhfwtXVa1R1cZjAYHyNJmv6ZG748Iy2uKqDD27cpfVk23YXg5l3564CFLsLfQXQfD3qo1CoaPldiiYC/XMHrSosQNnQ2UCAxUI6eec4iN5fTqCMY7qPWns1b4m3vUdhHRrxdVJ4Ka5Hy6LJSTnbRa3roCABrbT3r8s9vFaF6TjG7TC668pxLLYMolCvxZ2t2+hB/EboNt0sLsEBaHTQEK7Md7sjRQkX1GGhD2wnrfMq6C40IYQcLIjosZgMyEgNYH5ukf9RxHtvVMSM9kmx0WlTnb98fsrbCPmEvRx5i434AlNXgwwH8Th7sp9OkVDp1z5IsX9mdxIGDNLrvcXycVgiVQUg9mmTwLbpgpPN/dzrOthC2AZQS25x6amkA8nOJsZFoaSCZe4a+ZjavXFkD9aR+12+zZMSX7iX7ViQdaGIgLiUK4uwvAVx1VLWKfjvsvb8VSYg3eIqY/8bFsrhscMyu3YZGauBYX4ewEq vITtige3 eOtI0FaXEbKj9t4x0v8H0aiuUu8Xw6rEH6gKxdqYitC5X9GAvcbRpNJr1IUlp91xvTMPaQVWf2JHXJ6xaWRteCBsEdJ4gnzfBxvwcy95NmLtUaFSDcETaxsOYDKA6cY9O8kUdIqkRVQ4N7fLBLhTFr4SYq0eg9s1c2Tn1Gcad7Xq3n4TqtuyNqpnCgvEP5q7NI/Ti6PBokNBXDqonJP+KjeaJwfWhxpS0hAHYZYFqZfdgKs413hSfpnUDh2SuysmE37OQ5glUTSQBhjBx4N6qtk5nw4fYSNSmLiEI 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: Instead of putting the interesting folios on a list, delete the uninteresting one from the folio_batch. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Ryan Roberts --- mm/swap.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index c5ea0c6669e7..6b2f3f77450c 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -959,12 +959,11 @@ void lru_cache_disable(void) */ void folios_put(struct folio_batch *folios) { - int i; - LIST_HEAD(pages_to_free); + int i, j; struct lruvec *lruvec = NULL; unsigned long flags = 0; - for (i = 0; i < folios->nr; i++) { + for (i = 0, j = 0; i < folios->nr; i++) { struct folio *folio = folios->folios[i]; if (is_huge_zero_page(&folio->page)) @@ -1013,14 +1012,18 @@ void folios_put(struct folio_batch *folios) count_vm_event(UNEVICTABLE_PGCLEARED); } - list_add(&folio->lru, &pages_to_free); + if (j != i) + folios->folios[j] = folio; + j++; } if (lruvec) unlock_page_lruvec_irqrestore(lruvec, flags); + folios->nr = j; + if (!j) + return; - mem_cgroup_uncharge_list(&pages_to_free); - free_unref_page_list(&pages_to_free); - folios->nr = 0; + mem_cgroup_uncharge_folios(folios); + free_unref_folios(folios); } EXPORT_SYMBOL(folios_put);