linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Yznaga <anthony.yznaga@oracle.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@techsingularity.net>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm: Optimise put_pages_list()
Date: Fri, 22 Oct 2021 16:26:59 -0700	[thread overview]
Message-ID: <cb85b8a6-b82f-3054-5d76-57af018d6b2a@oracle.com> (raw)
In-Reply-To: <20211007192138.561673-1-willy@infradead.org>


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) <willy@infradead.org>
> ---
> 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()?


Anthony

> +		if (PageHead(page)) {
> +			list_del(&page->lru);
> +			__put_compound_page(page);
> +			continue;
> +		}
> +		/* Cannot be PageLRU because it's passed to us using the lru */
> +		__ClearPageWaiters(page);
>   	}
> +
> +	free_unref_page_list(pages);
>   }
>   EXPORT_SYMBOL(put_pages_list);
>   

  parent reply	other threads:[~2021-10-22 23:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07 19:21 [PATCH v2] mm: Optimise put_pages_list() Matthew Wilcox (Oracle)
2021-10-07 19:31 ` Andrew Morton
2021-10-07 20:55   ` Matthew Wilcox
2021-10-07 23:35     ` Andrew Morton
2021-10-08 14:17       ` Matthew Wilcox
2021-10-20 22:07         ` Anthony Yznaga
2021-10-21 14:41         ` Joao Martins
2021-10-22 23:26 ` Anthony Yznaga [this message]
2021-10-23  1:13   ` Matthew Wilcox
2021-10-23  6:11     ` Anthony Yznaga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb85b8a6-b82f-3054-5d76-57af018d6b2a@oracle.com \
    --to=anthony.yznaga@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).