diff mbox series

[07/16] mm/huge_memory: minor cleanup for split_huge_pages_pid

Message ID 20220622170627.19786-8-linmiaohe@huawei.com (mailing list archive)
State New
Headers show
Series A few cleanup patches for huge_memory | expand

Commit Message

Miaohe Lin June 22, 2022, 5:06 p.m. UTC
Use helper function vma_lookup to lookup the needed vma and use help macro
IS_ERR_OR_NULL to check the validity of page to simplify the code. Minor
readability improvement.

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

Comments

Kirill A. Shutemov June 23, 2022, 3:22 a.m. UTC | #1
On Thu, Jun 23, 2022 at 01:06:18AM +0800, Miaohe Lin wrote:
> Use helper function vma_lookup to lookup the needed vma and use help macro
> IS_ERR_OR_NULL to check the validity of page to simplify the code. Minor
> readability improvement.

Grouping of changing seems random, but okay.
Miaohe Lin June 23, 2022, 12:07 p.m. UTC | #2
On 2022/6/23 11:22, Kirill A. Shutemov wrote:
> On Thu, Jun 23, 2022 at 01:06:18AM +0800, Miaohe Lin wrote:
>> Use helper function vma_lookup to lookup the needed vma and use help macro
>> IS_ERR_OR_NULL to check the validity of page to simplify the code. Minor
>> readability improvement.
> 
> Grouping of changing seems random, but okay.

I group them because they belong to the same function. Should I split these two changes?

Many thanks for reviewing and comment!

>
diff mbox series

Patch

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index fb5c484dfa39..7cfa003b1789 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2942,10 +2942,10 @@  static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
 	 * table filled with PTE-mapped THPs, each of which is distinct.
 	 */
 	for (addr = vaddr_start; addr < vaddr_end; addr += PAGE_SIZE) {
-		struct vm_area_struct *vma = find_vma(mm, addr);
+		struct vm_area_struct *vma = vma_lookup(mm, addr);
 		struct page *page;
 
-		if (!vma || addr < vma->vm_start)
+		if (!vma)
 			break;
 
 		/* skip special VMA and hugetlb VMA */
@@ -2957,9 +2957,7 @@  static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
 		/* FOLL_DUMP to ignore special (like zero) pages */
 		page = follow_page(vma, addr, FOLL_GET | FOLL_DUMP | FOLL_LRU);
 
-		if (IS_ERR(page))
-			continue;
-		if (!page)
+		if (IS_ERR_OR_NULL(page))
 			continue;
 
 		if (!is_transparent_hugepage(page))