mbox series

[mm-unstable,v3,0/7] Cleanup transhuge_xxx helpers

Message ID 20220606214414.736109-1-shy828301@gmail.com (mailing list archive)
Headers show
Series Cleanup transhuge_xxx helpers | expand

Message

Yang Shi June 6, 2022, 9:44 p.m. UTC
v3: * Fixed the comment from Willy
v2: * Rebased to the latest mm-unstable
    * Fixed potential regression for smaps's THPeligible

This series is the follow-up of the discussion about cleaning up transhuge_xxx
helpers at https://lore.kernel.org/linux-mm/627a71f8-e879-69a5-ceb3-fc8d29d2f7f1@suse.cz/.

THP has a bunch of helpers that do VMA sanity check for different paths, they
do the similar checks for the most callsites and have a lot duplicate codes.
And it is confusing what helpers should be used at what conditions.

This series reorganized and cleaned up the code so that we could consolidate
all the checks into hugepage_vma_check().

The transhuge_vma_enabled(), transparent_hugepage_active() and
__transparent_hugepage_enabled() are killed by this series.

Added transhuge_vma_size_ok() helper to remove some duplicate code.


Yang Shi (7):
      mm: khugepaged: check THP flag in hugepage_vma_check()
      mm: thp: introduce transhuge_vma_size_ok() helper
      mm: khugepaged: remove the redundant anon vma check
      mm: khugepaged: use transhuge_vma_suitable replace open-code
      mm: thp: kill transparent_hugepage_active()
      mm: thp: kill __transhuge_page_enabled()
      mm: khugepaged: reorg some khugepaged helpers

 fs/proc/task_mmu.c         |  2 +-
 include/linux/huge_mm.h    | 84 ++++++++++++++++++++++++++++------------------------------------------
 include/linux/khugepaged.h | 21 ++----------------
 mm/huge_memory.c           | 64 +++++++++++++++++++++++++++++++++++++++++++++--------
 mm/khugepaged.c            | 78 +++++++++++++++--------------------------------------------------
 mm/memory.c                |  7 ++++--
 6 files changed, 114 insertions(+), 142 deletions(-)

Comments

Zach O'Keefe June 9, 2022, 11:32 p.m. UTC | #1
On Mon, Jun 6, 2022 at 2:44 PM Yang Shi <shy828301@gmail.com> wrote:
>
>
> v3: * Fixed the comment from Willy
> v2: * Rebased to the latest mm-unstable
>     * Fixed potential regression for smaps's THPeligible
>
> This series is the follow-up of the discussion about cleaning up transhuge_xxx
> helpers at https://lore.kernel.org/linux-mm/627a71f8-e879-69a5-ceb3-fc8d29d2f7f1@suse.cz/.
>
> THP has a bunch of helpers that do VMA sanity check for different paths, they
> do the similar checks for the most callsites and have a lot duplicate codes.
> And it is confusing what helpers should be used at what conditions.
>
> This series reorganized and cleaned up the code so that we could consolidate
> all the checks into hugepage_vma_check().

By the way, thanks for doing this work. I know I personally was quite
confused about which vma checking function does what / which I should
be using. I briefly tried sketching out how to do something like this
as well - but the various corner cases where e.g. hugepage_vma_check()
and transparent_hugepage_active() differed got confusing. Thanks for
figuring this all out.

> The transhuge_vma_enabled(), transparent_hugepage_active() and
> __transparent_hugepage_enabled() are killed by this series.
>
> Added transhuge_vma_size_ok() helper to remove some duplicate code.
>
>
> Yang Shi (7):
>       mm: khugepaged: check THP flag in hugepage_vma_check()
>       mm: thp: introduce transhuge_vma_size_ok() helper
>       mm: khugepaged: remove the redundant anon vma check
>       mm: khugepaged: use transhuge_vma_suitable replace open-code
>       mm: thp: kill transparent_hugepage_active()
>       mm: thp: kill __transhuge_page_enabled()
>       mm: khugepaged: reorg some khugepaged helpers
>
>  fs/proc/task_mmu.c         |  2 +-
>  include/linux/huge_mm.h    | 84 ++++++++++++++++++++++++++++------------------------------------------
>  include/linux/khugepaged.h | 21 ++----------------
>  mm/huge_memory.c           | 64 +++++++++++++++++++++++++++++++++++++++++++++--------
>  mm/khugepaged.c            | 78 +++++++++++++++--------------------------------------------------
>  mm/memory.c                |  7 ++++--
>  6 files changed, 114 insertions(+), 142 deletions(-)
>
>
>
Miaohe Lin June 10, 2022, 7:08 a.m. UTC | #2
On 2022/6/7 5:44, Yang Shi wrote:
> 
> v3: * Fixed the comment from Willy
> v2: * Rebased to the latest mm-unstable
>     * Fixed potential regression for smaps's THPeligible
> 
> This series is the follow-up of the discussion about cleaning up transhuge_xxx
> helpers at https://lore.kernel.org/linux-mm/627a71f8-e879-69a5-ceb3-fc8d29d2f7f1@suse.cz/.
> 
> THP has a bunch of helpers that do VMA sanity check for different paths, they
> do the similar checks for the most callsites and have a lot duplicate codes.
> And it is confusing what helpers should be used at what conditions.

Yes, these helpers really confused me when I read the code. Thanks for doing this!

> 
> This series reorganized and cleaned up the code so that we could consolidate
> all the checks into hugepage_vma_check().
> 
> The transhuge_vma_enabled(), transparent_hugepage_active() and
> __transparent_hugepage_enabled() are killed by this series.
> 
> Added transhuge_vma_size_ok() helper to remove some duplicate code.
> 
> 
> Yang Shi (7):
>       mm: khugepaged: check THP flag in hugepage_vma_check()
>       mm: thp: introduce transhuge_vma_size_ok() helper
>       mm: khugepaged: remove the redundant anon vma check
>       mm: khugepaged: use transhuge_vma_suitable replace open-code
>       mm: thp: kill transparent_hugepage_active()
>       mm: thp: kill __transhuge_page_enabled()
>       mm: khugepaged: reorg some khugepaged helpers
> 
>  fs/proc/task_mmu.c         |  2 +-
>  include/linux/huge_mm.h    | 84 ++++++++++++++++++++++++++++------------------------------------------
>  include/linux/khugepaged.h | 21 ++----------------
>  mm/huge_memory.c           | 64 +++++++++++++++++++++++++++++++++++++++++++++--------
>  mm/khugepaged.c            | 78 +++++++++++++++--------------------------------------------------
>  mm/memory.c                |  7 ++++--
>  6 files changed, 114 insertions(+), 142 deletions(-)
> 
> 
> 
> .
>