All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Cleanup for khugepaged
@ 2021-03-25 13:56 Miaohe Lin
  2021-03-25 13:56 ` [PATCH 1/3] khugepaged: use helper function range_in_vma() in collapse_pte_mapped_thp() Miaohe Lin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Miaohe Lin @ 2021-03-25 13:56 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, linux-mm, linmiaohe

Hi all,
This series contains cleanups to remove unnecessary out label and
meaningless !pte_present() check. Also use helper function to simplify
the code. More details can be found in the respective changelogs.
Thanks!

Miaohe Lin (3):
  khugepaged: use helper function range_in_vma() in
    collapse_pte_mapped_thp()
  khugepaged: remove unnecessary out label in collapse_huge_page()
  khugepaged: remove meaningless !pte_present() check in
    khugepaged_scan_pmd()

 mm/khugepaged.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

-- 
2.19.1


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

* [PATCH 1/3] khugepaged: use helper function range_in_vma() in collapse_pte_mapped_thp()
  2021-03-25 13:56 [PATCH 0/3] Cleanup for khugepaged Miaohe Lin
@ 2021-03-25 13:56 ` Miaohe Lin
  2021-03-25 13:56 ` [PATCH 2/3] khugepaged: remove unnecessary out label in collapse_huge_page() Miaohe Lin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Miaohe Lin @ 2021-03-25 13:56 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, linux-mm, linmiaohe

We could use helper function range_in_vma() to check whether the desired
range is inside the vma to simplify the code.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/khugepaged.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index b81521dfbb1a..ad0444f3f487 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1446,7 +1446,7 @@ void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr)
 	int i;
 
 	if (!vma || !vma->vm_file ||
-	    vma->vm_start > haddr || vma->vm_end < haddr + HPAGE_PMD_SIZE)
+	    !range_in_vma(vma, haddr, haddr + HPAGE_PMD_SIZE))
 		return;
 
 	/*
-- 
2.19.1


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

* [PATCH 2/3] khugepaged: remove unnecessary out label in collapse_huge_page()
  2021-03-25 13:56 [PATCH 0/3] Cleanup for khugepaged Miaohe Lin
  2021-03-25 13:56 ` [PATCH 1/3] khugepaged: use helper function range_in_vma() in collapse_pte_mapped_thp() Miaohe Lin
@ 2021-03-25 13:56 ` Miaohe Lin
  2021-03-25 13:56 ` [PATCH 3/3] khugepaged: remove meaningless !pte_present() check in khugepaged_scan_pmd() Miaohe Lin
  2021-03-25 14:21 ` [PATCH 0/3] Cleanup for khugepaged Zi Yan
  3 siblings, 0 replies; 5+ messages in thread
From: Miaohe Lin @ 2021-03-25 13:56 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, linux-mm, linmiaohe

The out label here is unneeded because it just goes to out_up_write label.
Remove it to make code more concise.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/khugepaged.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index ad0444f3f487..58466af69e70 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1128,10 +1128,10 @@ static void collapse_huge_page(struct mm_struct *mm,
 	mmap_write_lock(mm);
 	result = hugepage_vma_revalidate(mm, address, &vma);
 	if (result)
-		goto out;
+		goto out_up_write;
 	/* check if the pmd is still valid */
 	if (mm_find_pmd(mm, address) != pmd)
-		goto out;
+		goto out_up_write;
 
 	anon_vma_lock_write(vma->anon_vma);
 
@@ -1171,7 +1171,7 @@ static void collapse_huge_page(struct mm_struct *mm,
 		spin_unlock(pmd_ptl);
 		anon_vma_unlock_write(vma->anon_vma);
 		result = SCAN_FAIL;
-		goto out;
+		goto out_up_write;
 	}
 
 	/*
@@ -1215,8 +1215,6 @@ static void collapse_huge_page(struct mm_struct *mm,
 		mem_cgroup_uncharge(*hpage);
 	trace_mm_collapse_huge_page(mm, isolated, result);
 	return;
-out:
-	goto out_up_write;
 }
 
 static int khugepaged_scan_pmd(struct mm_struct *mm,
-- 
2.19.1


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

* [PATCH 3/3] khugepaged: remove meaningless !pte_present() check in khugepaged_scan_pmd()
  2021-03-25 13:56 [PATCH 0/3] Cleanup for khugepaged Miaohe Lin
  2021-03-25 13:56 ` [PATCH 1/3] khugepaged: use helper function range_in_vma() in collapse_pte_mapped_thp() Miaohe Lin
  2021-03-25 13:56 ` [PATCH 2/3] khugepaged: remove unnecessary out label in collapse_huge_page() Miaohe Lin
@ 2021-03-25 13:56 ` Miaohe Lin
  2021-03-25 14:21 ` [PATCH 0/3] Cleanup for khugepaged Zi Yan
  3 siblings, 0 replies; 5+ messages in thread
From: Miaohe Lin @ 2021-03-25 13:56 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, linux-mm, linmiaohe

We know it must meet the !is_swap_pte() and !pte_none() condition if we
reach here. Since !is_swap_pte() indicates pte_none() or pte_present()
is met, it's guaranteed that pte must be present here.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/khugepaged.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 58466af69e70..01c2d0ed9abd 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1271,10 +1271,6 @@ static int khugepaged_scan_pmd(struct mm_struct *mm,
 				goto out_unmap;
 			}
 		}
-		if (!pte_present(pteval)) {
-			result = SCAN_PTE_NON_PRESENT;
-			goto out_unmap;
-		}
 		if (pte_uffd_wp(pteval)) {
 			/*
 			 * Don't collapse the page if any of the small
-- 
2.19.1


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

* Re: [PATCH 0/3] Cleanup for khugepaged
  2021-03-25 13:56 [PATCH 0/3] Cleanup for khugepaged Miaohe Lin
                   ` (2 preceding siblings ...)
  2021-03-25 13:56 ` [PATCH 3/3] khugepaged: remove meaningless !pte_present() check in khugepaged_scan_pmd() Miaohe Lin
@ 2021-03-25 14:21 ` Zi Yan
  3 siblings, 0 replies; 5+ messages in thread
From: Zi Yan @ 2021-03-25 14:21 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, linux-kernel, linux-mm

[-- Attachment #1: Type: text/plain, Size: 748 bytes --]

On 25 Mar 2021, at 9:56, Miaohe Lin wrote:

> Hi all,
> This series contains cleanups to remove unnecessary out label and
> meaningless !pte_present() check. Also use helper function to simplify
> the code. More details can be found in the respective changelogs.
> Thanks!
>
> Miaohe Lin (3):
>   khugepaged: use helper function range_in_vma() in
>     collapse_pte_mapped_thp()
>   khugepaged: remove unnecessary out label in collapse_huge_page()
>   khugepaged: remove meaningless !pte_present() check in
>     khugepaged_scan_pmd()
>
>  mm/khugepaged.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)

All looks good to me. Thanks.

Reviewed-by: Zi Yan <ziy@nvidia.com>

—
Best Regards,
Yan Zi

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 858 bytes --]

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

end of thread, other threads:[~2021-03-25 14:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-25 13:56 [PATCH 0/3] Cleanup for khugepaged Miaohe Lin
2021-03-25 13:56 ` [PATCH 1/3] khugepaged: use helper function range_in_vma() in collapse_pte_mapped_thp() Miaohe Lin
2021-03-25 13:56 ` [PATCH 2/3] khugepaged: remove unnecessary out label in collapse_huge_page() Miaohe Lin
2021-03-25 13:56 ` [PATCH 3/3] khugepaged: remove meaningless !pte_present() check in khugepaged_scan_pmd() Miaohe Lin
2021-03-25 14:21 ` [PATCH 0/3] Cleanup for khugepaged Zi Yan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.