linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Colin Ian King <colin.i.king@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] mm/mincore: improve performance by adding an unlikely hint
Date: Mon, 17 Feb 2025 17:58:12 +0000	[thread overview]
Message-ID: <Z7N4tLUpRA1EKfDm@casper.infradead.org> (raw)
In-Reply-To: <20250217170934.457266-1-colin.i.king@gmail.com>

On Mon, Feb 17, 2025 at 05:09:34PM +0000, Colin Ian King wrote:
> Adding an unlikely() hint on the masked start comparison error
> return path improves run-time performance of the mincore system call.
> 
> Benchmarking on an i9-12900 shows an improvement of 7ns on mincore calls
> on a 256KB mmap'd region where 50% of the pages we resident.
> 
> Results based on running 20 tests with turbo disabled (to reduce
> clock freq turbo changes), with 10 second run per test and comparing
> the number of mincores calls per second. The % standard deviation of
> the 20 tests was ~0.10%, so results are reliable.

I think you've elided _just_ enough information here that nobody can
judge whether your stats skills are any good ;-)  You've told us 7ns
(per call, presumably) and you've told us 0.10% standard deviation,
but you haven't told us how long the syscall takes, so nobody can tell
whether 7ns is within 0.10% or not ;-)

> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  mm/mincore.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/mincore.c b/mm/mincore.c
> index d6bd19e520fc..832f29f46767 100644
> --- a/mm/mincore.c
> +++ b/mm/mincore.c
> @@ -239,7 +239,7 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
>  	start = untagged_addr(start);
>  
>  	/* Check the start address: needs to be page-aligned.. */
> -	if (start & ~PAGE_MASK)
> +	if (unlikely(start & ~PAGE_MASK))
>  		return -EINVAL;

We might get even more advantage by moving the EINVAL test before
untagged_addr() since we know that the tags are all in the high bits and
we don't need to have the test be dependent on the previous arithmetic.


  reply	other threads:[~2025-02-17 17:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17 17:09 Colin Ian King
2025-02-17 17:58 ` Matthew Wilcox [this message]
2025-02-17 18:00   ` Colin King (gmail)
2025-02-18  3:13     ` Andrew Morton
2025-02-18 14:16       ` Colin King (gmail)
2025-02-19  0:08         ` Andrew Morton

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=Z7N4tLUpRA1EKfDm@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=colin.i.king@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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