Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp564211pxb; Thu, 30 Sep 2021 11:56:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNbblt2bAC8qYS0zMUciy8PSwxvDJ7TPQ8Zk725+t++1H2WjloEW10joJvC46Ul+CTKZLR X-Received: by 2002:a17:903:1207:b0:13d:b9b1:ead7 with SMTP id l7-20020a170903120700b0013db9b1ead7mr5655192plh.63.1633028219216; Thu, 30 Sep 2021 11:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633028219; cv=none; d=google.com; s=arc-20160816; b=n7GpDg2XGbNJ7blu3oWt9/hqHEwGt1HRsTi6GvFn2l3uMMIZsfjkXX0qdGEHfj8hS6 zZ2l78YvhDKfRrUC9wQYLq7RZ2s3pGVvHkC01BKLe3YTC1k31Piq2zYxBY9K7Ir2+k46 C3WsS6qfUVzaoRlLPdOKApJlw+LutFvcTkIEg/gF4mJKcCF/57H/1/F1PQuzwkPgkT+B NMSgdx7TlLrcIjWishmpTwaj7FBQm06S/u+igB7Si/RBX1A+0J5Py/VFjE+ZR4piluJt e692v0kxIJOI97jINovW1jPUyJ7VGLe2llesg9UAENEkHwImkrRfWJX1Vmh/c5M5HpyM l9mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=dGRVuVHbzksQmbzJlQOqYbJI1FUMHbOyKl7nGX1/loQ=; b=SIIe9EjxS6GB87LAtSjFlcuxb3wwb5SI50UGy8BmylWsEyVRwm6Jy1LyfOBMlFaIC3 oBRt3CYEvMl/r0juGUiwp1+YGLoGmkIDi0o1l5rIb2x0d75niyljutNIEhEpGeALAxvu waN8zBofhFBHOGX9t2qgoWAteWM0tS9A+Q/UnjP/7wEbwv1tfHVx5BYE38aLCemN6+3T HGKZghisIxt1v9jMtlIohxMkbAXR4ICCxcN5XKT/Owhli7IVc21e3bs9ODvuVIuaOK1k AWjF9qn7lILLjwrPCkC0uROEEJJwk9Et1ERKYGmi4GqHLTB+A4b77950ulPWEDsYx+He Z41w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gK4ZdfX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si4854365pls.183.2021.09.30.11.56.45; Thu, 30 Sep 2021 11:56:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gK4ZdfX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352018AbhI3QgN (ORCPT + 99 others); Thu, 30 Sep 2021 12:36:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350921AbhI3QgM (ORCPT ); Thu, 30 Sep 2021 12:36:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0A9BC06176A for ; Thu, 30 Sep 2021 09:34:29 -0700 (PDT) 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: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=dGRVuVHbzksQmbzJlQOqYbJI1FUMHbOyKl7nGX1/loQ=; b=gK4ZdfX8FmPi5KpCz29ShyheUC g2gwIY4nbVPa1HUbgwM0XTb/YC1yUVdHsJzut0smgk6b471+UULwDI5DnRXWOFkTYNkuSqNqYjCik bkRN8Vbdosul7jlVD6znOnZa98NX+WmVJ6R3wICFOYOWPjx6ipMI/6tzPsxDwTm8GFRvnz4x18W8Z wku78QJr2r3uTH21eBqUDqtwe+QUefjWoWfjZvwM6dyQbBOnW0tVImlR7gmrEJdzS6WV8s26LjpQj ZJh8Ggl6jxEJr0z0M3OEhCUxJrJJCYJqvE2uSF3Qf1YGnxLxewjdEjPk2ThWrG+HcT1Zufgx5t/lY MUdXqvQg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVyzW-00D4DU-Tm; Thu, 30 Sep 2021 16:33:10 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" Subject: [RFC] mm: Optimise put_pages_list() Date: Thu, 30 Sep 2021 17:32:58 +0100 Message-Id: <20210930163258.3114404-1-willy@infradead.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of calling put_page() one page at a time, pop pages off the list if there are other refcounts and pass the remainder to free_unref_page_list(). This should be a speed improvement, but I have no measurements to support that. It's also not very widely used today, so I can't say I've really tested it. I'm only bothering with this patch because I'd like the IOMMU code to use it https://lore.kernel.org/lkml/20210930162043.3111119-1-willy@infradead.org/ Signed-off-by: Matthew Wilcox (Oracle) --- mm/swap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index af3cad4e5378..f6b38398fa6f 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -139,13 +139,14 @@ EXPORT_SYMBOL(__put_page); */ void put_pages_list(struct list_head *pages) { - while (!list_empty(pages)) { - struct page *victim; + struct page *page, *next; - victim = lru_to_page(pages); - list_del(&victim->lru); - put_page(victim); + list_for_each_entry_safe(page, next, pages, lru) { + if (!put_page_testzero(page)) + list_del(&page->lru); } + + free_unref_page_list(pages); } EXPORT_SYMBOL(put_pages_list); -- 2.32.0