linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] thp: clean up __collapse_huge_page_isolate
@ 2012-10-23  6:50 Bob Liu
  2012-10-23  6:54 ` Ni zhan Chen
  2012-10-24 22:43 ` David Rientjes
  0 siblings, 2 replies; 3+ messages in thread
From: Bob Liu @ 2012-10-23  6:50 UTC (permalink / raw)
  To: akpm
  Cc: aarcange, hughd, rientjes, xiaoguangrong, kirill.shutemov,
	linux-mm, Bob Liu

There are duplicated place using release_pte_pages().
And release_all_pte_pages() can also be removed.

v2: mv label out of condition.

Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
 mm/huge_memory.c |   38 +++++++++++---------------------------
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index a863af2..96a2ccc 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1700,64 +1700,49 @@ static void release_pte_pages(pte_t *pte, pte_t *_pte)
 	}
 }
 
-static void release_all_pte_pages(pte_t *pte)
-{
-	release_pte_pages(pte, pte + HPAGE_PMD_NR);
-}
-
 static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
 					unsigned long address,
 					pte_t *pte)
 {
 	struct page *page;
 	pte_t *_pte;
-	int referenced = 0, isolated = 0, none = 0;
+	int referenced = 0, none = 0;
 	for (_pte = pte; _pte < pte+HPAGE_PMD_NR;
 	     _pte++, address += PAGE_SIZE) {
 		pte_t pteval = *_pte;
 		if (pte_none(pteval)) {
 			if (++none <= khugepaged_max_ptes_none)
 				continue;
-			else {
-				release_pte_pages(pte, _pte);
+			else
 				goto out;
-			}
 		}
-		if (!pte_present(pteval) || !pte_write(pteval)) {
-			release_pte_pages(pte, _pte);
+		if (!pte_present(pteval) || !pte_write(pteval))
 			goto out;
-		}
 		page = vm_normal_page(vma, address, pteval);
-		if (unlikely(!page)) {
-			release_pte_pages(pte, _pte);
+		if (unlikely(!page))
 			goto out;
-		}
+
 		VM_BUG_ON(PageCompound(page));
 		BUG_ON(!PageAnon(page));
 		VM_BUG_ON(!PageSwapBacked(page));
 
 		/* cannot use mapcount: can't collapse if there's a gup pin */
-		if (page_count(page) != 1) {
-			release_pte_pages(pte, _pte);
+		if (page_count(page) != 1)
 			goto out;
-		}
 		/*
 		 * We can do it before isolate_lru_page because the
 		 * page can't be freed from under us. NOTE: PG_lock
 		 * is needed to serialize against split_huge_page
 		 * when invoked from the VM.
 		 */
-		if (!trylock_page(page)) {
-			release_pte_pages(pte, _pte);
+		if (!trylock_page(page))
 			goto out;
-		}
 		/*
 		 * Isolate the page to avoid collapsing an hugepage
 		 * currently in use by the VM.
 		 */
 		if (isolate_lru_page(page)) {
 			unlock_page(page);
-			release_pte_pages(pte, _pte);
 			goto out;
 		}
 		/* 0 stands for page_is_file_cache(page) == false */
@@ -1770,12 +1755,11 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
 		    mmu_notifier_test_young(vma->vm_mm, address))
 			referenced = 1;
 	}
-	if (unlikely(!referenced))
-		release_all_pte_pages(pte);
-	else
-		isolated = 1;
+	if (likely(referenced))
+		return 1;
 out:
-	return isolated;
+	release_pte_pages(pte, _pte);
+	return 0;
 }
 
 static void __collapse_huge_page_copy(pte_t *pte, struct page *page,
-- 
1.7.9.5


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] thp: clean up __collapse_huge_page_isolate
  2012-10-23  6:50 [PATCH v2] thp: clean up __collapse_huge_page_isolate Bob Liu
@ 2012-10-23  6:54 ` Ni zhan Chen
  2012-10-24 22:43 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: Ni zhan Chen @ 2012-10-23  6:54 UTC (permalink / raw)
  To: Bob Liu
  Cc: akpm, aarcange, hughd, rientjes, xiaoguangrong, kirill.shutemov,
	linux-mm

On 10/23/2012 02:50 PM, Bob Liu wrote:
> There are duplicated place using release_pte_pages().
> And release_all_pte_pages() can also be removed.
>
> v2: mv label out of condition.

it seems that the first version has already merged in linux-mm

>
> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> ---
>   mm/huge_memory.c |   38 +++++++++++---------------------------
>   1 file changed, 11 insertions(+), 27 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index a863af2..96a2ccc 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1700,64 +1700,49 @@ static void release_pte_pages(pte_t *pte, pte_t *_pte)
>   	}
>   }
>   
> -static void release_all_pte_pages(pte_t *pte)
> -{
> -	release_pte_pages(pte, pte + HPAGE_PMD_NR);
> -}
> -
>   static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
>   					unsigned long address,
>   					pte_t *pte)
>   {
>   	struct page *page;
>   	pte_t *_pte;
> -	int referenced = 0, isolated = 0, none = 0;
> +	int referenced = 0, none = 0;
>   	for (_pte = pte; _pte < pte+HPAGE_PMD_NR;
>   	     _pte++, address += PAGE_SIZE) {
>   		pte_t pteval = *_pte;
>   		if (pte_none(pteval)) {
>   			if (++none <= khugepaged_max_ptes_none)
>   				continue;
> -			else {
> -				release_pte_pages(pte, _pte);
> +			else
>   				goto out;
> -			}
>   		}
> -		if (!pte_present(pteval) || !pte_write(pteval)) {
> -			release_pte_pages(pte, _pte);
> +		if (!pte_present(pteval) || !pte_write(pteval))
>   			goto out;
> -		}
>   		page = vm_normal_page(vma, address, pteval);
> -		if (unlikely(!page)) {
> -			release_pte_pages(pte, _pte);
> +		if (unlikely(!page))
>   			goto out;
> -		}
> +
>   		VM_BUG_ON(PageCompound(page));
>   		BUG_ON(!PageAnon(page));
>   		VM_BUG_ON(!PageSwapBacked(page));
>   
>   		/* cannot use mapcount: can't collapse if there's a gup pin */
> -		if (page_count(page) != 1) {
> -			release_pte_pages(pte, _pte);
> +		if (page_count(page) != 1)
>   			goto out;
> -		}
>   		/*
>   		 * We can do it before isolate_lru_page because the
>   		 * page can't be freed from under us. NOTE: PG_lock
>   		 * is needed to serialize against split_huge_page
>   		 * when invoked from the VM.
>   		 */
> -		if (!trylock_page(page)) {
> -			release_pte_pages(pte, _pte);
> +		if (!trylock_page(page))
>   			goto out;
> -		}
>   		/*
>   		 * Isolate the page to avoid collapsing an hugepage
>   		 * currently in use by the VM.
>   		 */
>   		if (isolate_lru_page(page)) {
>   			unlock_page(page);
> -			release_pte_pages(pte, _pte);
>   			goto out;
>   		}
>   		/* 0 stands for page_is_file_cache(page) == false */
> @@ -1770,12 +1755,11 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
>   		    mmu_notifier_test_young(vma->vm_mm, address))
>   			referenced = 1;
>   	}
> -	if (unlikely(!referenced))
> -		release_all_pte_pages(pte);
> -	else
> -		isolated = 1;
> +	if (likely(referenced))
> +		return 1;
>   out:
> -	return isolated;
> +	release_pte_pages(pte, _pte);
> +	return 0;
>   }
>   
>   static void __collapse_huge_page_copy(pte_t *pte, struct page *page,

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] thp: clean up __collapse_huge_page_isolate
  2012-10-23  6:50 [PATCH v2] thp: clean up __collapse_huge_page_isolate Bob Liu
  2012-10-23  6:54 ` Ni zhan Chen
@ 2012-10-24 22:43 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2012-10-24 22:43 UTC (permalink / raw)
  To: Bob Liu; +Cc: akpm, aarcange, hughd, xiaoguangrong, kirill.shutemov, linux-mm

On Tue, 23 Oct 2012, Bob Liu wrote:

> There are duplicated place using release_pte_pages().
> And release_all_pte_pages() can also be removed.
> 
> v2: mv label out of condition.
> 
> Signed-off-by: Bob Liu <lliubbo@gmail.com>

Acked-by: David Rientjes <rientjes@google.com>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-24 22:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-23  6:50 [PATCH v2] thp: clean up __collapse_huge_page_isolate Bob Liu
2012-10-23  6:54 ` Ni zhan Chen
2012-10-24 22:43 ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).