mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ira Weiny <ira.weiny@intel.com>
To: Prathu Baronia <prathubaronia2011@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, chintan.pandya@oneplus.com,
	Prathu Baronia <prathu.baronia@oneplus.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH v4 1/1] mm/highmem: Remove deprecated kmap_atomic
Date: Wed, 10 Feb 2021 16:33:07 -0800	[thread overview]
Message-ID: <20210211003307.GA3158182@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <20210204073255.20769-2-prathu.baronia@oneplus.com>

On Thu, Feb 04, 2021 at 01:02:53PM +0530, Prathu Baronia wrote:
> From: Ira Weiny <ira.weiny@intel.com>
> 
> kmap_atomic() is being deprecated in favor of kmap_local_page().
> 
> Replace the uses of kmap_atomic() within the highmem code.
> 
> On profiling clear_huge_page() using ftrace an improvement
> of 62% was observed on the below setup.
> 
> Setup:-
> Below data has been collected on Qualcomm's SM7250 SoC THP enabled
> (kernel v4.19.113) with only CPU-0(Cortex-A55) and CPU-7(Cortex-A76)
> switched on and set to max frequency, also DDR set to perf governor.
> 
> FTRACE Data:-
> 
> Base data:-
> Number of iterations: 48
> Mean of allocation time: 349.5 us
> std deviation: 74.5 us
> 
> v4 data:-
> Number of iterations: 48
> Mean of allocation time: 131 us
> std deviation: 32.7 us
> 
> The following simple userspace experiment to allocate
> 100MB(BUF_SZ) of pages and writing to it gave us a good insight,
> we observed an improvement of 42% in allocation and writing timings.
> -------------------------------------------------------------
> Test code snippet
> -------------------------------------------------------------
>       clock_start();
>       buf = malloc(BUF_SZ); /* Allocate 100 MB of memory */
> 
>         for(i=0; i < BUF_SZ_PAGES; i++)
>         {
>                 *((int *)(buf + (i*PAGE_SIZE))) = 1;
>         }
>       clock_end();
> -------------------------------------------------------------
> 
> Malloc test timings for 100MB anon allocation:-
> 
> Base data:-
> Number of iterations: 100
> Mean of allocation time: 31831 us
> std deviation: 4286 us
> 
> v4 data:-
> Number of iterations: 100
> Mean of allocation time: 18193 us
> std deviation: 4915 us
> 
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>

This already has my signed off by so I'm not going to 'review'.  With Prathu's
testing information I hope this can land.

Andrew did you see this patch?

Thanks,
Ira

> Signed-off-by: Prathu Baronia <prathu.baronia@oneplus.com>
> [Updated commit text with test data]
> ---
>  include/linux/highmem.h | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/include/linux/highmem.h b/include/linux/highmem.h
> index d2c70d3772a3..9a202c7e4e26 100644
> --- a/include/linux/highmem.h
> +++ b/include/linux/highmem.h
> @@ -146,9 +146,9 @@ static inline void invalidate_kernel_vmap_range(void *vaddr, int size)
>  #ifndef clear_user_highpage
>  static inline void clear_user_highpage(struct page *page, unsigned long vaddr)
>  {
> -	void *addr = kmap_atomic(page);
> +	void *addr = kmap_local_page(page);
>  	clear_user_page(addr, vaddr, page);
> -	kunmap_atomic(addr);
> +	kunmap_local(addr);
>  }
>  #endif
>  
> @@ -199,9 +199,9 @@ alloc_zeroed_user_highpage_movable(struct vm_area_struct *vma,
>  
>  static inline void clear_highpage(struct page *page)
>  {
> -	void *kaddr = kmap_atomic(page);
> +	void *kaddr = kmap_local_page(page);
>  	clear_page(kaddr);
> -	kunmap_atomic(kaddr);
> +	kunmap_local(kaddr);
>  }
>  
>  /*
> @@ -216,7 +216,7 @@ static inline void zero_user_segments(struct page *page,
>  		unsigned start1, unsigned end1,
>  		unsigned start2, unsigned end2)
>  {
> -	void *kaddr = kmap_atomic(page);
> +	void *kaddr = kmap_local_page(page);
>  	unsigned int i;
>  
>  	BUG_ON(end1 > page_size(page) || end2 > page_size(page));
> @@ -227,7 +227,7 @@ static inline void zero_user_segments(struct page *page,
>  	if (end2 > start2)
>  		memset(kaddr + start2, 0, end2 - start2);
>  
> -	kunmap_atomic(kaddr);
> +	kunmap_local(kaddr);
>  	for (i = 0; i < compound_nr(page); i++)
>  		flush_dcache_page(page + i);
>  }
> @@ -252,11 +252,11 @@ static inline void copy_user_highpage(struct page *to, struct page *from,
>  {
>  	char *vfrom, *vto;
>  
> -	vfrom = kmap_atomic(from);
> -	vto = kmap_atomic(to);
> +	vfrom = kmap_local_page(from);
> +	vto = kmap_local_page(to);
>  	copy_user_page(vto, vfrom, vaddr, to);
> -	kunmap_atomic(vto);
> -	kunmap_atomic(vfrom);
> +	kunmap_local(vto);
> +	kunmap_local(vfrom);
>  }
>  
>  #endif
> @@ -267,11 +267,11 @@ static inline void copy_highpage(struct page *to, struct page *from)
>  {
>  	char *vfrom, *vto;
>  
> -	vfrom = kmap_atomic(from);
> -	vto = kmap_atomic(to);
> +	vfrom = kmap_local_page(from);
> +	vto = kmap_local_page(to);
>  	copy_page(vto, vfrom);
> -	kunmap_atomic(vto);
> -	kunmap_atomic(vfrom);
> +	kunmap_local(vto);
> +	kunmap_local(vfrom);
>  }
>  
>  #endif
> -- 
> 2.17.1
> 

  reply	other threads:[~2021-02-11  0:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04  7:32 [PATCH v4 0/1] " Prathu Baronia
2021-02-04  7:32 ` [PATCH v4 1/1] " Prathu Baronia
2021-02-11  0:33   ` Ira Weiny [this message]
2021-02-11 23:56     ` Andrew Morton
2021-11-05 13:49       ` Matthew Wilcox
2021-11-05 16:51         ` Matthew Wilcox
2021-11-05 16:58           ` Ira Weiny
2021-11-05 17:23             ` Matthew Wilcox
2021-11-05 18:38               ` Ira Weiny
2021-11-08 10:12                 ` Prathu Baronia
2021-11-05 16:56         ` Ira Weiny
2021-11-05 17:35           ` Matthew Wilcox

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=20210211003307.GA3158182@iweiny-DESK2.sc.intel.com \
    --to=ira.weiny@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=chintan.pandya@oneplus.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=prathu.baronia@oneplus.com \
    --cc=prathubaronia2011@gmail.com \
    --cc=rdunlap@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=willy@infradead.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

all inboxes | Powered by JetHome®