diff mbox series

[v3,30/34] mm: Use flush_icache_pages() in do_set_pmd()

Message ID 20230228213738.272178-31-willy@infradead.org (mailing list archive)
State New
Headers show
Series New page table range API | expand

Commit Message

Matthew Wilcox Feb. 28, 2023, 9:37 p.m. UTC
Push the iteration over each page down to the architectures (many
can flush the entire THP without iteration).

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/memory.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Mike Rapoport March 3, 2023, 2:02 p.m. UTC | #1
On Tue, Feb 28, 2023 at 09:37:33PM +0000, Matthew Wilcox (Oracle) wrote:
> Push the iteration over each page down to the architectures (many
> can flush the entire THP without iteration).
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  mm/memory.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index bfa3100ec5a3..69e844d5f75c 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -4222,8 +4222,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
>  	if (unlikely(!pmd_none(*vmf->pmd)))
>  		goto out;
>  
> -	for (i = 0; i < HPAGE_PMD_NR; i++)
> -		flush_icache_page(vma, page + i);
> +	flush_icache_pages(vma, page, HPAGE_PMD_NR);
>  
>  	entry = mk_huge_pmd(page, vma->vm_page_prot);
>  	if (write)
> -- 
> 2.39.1

I get this:

  CC      mm/memory.o
/home/mike/git/linux/mm/memory.c: In function 'do_set_pmd':
/home/mike/git/linux/mm/memory.c:4191:13: warning: unused variable 'i' [-Wunused-variable]
 4191 |         int i;
      |             ^

And the patch here makes it go away:

diff --git a/mm/memory.c b/mm/memory.c
index cc7845ff09ba..c359fb8643e5 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4188,7 +4188,6 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
 	bool write = vmf->flags & FAULT_FLAG_WRITE;
 	unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
 	pmd_t entry;
-	int i;
 	vm_fault_t ret = VM_FAULT_FALLBACK;
 
 	if (!transhuge_vma_suitable(vma, haddr))
Matthew Wilcox March 3, 2023, 4:02 p.m. UTC | #2
On Fri, Mar 03, 2023 at 04:02:01PM +0200, Mike Rapoport wrote:
> On Tue, Feb 28, 2023 at 09:37:33PM +0000, Matthew Wilcox (Oracle) wrote:
> > Push the iteration over each page down to the architectures (many
> > can flush the entire THP without iteration).
> > 
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > ---
> >  mm/memory.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/mm/memory.c b/mm/memory.c
> > index bfa3100ec5a3..69e844d5f75c 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -4222,8 +4222,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
> >  	if (unlikely(!pmd_none(*vmf->pmd)))
> >  		goto out;
> >  
> > -	for (i = 0; i < HPAGE_PMD_NR; i++)
> > -		flush_icache_page(vma, page + i);
> > +	flush_icache_pages(vma, page, HPAGE_PMD_NR);
> >  
> >  	entry = mk_huge_pmd(page, vma->vm_page_prot);
> >  	if (write)
> > -- 
> > 2.39.1
> 
> I get this:
> 
>   CC      mm/memory.o
> /home/mike/git/linux/mm/memory.c: In function 'do_set_pmd':
> /home/mike/git/linux/mm/memory.c:4191:13: warning: unused variable 'i' [-Wunused-variable]
>  4191 |         int i;

Yep, caught that one last night.  My build test must have been with a
config that didn't include THP.  Thanks.
diff mbox series

Patch

diff --git a/mm/memory.c b/mm/memory.c
index bfa3100ec5a3..69e844d5f75c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4222,8 +4222,7 @@  vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
 	if (unlikely(!pmd_none(*vmf->pmd)))
 		goto out;
 
-	for (i = 0; i < HPAGE_PMD_NR; i++)
-		flush_icache_page(vma, page + i);
+	flush_icache_pages(vma, page, HPAGE_PMD_NR);
 
 	entry = mk_huge_pmd(page, vma->vm_page_prot);
 	if (write)