linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mgorman@suse.de>
To: Dave Hansen <dave@sr71.net>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, tim.c.chen@linux.intel.com
Subject: Re: [RFCv2][PATCH 5/5] batch shrink_page_list() locking operations
Date: Fri, 17 May 2013 14:35:27 +0100	[thread overview]
Message-ID: <20130517133527.GM11497@suse.de> (raw)
In-Reply-To: <20130516203434.41DFD429@viggo.jf.intel.com>

On Thu, May 16, 2013 at 01:34:34PM -0700, Dave Hansen wrote:
> 
> From: Dave Hansen <dave.hansen@linux.intel.com>
> changes for v2:
>  * remove batch_has_same_mapping() helper.  A local varible makes
>    the check cheaper and cleaner
>  * Move batch draining later to where we already know
>    page_mapping().  This probably fixes a truncation race anyway
>  * rename batch_for_mapping_removal -> batch_for_mapping_rm.  It
>    caused a line over 80 chars and needed shortening anyway.
>  * Note: we only set 'batch_mapping' when there are pages in the
>    batch_for_mapping_rm list
> 
> --
> 
> We batch like this so that several pages can be freed with a
> single mapping->tree_lock acquisition/release pair.  This reduces
> the number of atomic operations and ensures that we do not bounce
> cachelines around.
> 
> Tim Chen's earlier version of these patches just unconditionally
> created large batches of pages, even if they did not share a
> page_mapping().  This is a bit suboptimal for a few reasons:
> 1. if we can not consolidate lock acquisitions, it makes little
>    sense to batch
> 2. The page locks are held for long periods of time, so we only
>    want to do this when we are sure that we will gain a
>    substantial throughput improvement because we pay a latency
>    cost by holding the locks.
> 
> This patch makes sure to only batch when all the pages on
> 'batch_for_mapping_rm' continue to share a page_mapping().
> This only happens in practice in cases where pages in the same
> file are close to each other on the LRU.  That seems like a
> reasonable assumption.
> 
> In a 128MB virtual machine doing kernel compiles, the average
> batch size when calling __remove_mapping_batch() is around 5,
> so this does seem to do some good in practice.
> 
> On a 160-cpu system doing kernel compiles, I still saw an
> average batch length of about 2.8.  One promising feature:
> as the memory pressure went up, the average batches seem to
> have gotten larger.
> 
> It has shown some substantial performance benefits on
> microbenchmarks.
> 
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
>
> <SNIP>
>
> @@ -718,6 +775,7 @@ static unsigned long shrink_page_list(st
>  		cond_resched();
>  
>  		page = lru_to_page(page_list);
> +
>  		list_del(&page->lru);
>  
>  		if (!trylock_page(page))

Can drop this hunk :/

> @@ -776,6 +834,10 @@ static unsigned long shrink_page_list(st
>  				nr_writeback++;
>  				goto keep_locked;
>  			}
> +			/*
> +			 * batch_for_mapping_rm could be drained here
> +			 * if its lock_page()s hurt latency elsewhere.
> +			 */
>  			wait_on_page_writeback(page);
>  		}
>  
> @@ -805,6 +867,18 @@ static unsigned long shrink_page_list(st
>  		}
>  
>  		mapping = page_mapping(page);
> +		/*
> +		 * batching only makes sense when we can save lock
> +		 * acquisitions, so drain the previously-batched
> +		 * pages when we move over to a different mapping
> +		 */
> +		if (batch_mapping && (batch_mapping != mapping)) {
> +			nr_reclaimed +=
> +				__remove_mapping_batch(&batch_for_mapping_rm,
> +							&ret_pages,
> +							&free_pages);
> +			batch_mapping = NULL;
> +		}
>  
>  		/*
>  		 * The page is mapped into the page tables of one or more

As a heads-up, Andrew picked up a reclaim-related series from me. It
adds a new wait_on_page_writeback() with a revised patch making it a
congestion_wait() inside shrink_page_list. Watch when these two series
are integrated because you almost certainly want to do a follow-up patch
that drains before that congestion_wait too. 

Otherwise

Acked-by: Mel Gorman <mgorman@suse.de>

-- 
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2013-05-17 13:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-16 20:34 [RFCv2][PATCH 0/5] mm: Batch page reclamation under shink_page_list Dave Hansen
2013-05-16 20:34 ` [RFCv2][PATCH 1/5] defer clearing of page_private() for swap cache pages Dave Hansen
2013-05-16 20:34 ` [RFCv2][PATCH 2/5] make 'struct page' and swp_entry_t variants of swapcache_free() Dave Hansen
2013-05-17 13:27   ` Mel Gorman
2013-05-16 20:34 ` [RFCv2][PATCH 3/5] break up __remove_mapping() Dave Hansen
2013-05-16 20:34 ` [RFCv2][PATCH 4/5] break out mapping "freepage" code Dave Hansen
2013-05-16 20:34 ` [RFCv2][PATCH 5/5] batch shrink_page_list() locking operations Dave Hansen
2013-05-17 13:35   ` Mel Gorman [this message]
2013-05-20 21:55 ` [RFCv2][PATCH 0/5] mm: Batch page reclamation under shink_page_list Seth Jennings

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=20130517133527.GM11497@suse.de \
    --to=mgorman@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=dave@sr71.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tim.c.chen@linux.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;
as well as URLs for NNTP newsgroup(s).