From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D6BFC433F5 for ; Sat, 23 Oct 2021 01:15:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9C511608FB for ; Sat, 23 Oct 2021 01:15:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9C511608FB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id CFB49940008; Fri, 22 Oct 2021 21:15:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C83E9940007; Fri, 22 Oct 2021 21:15:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFFCF940008; Fri, 22 Oct 2021 21:15:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id A309B940007 for ; Fri, 22 Oct 2021 21:15:06 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 643078249980 for ; Sat, 23 Oct 2021 01:15:06 +0000 (UTC) X-FDA: 78725933412.18.1D9A6D2 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id A73E51906 for ; Sat, 23 Oct 2021 01:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0aWo7cdjf8VAjVdLovc3QcMEUO0D9bv9Ns1nWcTyQ4M=; b=lR94lvpYLjehSTpOek+ZG7nYnb 13UXuiNnKBggx+mZlLPp4Aj5sQD8549TImK7puBgKxmO+IbfsoLrpLfncA23hd/diiYe6b/Wgbj/J QLgVLpXtV9NEuvMjqqHNmqhpDZq5cNHa4yUUy9Ij2pY+EK1IlwAku9bkce7TxNVNN0K+4NJe+L2ti UYWF6oikPzsey7BYUX0vy23yeGbE2hf06R96O0MrAvvss7YxP6jt4rLb/KF1MWY7ZA4Nn1cjbHzg1 O82T1aptVHpKPflA6mHyuehpJXH0hJ5wYlFDqEydbYVyCAr08acZd0idYDEhvkLV6P8wCi5C9Wnkj kO4epW7A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1me5bT-00EIw3-3Y; Sat, 23 Oct 2021 01:13:58 +0000 Date: Sat, 23 Oct 2021 02:13:43 +0100 From: Matthew Wilcox To: Anthony Yznaga Cc: Andrew Morton , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: Optimise put_pages_list() Message-ID: References: <20211007192138.561673-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A73E51906 X-Stat-Signature: 7ymsn5b99zzfjrnjc5wd5s5jsso5f5ko Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lR94lvpY; dmarc=none; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1634951705-735395 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: On Fri, Oct 22, 2021 at 04:26:59PM -0700, Anthony Yznaga wrote: > > On 10/7/21 12:21 PM, Matthew Wilcox (Oracle) wrote: > > Instead of calling put_page() one page at a time, pop pages off > > the list if their refcount was too high and pass the remainder to > > put_unref_page_list(). This should be a speed improvement, but I have > > no measurements to support that. Current callers do not care about > > performance, but I hope to add some which do. > > > > Signed-off-by: Matthew Wilcox (Oracle) > > --- > > v2: > > - Handle compound pages (Mel) > > - Comment why we don't need to handle PageLRU > > - Added call to __ClearPageWaiters(), matching that in release_pages() > > > > mm/swap.c | 23 ++++++++++++++++------- > > 1 file changed, 16 insertions(+), 7 deletions(-) > > > > diff --git a/mm/swap.c b/mm/swap.c > > index af3cad4e5378..9f334d503fd2 100644 > > --- a/mm/swap.c > > +++ b/mm/swap.c > > @@ -134,18 +134,27 @@ EXPORT_SYMBOL(__put_page); > > * put_pages_list() - release a list of pages > > * @pages: list of pages threaded on page->lru > > * > > - * Release a list of pages which are strung together on page.lru. Currently > > - * used by read_cache_pages() and related error recovery code. > > + * Release a list of pages which are strung together on page.lru. > > */ > > 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); > > + continue; > > + } > > > I know that compound pages are not currently passed to put_pages_list(), > but I assume the put_page_testzero() should only be done on the head > page similar to release_pages()? Fun fact about pages: You can't put a tail page on an LRU list. Why? struct page { ... union { struct { /* Page cache and anonymous pages */ struct list_head lru; ... struct { /* Tail pages of compound page */ unsigned long compound_head; /* Bit zero is set */ so if you try to put a tail page on the LRU list, it becomes no longer a tail page.