Skip to content

Commit 8116253

Browse files
Matthew Wilcox (Oracle)opsiff
authored andcommitted
mm/memory-failure: pass the folio to collect_procs_ksm()
We've already calculated it, so pass it in instead of recalculating it in collect_procs_ksm(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Jane Chu <[email protected]> Reviewed-by: Miaohe Lin <[email protected]> Cc: Dan Williams <[email protected]> Cc: Miaohe Lin <[email protected]> Cc: Oscar Salvador <[email protected]> Signed-off-by: Andrew Morton <[email protected]> (cherry picked from commit b650e1d)
1 parent dccef48 commit 8116253

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

include/linux/ksm.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,9 @@ struct page *ksm_might_need_to_copy(struct page *page,
9191

9292
void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc);
9393
void folio_migrate_ksm(struct folio *newfolio, struct folio *folio);
94-
95-
#ifdef CONFIG_MEMORY_FAILURE
96-
void collect_procs_ksm(struct page *page, struct list_head *to_kill,
97-
int force_early);
98-
#endif
99-
100-
#ifdef CONFIG_PROC_FS
94+
void collect_procs_ksm(struct folio *folio, struct page *page,
95+
struct list_head *to_kill, int force_early);
10196
long ksm_process_profit(struct mm_struct *);
102-
#endif /* CONFIG_PROC_FS */
10397

10498
#else /* !CONFIG_KSM */
10599

@@ -129,12 +123,10 @@ static inline void ksm_might_unmap_zero_page(struct mm_struct *mm, pte_t pte)
129123
{
130124
}
131125

132-
#ifdef CONFIG_MEMORY_FAILURE
133-
static inline void collect_procs_ksm(struct page *page,
126+
static inline void collect_procs_ksm(struct folio *folio, struct page *page,
134127
struct list_head *to_kill, int force_early)
135128
{
136129
}
137-
#endif
138130

139131
#ifdef CONFIG_MMU
140132
static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,

mm/ksm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,12 +2906,11 @@ void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc)
29062906
/*
29072907
* Collect processes when the error hit an ksm page.
29082908
*/
2909-
void collect_procs_ksm(struct page *page, struct list_head *to_kill,
2910-
int force_early)
2909+
void collect_procs_ksm(struct folio *folio, struct page *page,
2910+
struct list_head *to_kill, int force_early)
29112911
{
29122912
struct ksm_stable_node *stable_node;
29132913
struct ksm_rmap_item *rmap_item;
2914-
struct folio *folio = page_folio(page);
29152914
struct vm_area_struct *vma;
29162915
struct task_struct *tsk;
29172916

mm/memory-failure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ static void collect_procs(struct folio *folio, struct page *page,
723723
if (!folio->mapping)
724724
return;
725725
if (unlikely(folio_test_ksm(folio)))
726-
collect_procs_ksm(page, tokill, force_early);
726+
collect_procs_ksm(folio, page, tokill, force_early);
727727
else if (folio_test_anon(folio))
728728
collect_procs_anon(folio, page, tokill, force_early);
729729
else

0 commit comments

Comments
 (0)