mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Eric Dumazet <edumazet@google.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] iov_iter: optimize page_copy_sane()
Date: Mon, 17 Dec 2018 06:42:50 -0800	[thread overview]
Message-ID: <0d6058b9-8123-6d8c-0571-6ea9a5cd822d@gmail.com> (raw)
In-Reply-To: <20181208133735.245799-1-edumazet@google.com>



On 12/08/2018 05:37 AM, Eric Dumazet wrote:
> Avoid cache line miss dereferencing struct page if we can.
> 
> page_copy_sane() mostly deals with order-0 pages.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> ---
>  lib/iov_iter.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 54c248526b55fc498c996f2a5ea651262fcc7f61..2a1e282c3d38e2d03b075f54b7f9313e48b90289 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -854,8 +854,18 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocache);
>  
>  static inline bool page_copy_sane(struct page *page, size_t offset, size_t n)
>  {
> -	struct page *head = compound_head(page);
> -	size_t v = n + offset + page_address(page) - page_address(head);
> +	struct page *head;
> +	size_t v = n + offset;
> +
> +	/*
> +	 * Fast path if this is an order-0 page,
> +	 * or if the copied area fits the first page of a compound one.
> +	 */
> +	if (likely(n <= v && v <= PAGE_SIZE))
> +		return true;
> +
> +	head = compound_head(page);
> +	v += (page - head) << PAGE_SHIFT;
>  
>  	if (likely(n <= v && v <= (PAGE_SIZE << compound_order(head))))
>  		return true;
> 

Hi Alexander !

Any news on this patch ?

Thanks !

      reply	other threads:[~2018-12-17 14:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-08 13:37 Eric Dumazet
2018-12-17 14:42 ` Eric Dumazet [this message]

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=0d6058b9-8123-6d8c-0571-6ea9a5cd822d@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®