Skip to content

Commit cc79061

Browse files
Baolin Wangakpm00
authored andcommitted
mm: khugepaged: decouple SHMEM and file folios' collapse
Originally, the file pages collapse was intended for tmpfs/shmem to merge into THP in the background. However, now not only tmpfs/shmem can support large folios, but some other file systems (such as XFS, erofs ...) also support large folios. Therefore, it is time to decouple the support of file folios collapse from SHMEM. Link: https://lkml.kernel.org/r/ce5c2314e0368cf34bda26f9bacf01c982d4da17.1747119309.git.baolin.wang@linux.alibaba.com Signed-off-by: Baolin Wang <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Zi Yan <[email protected]> Cc: Dev Jain <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Mariano Pache <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 19e0713 commit cc79061

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

include/linux/khugepaged.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,8 @@ extern void khugepaged_enter_vma(struct vm_area_struct *vma,
1515
unsigned long vm_flags);
1616
extern void khugepaged_min_free_kbytes_update(void);
1717
extern bool current_is_khugepaged(void);
18-
#ifdef CONFIG_SHMEM
1918
extern int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr,
2019
bool install_pmd);
21-
#else
22-
static inline int collapse_pte_mapped_thp(struct mm_struct *mm,
23-
unsigned long addr, bool install_pmd)
24-
{
25-
return 0;
26-
}
27-
#endif
2820

2921
static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
3022
{

mm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ config THP_SWAP
886886

887887
config READ_ONLY_THP_FOR_FS
888888
bool "Read-only THP for filesystems (EXPERIMENTAL)"
889-
depends on TRANSPARENT_HUGEPAGE && SHMEM
889+
depends on TRANSPARENT_HUGEPAGE
890890

891891
help
892892
Allow khugepaged to put read-only file-backed pages in THP.

mm/khugepaged.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,6 @@ static void collect_mm_slot(struct khugepaged_mm_slot *mm_slot)
14641464
}
14651465
}
14661466

1467-
#ifdef CONFIG_SHMEM
14681467
/* folio must be locked, and mmap_lock must be held */
14691468
static int set_huge_pmd(struct vm_area_struct *vma, unsigned long addr,
14701469
pmd_t *pmdp, struct folio *folio, struct page *page)
@@ -2353,14 +2352,6 @@ static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr,
23532352
trace_mm_khugepaged_scan_file(mm, folio, file, present, swap, result);
23542353
return result;
23552354
}
2356-
#else
2357-
static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr,
2358-
struct file *file, pgoff_t start,
2359-
struct collapse_control *cc)
2360-
{
2361-
BUILD_BUG();
2362-
}
2363-
#endif
23642355

23652356
static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
23662357
struct collapse_control *cc)
@@ -2436,7 +2427,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
24362427
VM_BUG_ON(khugepaged_scan.address < hstart ||
24372428
khugepaged_scan.address + HPAGE_PMD_SIZE >
24382429
hend);
2439-
if (IS_ENABLED(CONFIG_SHMEM) && !vma_is_anonymous(vma)) {
2430+
if (!vma_is_anonymous(vma)) {
24402431
struct file *file = get_file(vma->vm_file);
24412432
pgoff_t pgoff = linear_page_index(vma,
24422433
khugepaged_scan.address);
@@ -2782,7 +2773,7 @@ int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev,
27822773
mmap_assert_locked(mm);
27832774
memset(cc->node_load, 0, sizeof(cc->node_load));
27842775
nodes_clear(cc->alloc_nmask);
2785-
if (IS_ENABLED(CONFIG_SHMEM) && !vma_is_anonymous(vma)) {
2776+
if (!vma_is_anonymous(vma)) {
27862777
struct file *file = get_file(vma->vm_file);
27872778
pgoff_t pgoff = linear_page_index(vma, addr);
27882779

0 commit comments

Comments
 (0)