All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Shi <shy828301@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Miaohe Lin <linmiaohe@huawei.com>,
	Song Liu <songliubraving@fb.com>, Rik van Riel <riel@surriel.com>,
	Matthew Wilcox <willy@infradead.org>, Zi Yan <ziy@nvidia.com>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux MM <linux-mm@kvack.org>,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [v3 PATCH 6/8] mm: khugepaged: move some khugepaged_* functions to khugepaged.c
Date: Mon, 9 May 2022 16:00:54 -0700	[thread overview]
Message-ID: <CAHbLzkrkra4ip2ovJg7YWhKwZJaLNZXH-X2D+20fy_k4c+jWCQ@mail.gmail.com> (raw)
In-Reply-To: <f304299d-e533-ed18-e247-6dec928ce3b0@suse.cz>

On Mon, May 9, 2022 at 8:31 AM Vlastimil Babka <vbabka@suse.cz> wrote:
>
> On 4/4/22 22:02, Yang Shi wrote:
> > To reuse hugepage_vma_check() for khugepaged_enter() so that we could
> > remove some duplicate code.  But moving hugepage_vma_check() to
> > khugepaged.h needs to include huge_mm.h in it, it seems not optimal to
> > bloat khugepaged.h.
> >
> > And the khugepaged_* functions actually are wrappers for some non-inline
> > functions, so it seems the benefits are not too much to keep them inline.
> >
> > So move the khugepaged_* functions to khugepaged.c, any callers just
> > need to include khugepaged.h which is quite small.  For example, the
> > following patches will call khugepaged_enter() in filemap page fault path
> > for regular filesystems to make readonly FS THP collapse more consistent.
> > The  filemap.c just needs to include khugepaged.h.
>
> This last part is inaccurate in v3?

Yeah, thanks for catching this. Since the patch will be reworked, so
the commit log will be reworked as well.

>
> > Acked-by: Song Liu <song@kernel.org>
> > Signed-off-by: Yang Shi <shy828301@gmail.com>
>
> I think moving the tiny wrappers is unnecessary.
>
> How about just making hugepage_vma_check() not static and declare it in
> khugepaged.h, then it can be used from khugepaged_enter() in the same file
> and AFAICS no need to include huge_mm.h there?

Sounds good to me, will fix it in v4. Thanks for reviewing and acking
the series.

>
> > ---
> >  include/linux/khugepaged.h | 37 ++++++-------------------------------
> >  mm/khugepaged.c            | 20 ++++++++++++++++++++
> >  2 files changed, 26 insertions(+), 31 deletions(-)
> >
> > diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h
> > index 0423d3619f26..6acf9701151e 100644
> > --- a/include/linux/khugepaged.h
> > +++ b/include/linux/khugepaged.h
> > @@ -2,10 +2,6 @@
> >  #ifndef _LINUX_KHUGEPAGED_H
> >  #define _LINUX_KHUGEPAGED_H
> >
> > -#include <linux/sched/coredump.h> /* MMF_VM_HUGEPAGE */
> > -#include <linux/shmem_fs.h>
> > -
> > -
> >  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> >  extern struct attribute_group khugepaged_attr_group;
> >
> > @@ -16,6 +12,12 @@ extern void __khugepaged_enter(struct mm_struct *mm);
> >  extern void __khugepaged_exit(struct mm_struct *mm);
> >  extern void khugepaged_enter_vma_merge(struct vm_area_struct *vma,
> >                                      unsigned long vm_flags);
> > +extern void khugepaged_fork(struct mm_struct *mm,
> > +                         struct mm_struct *oldmm);
> > +extern void khugepaged_exit(struct mm_struct *mm);
> > +extern void khugepaged_enter(struct vm_area_struct *vma,
> > +                          unsigned long vm_flags);
> > +
> >  extern void khugepaged_min_free_kbytes_update(void);
> >  #ifdef CONFIG_SHMEM
> >  extern void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr);
> > @@ -33,36 +35,9 @@ static inline void collapse_pte_mapped_thp(struct mm_struct *mm,
> >  #define khugepaged_always()                          \
> >       (transparent_hugepage_flags &                   \
> >        (1<<TRANSPARENT_HUGEPAGE_FLAG))
> > -#define khugepaged_req_madv()                                        \
> > -     (transparent_hugepage_flags &                           \
> > -      (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
> >  #define khugepaged_defrag()                                  \
> >       (transparent_hugepage_flags &                           \
> >        (1<<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG))
> > -
> > -static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
> > -{
> > -     if (test_bit(MMF_VM_HUGEPAGE, &oldmm->flags))
> > -             __khugepaged_enter(mm);
> > -}
> > -
> > -static inline void khugepaged_exit(struct mm_struct *mm)
> > -{
> > -     if (test_bit(MMF_VM_HUGEPAGE, &mm->flags))
> > -             __khugepaged_exit(mm);
> > -}
> > -
> > -static inline void khugepaged_enter(struct vm_area_struct *vma,
> > -                                unsigned long vm_flags)
> > -{
> > -     if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags))
> > -             if ((khugepaged_always() ||
> > -                  (shmem_file(vma->vm_file) && shmem_huge_enabled(vma)) ||
> > -                  (khugepaged_req_madv() && (vm_flags & VM_HUGEPAGE))) &&
> > -                 !(vm_flags & VM_NOHUGEPAGE) &&
> > -                 !test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags))
> > -                     __khugepaged_enter(vma->vm_mm);
> > -}
> >  #else /* CONFIG_TRANSPARENT_HUGEPAGE */
> >  static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
> >  {
> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > index b69eda934d70..ec5b0a691d87 100644
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -556,6 +556,26 @@ void __khugepaged_exit(struct mm_struct *mm)
> >       }
> >  }
> >
> > +void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
> > +{
> > +     if (test_bit(MMF_VM_HUGEPAGE, &oldmm->flags))
> > +             __khugepaged_enter(mm);
> > +}
> > +
> > +void khugepaged_exit(struct mm_struct *mm)
> > +{
> > +     if (test_bit(MMF_VM_HUGEPAGE, &mm->flags))
> > +             __khugepaged_exit(mm);
> > +}
> > +
> > +void khugepaged_enter(struct vm_area_struct *vma, unsigned long vm_flags)
> > +{
> > +     if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags) &&
> > +         khugepaged_enabled())
> > +             if (hugepage_vma_check(vma, vm_flags))
> > +                     __khugepaged_enter(vma->vm_mm);
> > +}
> > +
> >  static void release_pte_page(struct page *page)
> >  {
> >       mod_node_page_state(page_pgdat(page),
>

  reply	other threads:[~2022-05-09 23:01 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 20:02 [v3 PATCH 0/8] Make khugepaged collapse readonly FS THP more consistent Yang Shi
2022-04-04 20:02 ` [v3 PATCH 1/8] sched: coredump.h: clarify the use of MMF_VM_HUGEPAGE Yang Shi
2022-05-09 12:25   ` Vlastimil Babka
2022-04-04 20:02 ` [v3 PATCH 2/8] mm: khugepaged: remove redundant check for VM_NO_KHUGEPAGED Yang Shi
2022-05-09 12:45   ` Vlastimil Babka
2022-04-04 20:02 ` [v3 PATCH 3/8] mm: khugepaged: skip DAX vma Yang Shi
2022-05-09 12:46   ` Vlastimil Babka
2022-04-04 20:02 ` [v3 PATCH 4/8] mm: thp: only regular file could be THP eligible Yang Shi
2022-05-09 13:41   ` Vlastimil Babka
2022-04-04 20:02 ` [v3 PATCH 5/8] mm: khugepaged: make khugepaged_enter() void function Yang Shi
2022-05-09 13:46   ` Vlastimil Babka
2022-04-04 20:02 ` [v3 PATCH 6/8] mm: khugepaged: move some khugepaged_* functions to khugepaged.c Yang Shi
2022-05-09 15:31   ` Vlastimil Babka
2022-05-09 23:00     ` Yang Shi [this message]
2022-04-04 20:02 ` [v3 PATCH 7/8] mm: khugepaged: introduce khugepaged_enter_vma() helper Yang Shi
2022-05-09 15:39   ` Vlastimil Babka
2022-04-04 20:02 ` [v3 PATCH 8/8] mm: mmap: register suitable readonly file vmas for khugepaged Yang Shi
2022-05-09 15:43   ` Vlastimil Babka
2022-04-05  0:16 ` [v3 PATCH 0/8] Make khugepaged collapse readonly FS THP more consistent Matthew Wilcox
2022-04-05  0:48   ` Yang Shi
2022-04-27 20:58     ` Matthew Wilcox
2022-04-27 22:38       ` Yang Shi
2022-04-27 23:16       ` Yang Shi
2022-05-09 16:05 ` Vlastimil Babka
2022-05-09 20:34   ` Yang Shi
2022-05-10  7:35     ` Vlastimil Babka
2022-05-10 19:25       ` Yang Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHbLzkrkra4ip2ovJg7YWhKwZJaLNZXH-X2D+20fy_k4c+jWCQ@mail.gmail.com \
    --to=shy828301@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=riel@surriel.com \
    --cc=songliubraving@fb.com \
    --cc=tytso@mit.edu \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.