Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1706468

Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page

From Matthew Wilcox <willy@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page
Date 2017-08-08 14:20 +0200
Message-ID <ucbEm-8gS-5@gated-at.bofh.it> (permalink)
References <ubKE9-5de-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Aug 07, 2017 at 03:21:31PM +0800, Huang, Ying wrote:
> @@ -2509,7 +2509,8 @@ enum mf_action_page_type {
>  #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS)
>  extern void clear_huge_page(struct page *page,
>  			    unsigned long addr,
> -			    unsigned int pages_per_huge_page);
> +			    unsigned int pages_per_huge_page,
> +			    unsigned long addr_hint);

I don't really like adding the extra argument to this function ...

> +++ b/mm/huge_memory.c
> @@ -549,7 +549,8 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
>  	struct vm_area_struct *vma = vmf->vma;
>  	struct mem_cgroup *memcg;
>  	pgtable_t pgtable;
> -	unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
> +	unsigned long address = vmf->address;
> +	unsigned long haddr = address & HPAGE_PMD_MASK;
>  
>  	VM_BUG_ON_PAGE(!PageCompound(page), page);
>  
> @@ -566,7 +567,7 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
>  		return VM_FAULT_OOM;
>  	}
>  
> -	clear_huge_page(page, haddr, HPAGE_PMD_NR);
> +	clear_huge_page(page, haddr, HPAGE_PMD_NR, address);
>  	/*
>  	 * The memory barrier inside __SetPageUptodate makes sure that
>  	 * clear_huge_page writes become visible before the set_pmd_at()

How about calling:

-	clear_huge_page(page, haddr, HPAGE_PMD_NR);
+	clear_huge_page(page, address, HPAGE_PMD_NR);

> +++ b/mm/memory.c
> @@ -4363,10 +4363,10 @@ static void clear_gigantic_page(struct page *page,
>  		clear_user_highpage(p, addr + i * PAGE_SIZE);
>  	}
>  }
> -void clear_huge_page(struct page *page,
> -		     unsigned long addr, unsigned int pages_per_huge_page)
> +void clear_huge_page(struct page *page, unsigned long addr,
> +		     unsigned int pages_per_huge_page, unsigned long addr_hint)
>  {
> -	int i;
> +	int i, n, base, l;
>  
>  	if (unlikely(pages_per_huge_page > MAX_ORDER_NR_PAGES)) {
>  		clear_gigantic_page(page, addr, pages_per_huge_page);

... and doing this:

 void clear_huge_page(struct page *page,
-		     unsigned long addr, unsigned int pages_per_huge_page)
+		     unsigned long addr_hint, unsigned int pages_per_huge_page)
 {
-	int i;
+	int i, n, base, l;
+	unsigned long addr = addr_hint &
+				(1UL << (pages_per_huge_page + PAGE_SHIFT));

> @@ -4374,9 +4374,31 @@ void clear_huge_page(struct page *page,
>  	}
>  
>  	might_sleep();
> -	for (i = 0; i < pages_per_huge_page; i++) {
> +	VM_BUG_ON(clamp(addr_hint, addr, addr +
> +			(pages_per_huge_page << PAGE_SHIFT)) != addr_hint);

... then you can ditch this check

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH -mm] mm: Clear to access sub-page last when clearing huge page "Huang, Ying" <ying.huang@intel.com> - 2017-08-07 09:30 +0200
  Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge  page Jan Kara <jack@suse.cz> - 2017-08-07 12:00 +0200
    Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page "Huang\, Ying" <ying.huang@intel.com> - 2017-08-07 12:10 +0200
  Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge  page "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-08-07 12:20 +0200
    Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page "Huang\, Ying" <ying.huang@intel.com> - 2017-08-08 01:00 +0200
      Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page "Huang\, Ying" <ying.huang@intel.com> - 2017-08-08 09:50 +0200
  Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge  page Christopher Lameter <cl@linux.com> - 2017-08-07 20:50 +0200
    Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page "Huang\, Ying" <ying.huang@intel.com> - 2017-08-08 01:10 +0200
    Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page "Huang\, Ying" <ying.huang@intel.com> - 2017-08-08 08:30 +0200
  Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge  page Mike Kravetz <mike.kravetz@oracle.com> - 2017-08-08 06:10 +0200
    Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page "Huang\, Ying" <ying.huang@intel.com> - 2017-08-08 06:30 +0200
  Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge  page Matthew Wilcox <willy@infradead.org> - 2017-08-08 14:20 +0200
    Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page "Huang\, Ying" <ying.huang@intel.com> - 2017-08-09 01:10 +0200
  Re: [PATCH -mm] mm: Clear to access sub-page last when clearing  huge page Andrew Morton <akpm@linux-foundation.org> - 2017-08-09 23:30 +0200
    Re: [PATCH -mm] mm: Clear to access sub-page last when clearing huge page "Huang\, Ying" <ying.huang@intel.com> - 2017-08-10 03:00 +0200

csiph-web