[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] proc: convert smaps_account and clear_refs_pte_range to use a folio #1998
Conversation
mainline inclusion from mainline-v6.10-rc1 category: performance Patch series "Remove page_idle and page_young wrappers". There are only a couple of places left using the page wrappers for idle & young tracking. Convert the two users in proc and then we can remove the wrappers. That enables the further simplification of autogenerating the definitions when CONFIG_PAGE_IDLE_FLAG is disabled. This patch (of 4): Replaces four calls to compound_head() with two. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Andrew Morton <[email protected]> (cherry picked from commit 03aa577) Signed-off-by: Wentao Guan <[email protected]>
mainline inclusion from mainline-v6.10-rc1 category: performance Replace seven calls to compound_head() with one. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Andrew Morton <[email protected]> (cherry picked from commit 6c977f3) Signed-off-by: Wentao Guan <[email protected]>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR refactors procfs memory accounting and clear_refs handling to use folio-based APIs instead of struct page APIs, aligning smaps_account() and clear_refs_pte_range() with the kernel’s folio model while preserving existing behavior. Flow diagram for clear_refs_pte_range folio-based young/referenced clearingflowchart TD
A[clear_refs_pte_range] --> B[pmd_trans_huge_lock]
B --> C{pmd_present}
C -->|true| D[pmd_folio]
D --> E[pmdp_test_and_clear_young]
E --> F[folio_test_clear_young]
F --> G[folio_clear_referenced]
C -->|false| H[return 0]
A --> I[pte_offset_map_lock]
I --> J[for each pte]
J --> K{pte_present}
K -->|true| L[vm_normal_folio]
L --> M{folio != NULL}
M -->|true| N[ptep_test_and_clear_young]
N --> O[folio_test_clear_young]
O --> P[folio_clear_referenced]
M -->|false| Q[continue]
K -->|false| Q
J --> R[pte_unmap_unlock]
R --> S[cond_resched]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR updates /proc memory accounting and clear-refs logic in fs/proc/task_mmu.c to use folio-based helpers instead of page-based helpers, aligning these code paths with the kernel’s folio APIs.
Changes:
- Convert
smaps_account()checks (anon/swap-backed/dirty/KSM/young/referenced/refcount) to folio helpers. - Convert
clear_refs_pte_range()young/referenced clearing to operate on folios for both PMD (THP) and PTE paths.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| goto out; | ||
|
|
||
| page = pmd_page(*pmd); | ||
| folio = pmd_folio(*pmd); |
Summary by Sourcery
Convert smaps accounting and clear_refs PTE handling to operate on folios instead of pages.
Enhancements: