linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Huang Ying <ying.huang@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Johannes Weiner <hannes@cmpxchg.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Xu <peterx@redhat.com>, Hugh Dickins <hughd@google.com>,
	Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@surriel.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Michal Hocko <mhocko@kernel.org>,
	Dave Hansen <dave.hansen@intel.com>,
	Tim Chen <tim.c.chen@intel.com>
Subject: Re: [PATCH] mm: free idle swap cache page after COW
Date: Tue, 1 Jun 2021 12:48:15 +0100	[thread overview]
Message-ID: <YLYef3i2OGseGbsS@casper.infradead.org> (raw)
In-Reply-To: <20210601053143.1380078-1-ying.huang@intel.com>

On Tue, Jun 01, 2021 at 01:31:43PM +0800, Huang Ying wrote:
> With commit 09854ba94c6a ("mm: do_wp_page() simplification"), after
> COW, the idle swap cache page (neither the page nor the corresponding
> swap entry is mapped by any process) will be left in the LRU list,
> even if it's in the active list or the head of the inactive list.  So,
> the page reclaimer may take quite some overhead to reclaim these
> actually unused pages.
> 
> To help the page reclaiming, in this patch, after COW, the idle swap
> cache page will be tried to be freed.  To avoid to introduce much
> overhead to the hot COW code path,
> 
> a) there's almost zero overhead for non-swap case via checking
>    PageSwapCache() firstly.
> 
> b) the page lock is acquired via trylock only.
> 
> To test the patch, we used pmbench memory accessing benchmark with
> working-set larger than available memory on a 2-socket Intel server
> with a NVMe SSD as swap device.  Test results shows that the pmbench
> score increases up to 23.8% with the decreased size of swap cache and
> swapin throughput.

So 2 percentage points better than my original idea?  Sweet.

> diff --git a/mm/memory.c b/mm/memory.c
> index 2b7ffcbca175..d44425820240 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3104,6 +3104,8 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf)
>  				munlock_vma_page(old_page);
>  			unlock_page(old_page);
>  		}
> +		if (page_copied)
> +			free_swap_cache(old_page);
>  		put_page(old_page);
>  	}
>  	return page_copied ? VM_FAULT_WRITE : 0;

Why not ...

		if (page_copied)
			free_page_and_swap_cache(old_page);
		else
			put_page(old_page);

then you don't need to expose free_swap_cache().  Or does the test for
huge_zero_page mess this up?



  reply	other threads:[~2021-06-01 11:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01  5:31 Huang Ying
2021-06-01 11:48 ` Matthew Wilcox [this message]
2021-06-01 15:00   ` Johannes Weiner
2021-06-02  3:18     ` Linus Torvalds
2021-06-01 13:30 ` Johannes Weiner

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=YLYef3i2OGseGbsS@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@kernel.org \
    --cc=peterx@redhat.com \
    --cc=riel@surriel.com \
    --cc=tim.c.chen@intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=ying.huang@intel.com \
    /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