mm-khugepaged-use-enum-scan_result-for-result-variables-and-return-types.patch removed from -mm tree
The quilt patch titled
Subject: mm/khugepaged: use enum scan_result for result variables and return types
has been removed from the -mm tree. Its filename was
mm-khugepaged-use-enum-scan_result-for-result-variables-and-return-types.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Shivank Garg <[email protected]>
Subject: mm/khugepaged: use enum scan_result for result variables and return types
Date: Sun, 18 Jan 2026 19:22:59 +0000
Convert result variables and return types from int to enum scan_result throughout khugepaged code. This improves type safety and code clarity by making the intent explicit.
No functional change.
---
mm/khugepaged.c | 99 +++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 53 deletions(-)
mm/khugepaged.c renamed from mm/khugepaged.c~mm-khugepaged-use-enum-scan_result-for-result-variables-and-return-types +46 -53
@@ -537,17 +537,16 @@ static void release_pte_pages(pte_t *pte } } -static int __collapse_huge_page_isolate (struct vm_area_struct *vma, -unsigned long start_addr, -pte_t *pte, -struct collapse_control *cc, -struct list_head *compound_pagelist) +static enum scan_result __collapse_huge_page_isolate (struct vm_area_struct *vma, +unsigned long start_addr,pte_t *pte,struct collapse_control *cc, +struct list_head *compound_pagelist) {struct page *page =NULL ;struct folio *folio =NULL ;unsigned long addr = start_addr;pte_t *_pte; -int none_or_zero =0 , shared =0 , result =SCAN_FAIL , referenced =0 ; +int none_or_zero =0 , shared =0 , referenced =0 ; +enum scan_result result =SCAN_FAIL ;for (_pte = pte; _pte < pte +HPAGE_PMD_NR ; _pte++, addr +=PAGE_SIZE ) {
@@ -780,13 +779,13 @@ static void __collapse_huge_page_copy_fa* @ptl: lock on raw pages' PTEs * @compound_pagelist: list that stores compound pages */ -static int __collapse_huge_page_copy (pte_t *pte,struct folio *folio, +static enum scan_result __collapse_huge_page_copy (pte_t *pte,struct folio *folio,pmd_t *pmd,pmd_t orig_pmd,struct vm_area_struct *vma,unsigned long address,spinlock_t *ptl,struct list_head *compound_pagelist) {unsigned int i; -int result =SCAN_SUCCEED ; +enum scan_result result =SCAN_SUCCEED ;/* * Copying pages' contents is subject to memory poison at any iteration.
@@ -898,10 +897,8 @@ static int hpage_collapse_find_target_no* Returns enum scan_result value. */ -static int hugepage_vma_revalidate (struct mm_struct *mm,unsigned long address, -bool expect_anon, -struct vm_area_struct **vmap, -struct collapse_control *cc) +static enum scan_result hugepage_vma_revalidate (struct mm_struct *mm,unsigned long address, +bool expect_anon,struct vm_area_struct **vmap,struct collapse_control *cc) {struct vm_area_struct *vma; enum tva_type type = cc->is_khugepaged ? TVA_KHUGEPAGED :
@@ -930,7 +927,7 @@ static int hugepage_vma_revalidate(strucreturn SCAN_SUCCEED ; } -static inline int check_pmd_state (pmd_t *pmd) +static inline enum scan_result check_pmd_state (pmd_t *pmd) {pmd_t pmde =pmdp_get_lockless (pmd);
@@ -953,9 +950,8 @@ static inline int check_pmd_state(pmd_treturn SCAN_SUCCEED ; } -static int find_pmd_or_thp_or_none (struct mm_struct *mm, -unsigned long address, -pmd_t **pmd) +static enum scan_result find_pmd_or_thp_or_none (struct mm_struct *mm, +unsigned long address,pmd_t **pmd) { *pmd =mm_find_pmd (mm, address);if (!*pmd)
@@ -964,12 +960,11 @@ static int find_pmd_or_thp_or_none(strucreturn check_pmd_state (*pmd); } -static int check_pmd_still_valid (struct mm_struct *mm, -unsigned long address, -pmd_t *pmd) +static enum scan_result check_pmd_still_valid (struct mm_struct *mm, +unsigned long address,pmd_t *pmd) {pmd_t *new_pmd; -int result =find_pmd_or_thp_or_none (mm, address, &new_pmd); +enum scan_result result =find_pmd_or_thp_or_none (mm, address, &new_pmd);if (result !=SCAN_SUCCEED )return result;
@@ -985,15 +980,14 @@ static int check_pmd_still_valid(struct* Called and returns without pte mapped or spinlocks held. * Returns result: if not SCAN_SUCCEED, mmap_lock has been released. */ -static int __collapse_huge_page_swapin (struct mm_struct *mm, -struct vm_area_struct *vma, -unsigned long start_addr,pmd_t *pmd, -int referenced) +static enum scan_result __collapse_huge_page_swapin (struct mm_struct *mm, +struct vm_area_struct *vma,unsigned long start_addr,pmd_t *pmd, +int referenced) {int swapped_in =0 ;vm_fault_t ret =0 ;unsigned long addr, end = start_addr + (HPAGE_PMD_NR *PAGE_SIZE ); -int result; +enum scan_result result;pte_t *pte =NULL ;spinlock_t *ptl;
@@ -1062,8 +1056,8 @@ out:return result; } -static int alloc_charge_folio (struct folio **foliop,struct mm_struct *mm, -struct collapse_control *cc) +static enum scan_result alloc_charge_folio (struct folio **foliop,struct mm_struct *mm, +struct collapse_control *cc) {gfp_t gfp = (cc->is_khugepaged ?alloc_hugepage_khugepaged_gfpmask () :GFP_TRANSHUGE );
@@ -1090,9 +1084,8 @@ static int alloc_charge_folio(struct folreturn SCAN_SUCCEED ; } -static int collapse_huge_page (struct mm_struct *mm,unsigned long address, -int referenced,int unmapped, -struct collapse_control *cc) +static enum scan_result collapse_huge_page (struct mm_struct *mm,unsigned long address, +int referenced,int unmapped,struct collapse_control *cc) {LIST_HEAD (compound_pagelist);pmd_t *pmd, _pmd;
@@ -1100,7 +1093,7 @@ static int collapse_huge_page(struct mm_pgtable_t pgtable;struct folio *folio;spinlock_t *pmd_ptl, *pte_ptl; -int result =SCAN_FAIL ; +enum scan_result result =SCAN_FAIL ;struct vm_area_struct *vma;struct mmu_notifier_range range;
@@ -1246,15 +1239,14 @@ out_nolock:return result; } -static int hpage_collapse_scan_pmd (struct mm_struct *mm, -struct vm_area_struct *vma, -unsigned long start_addr,bool *mmap_locked, -struct collapse_control *cc) +static enum scan_result hpage_collapse_scan_pmd (struct mm_struct *mm, +struct vm_area_struct *vma,unsigned long start_addr,bool *mmap_locked, +struct collapse_control *cc) {pmd_t *pmd;pte_t *pte, *_pte; -int result =SCAN_FAIL , referenced =0 ; -int none_or_zero =0 , shared =0 ; +int none_or_zero =0 , shared =0 , referenced =0 ; +enum scan_result result =SCAN_FAIL ;struct page *page =NULL ;struct folio *folio =NULL ;unsigned long addr;
@@ -1441,8 +1433,8 @@ static void collect_mm_slot(struct mm_sl }/* folio must be locked, and mmap_lock must be held */ -static int set_huge_pmd (struct vm_area_struct *vma,unsigned long addr, -pmd_t *pmdp,struct folio *folio,struct page *page) +static enum scan_result set_huge_pmd (struct vm_area_struct *vma,unsigned long addr, +pmd_t *pmdp,struct folio *folio,struct page *page) {struct mm_struct *mm = vma->vm_mm;struct vm_fault vmf = {
@@ -1477,10 +1469,11 @@ static int set_huge_pmd(struct vm_area_sreturn SCAN_SUCCEED ; } -static int try_collapse_pte_mapped_thp (struct mm_struct *mm,unsigned long addr, +static enum scan_result try_collapse_pte_mapped_thp (struct mm_struct *mm,unsigned long addr,bool install_pmd) { -int nr_mapped_ptes =0 , result =SCAN_FAIL ; +enum scan_result result =SCAN_FAIL ; +int nr_mapped_ptes =0 ;unsigned int nr_batch_ptes;struct mmu_notifier_range range;bool notified = false;
@@ -1862,9 +1855,8 @@ drop_pml:* + unlock old pages * + unlock and free huge page; */ -static int collapse_file (struct mm_struct *mm,unsigned long addr, -struct file *file,pgoff_t start, -struct collapse_control *cc) +static enum scan_result collapse_file (struct mm_struct *mm,unsigned long addr, +struct file *file,pgoff_t start,struct collapse_control *cc) {struct address_space *mapping = file->f_mapping;struct page *dst;
@@ -1872,7 +1864,8 @@ static int collapse_file(struct mm_strucpgoff_t index =0 , end = start +HPAGE_PMD_NR ;LIST_HEAD (pagelist);XA_STATE_ORDER (xas, &mapping->i_pages, start,HPAGE_PMD_ORDER ); -int nr_none =0 , result =SCAN_SUCCEED ; +enum scan_result result =SCAN_SUCCEED ; +int nr_none =0 ;bool is_shmem =shmem_file (file);VM_BUG_ON (!IS_ENABLED (CONFIG_READ_ONLY_THP_FOR_FS ) && !is_shmem);
@@ -2293,16 +2286,15 @@ out:return result; } -static int hpage_collapse_scan_file (struct mm_struct *mm,unsigned long addr, -struct file *file,pgoff_t start, -struct collapse_control *cc) +static enum scan_result hpage_collapse_scan_file (struct mm_struct *mm,unsigned long addr, +struct file *file,pgoff_t start,struct collapse_control *cc) {struct folio *folio =NULL ;struct address_space *mapping = file->f_mapping;XA_STATE (xas, &mapping->i_pages, start);int present, swap;int node =NUMA_NO_NODE ; -int result =SCAN_SUCCEED ; +enum scan_result result =SCAN_SUCCEED ; present =0 ; swap =0 ;
@@ -2400,7 +2392,7 @@ static int hpage_collapse_scan_file(strureturn result; } -static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result, +static unsigned int khugepaged_scan_mm_slot(unsigned int pages, enum scan_result *result, struct collapse_control *cc) __releases(&khugepaged_mm_lock) __acquires(&khugepaged_mm_lock)
@@ -2561,7 +2553,7 @@ static void khugepaged_do_scan(struct counsigned int progress =0 , pass_through_head =0 ;unsigned int pages =READ_ONCE (khugepaged_pages_to_scan);bool wait = true; -int result =SCAN_SUCCEED ; +enum scan_result result =SCAN_SUCCEED ;lru_add_drain_all ();
@@ -2774,7 +2766,8 @@ int madvise_collapse(struct vm_area_strustruct collapse_control *cc;struct mm_struct *mm = vma->vm_mm;unsigned long hstart, hend, addr; -int thps =0 , last_fail =SCAN_FAIL ; +enum scan_result last_fail =SCAN_FAIL ; +int thps =0 ;bool mmap_locked = true;BUG_ON (vma->vm_start > start);
@@ -2795,7 +2788,7 @@ int madvise_collapse(struct vm_area_stru hend = end &HPAGE_PMD_MASK ;for (addr = hstart; addr < hend; addr +=HPAGE_PMD_SIZE ) { -int result =SCAN_FAIL ; +enum scan_result result =SCAN_FAIL ;bool triggered_wb = false; retry:
_
Patches currently in -mm which might be from [email protected] are