All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@nxp.com>
To: Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>,
	Christoph Lameter <cl@linux.com>
Cc: Vlad Buslov <vladbu@mellanox.com>,
	"kernel-team@fb.com" <kernel-team@fb.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 12/12] percpu: use chunk scan_hint to skip some scanning
Date: Sun, 3 Mar 2019 08:38:22 +0000	[thread overview]
Message-ID: <AM0PR04MB4481EA4F39764CD4E6D4D43788700@AM0PR04MB4481.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20190228021839.55779-13-dennis@kernel.org>



> -----Original Message-----
> From: owner-linux-mm@kvack.org [mailto:owner-linux-mm@kvack.org] On
> Behalf Of Dennis Zhou
> Sent: 2019年2月28日 10:19
> To: Dennis Zhou <dennis@kernel.org>; Tejun Heo <tj@kernel.org>; Christoph
> Lameter <cl@linux.com>
> Cc: Vlad Buslov <vladbu@mellanox.com>; kernel-team@fb.com;
> linux-mm@kvack.org; linux-kernel@vger.kernel.org
> Subject: [PATCH 12/12] percpu: use chunk scan_hint to skip some scanning
> 
> Just like blocks, chunks now maintain a scan_hint. This can be used to skip
> some scanning by promoting the scan_hint to be the contig_hint.
> The chunk's scan_hint is primarily updated on the backside and relies on full
> scanning when a block becomes free or the free region spans across blocks.
> 
> Signed-off-by: Dennis Zhou <dennis@kernel.org>
> ---
>  mm/percpu.c | 36 +++++++++++++++++++++++++++---------
>  1 file changed, 27 insertions(+), 9 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index 197479f2c489..40d49d7fb286 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -711,20 +711,31 @@ static void pcpu_block_update_scan(struct
> pcpu_chunk *chunk, int bit_off,
>  /**
>   * pcpu_chunk_refresh_hint - updates metadata about a chunk
>   * @chunk: chunk of interest
> + * @full_scan: if we should scan from the beginning
>   *
>   * Iterates over the metadata blocks to find the largest contig area.
> - * It also counts the populated pages and uses the delta to update the
> - * global count.
> + * A full scan can be avoided on the allocation path as this is
> + triggered
> + * if we broke the contig_hint.  In doing so, the scan_hint will be
> + before
> + * the contig_hint or after if the scan_hint == contig_hint.  This
> + cannot
> + * be prevented on freeing as we want to find the largest area possibly
> + * spanning blocks.
>   */
> -static void pcpu_chunk_refresh_hint(struct pcpu_chunk *chunk)
> +static void pcpu_chunk_refresh_hint(struct pcpu_chunk *chunk, bool
> +full_scan)
>  {
>  	struct pcpu_block_md *chunk_md = &chunk->chunk_md;
>  	int bit_off, bits;
> 
> -	/* clear metadata */
> -	chunk_md->contig_hint = 0;
> +	/* promote scan_hint to contig_hint */
> +	if (!full_scan && chunk_md->scan_hint) {
> +		bit_off = chunk_md->scan_hint_start + chunk_md->scan_hint;
> +		chunk_md->contig_hint_start = chunk_md->scan_hint_start;
> +		chunk_md->contig_hint = chunk_md->scan_hint;
> +		chunk_md->scan_hint = 0;
> +	} else {
> +		bit_off = chunk_md->first_free;
> +		chunk_md->contig_hint = 0;
> +	}
> 
> -	bit_off = chunk_md->first_free;
>  	bits = 0;
>  	pcpu_for_each_md_free_region(chunk, bit_off, bits) {
>  		pcpu_block_update(chunk_md, bit_off, bit_off + bits); @@ -884,6
> +895,13 @@ static void pcpu_block_update_hint_alloc(struct pcpu_chunk
> *chunk, int bit_off,
>  	if (nr_empty_pages)
>  		pcpu_update_empty_pages(chunk, -1 * nr_empty_pages);
> 
> +	if (pcpu_region_overlap(chunk_md->scan_hint_start,
> +				chunk_md->scan_hint_start +
> +				chunk_md->scan_hint,
> +				bit_off,
> +				bit_off + bits))
> +		chunk_md->scan_hint = 0;
> +
>  	/*
>  	 * The only time a full chunk scan is required is if the chunk
>  	 * contig hint is broken.  Otherwise, it means a smaller space @@
> -894,7 +912,7 @@ static void pcpu_block_update_hint_alloc(struct
> pcpu_chunk *chunk, int bit_off,
>  				chunk_md->contig_hint,
>  				bit_off,
>  				bit_off + bits))
> -		pcpu_chunk_refresh_hint(chunk);
> +		pcpu_chunk_refresh_hint(chunk, false);
>  }
> 
>  /**
> @@ -1005,7 +1023,7 @@ static void pcpu_block_update_hint_free(struct
> pcpu_chunk *chunk, int bit_off,
>  	 * the else condition below.
>  	 */
>  	if (((end - start) >= PCPU_BITMAP_BLOCK_BITS) || s_index != e_index)
> -		pcpu_chunk_refresh_hint(chunk);
> +		pcpu_chunk_refresh_hint(chunk, true);
>  	else
>  		pcpu_block_update(&chunk->chunk_md,
>  				  pcpu_block_off_to_off(s_index, start), @@ -1078,7
> +1096,7 @@ static int pcpu_find_block_fit(struct pcpu_chunk *chunk, int
> alloc_bits,
>  	if (bit_off + alloc_bits > chunk_md->contig_hint)
>  		return -1;
> 
> -	bit_off = chunk_md->first_free;
> +	bit_off = pcpu_next_hint(chunk_md, alloc_bits);
>  	bits = 0;
>  	pcpu_for_each_fit_region(chunk, alloc_bits, align, bit_off, bits) {
>  		if (!pop_only || pcpu_is_populated(chunk, bit_off, bits,

Reviewed-by: Peng Fan <peng.fan@nxp.com>

> --
> 2.17.1


  reply	other threads:[~2019-03-03  8:41 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28  2:18 [PATCH 00/12] introduce percpu block scan_hint Dennis Zhou
2019-02-28  2:18 ` [PATCH 01/12] percpu: update free path with correct new free region Dennis Zhou
2019-03-02 12:56   ` Peng Fan
2019-02-28  2:18 ` [PATCH 02/12] percpu: do not search past bitmap when allocating an area Dennis Zhou
2019-03-02 13:32   ` Peng Fan
2019-03-02 22:23     ` Dennis Zhou
2019-03-03  8:41       ` Peng Fan
2019-02-28  2:18 ` [PATCH 03/12] percpu: introduce helper to determine if two regions overlap Dennis Zhou
2019-03-02 13:37   ` Peng Fan
2019-03-02 22:24     ` Dennis Zhou
2019-02-28  2:18 ` [PATCH 04/12] percpu: manage chunks based on contig_bits instead of free_bytes Dennis Zhou
2019-03-02 13:48   ` Peng Fan
2019-03-02 22:32     ` Dennis Zhou
2019-03-03  8:42       ` Peng Fan
2019-02-28  2:18 ` [PATCH 05/12] percpu: relegate chunks unusable when failing small allocations Dennis Zhou
2019-03-02 13:55   ` Peng Fan
2019-03-02 22:34     ` Dennis Zhou
2019-02-28  2:18 ` [PATCH 06/12] percpu: set PCPU_BITMAP_BLOCK_SIZE to PAGE_SIZE Dennis Zhou
2019-03-03  4:56   ` Peng Fan
2019-02-28  2:18 ` [PATCH 07/12] percpu: add block level scan_hint Dennis Zhou
2019-03-03  6:01   ` Peng Fan
2019-03-03 20:23     ` Dennis Zhou
2019-03-04  9:36       ` Peng Fan
2019-02-28  2:18 ` [PATCH 08/12] percpu: remember largest area skipped during allocation Dennis Zhou
2019-02-28  2:18 ` [PATCH 09/12] percpu: use block scan_hint to only scan forward Dennis Zhou
2019-02-28  2:18 ` [PATCH 10/12] percpu: make pcpu_block_md generic Dennis Zhou
2019-03-03  6:35   ` Peng Fan
2019-02-28  2:18 ` [PATCH 11/12] percpu: convert chunk hints to be based on pcpu_block_md Dennis Zhou
2019-03-03  8:18   ` Peng Fan
2019-03-03 20:22     ` Dennis Zhou
2019-03-04  6:36       ` Peng Fan
2019-02-28  2:18 ` [PATCH 12/12] percpu: use chunk scan_hint to skip some scanning Dennis Zhou
2019-03-03  8:38   ` Peng Fan [this message]
2019-02-28 14:47 ` [PATCH 00/12] introduce percpu block scan_hint Vlad Buslov
2019-03-13 20:19 ` Dennis Zhou

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=AM0PR04MB4481EA4F39764CD4E6D4D43788700@AM0PR04MB4481.eurprd04.prod.outlook.com \
    --to=peng.fan@nxp.com \
    --cc=cl@linux.com \
    --cc=dennis@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tj@kernel.org \
    --cc=vladbu@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.