From: Hillf Danton <hdanton@sina.com>
To: Yang Shi <shy828301@gmail.com>
Cc: vbabka@suse.cz, kirill.shutemov@linux.intel.com,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/7] mm: thp: introduce transhuge_vma_size_ok() helper
Date: Sat, 21 May 2022 09:39:54 +0800 [thread overview]
Message-ID: <20220521013954.2695-1-hdanton@sina.com> (raw)
In-Reply-To: <20220520211605.51473-3-shy828301@gmail.com>
On Fri, 20 May 2022 14:16:00 -0700 Yang Shi wrote:
> There are couple of places that check whether the vma size is ok for
> THP or not, they are open coded and duplicate, introduce
> transhuge_vma_size_ok() helper to do the job.
>
> Signed-off-by: Yang Shi <shy828301@gmail.com>
> ---
> include/linux/huge_mm.h | 17 +++++++++++++++++
> mm/huge_memory.c | 5 +----
> mm/khugepaged.c | 12 ++++++------
> 3 files changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> index 648cb3ce7099..a8f61db47f2a 100644
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -116,6 +116,18 @@ extern struct kobj_attribute shmem_enabled_attr;
>
> extern unsigned long transparent_hugepage_flags;
>
> +/*
> + * The vma size has to be large enough to hold an aligned HPAGE_PMD_SIZE area.
> + */
> +static inline bool transhuge_vma_size_ok(struct vm_area_struct *vma)
> +{
> + if (round_up(vma->vm_start, HPAGE_PMD_SIZE) <
> + (vma->vm_end & HPAGE_PMD_MASK))
> + return true;
> +
> + return false;
> +}
> +
> static inline bool transhuge_vma_suitable(struct vm_area_struct *vma,
> unsigned long addr)
> {
> @@ -345,6 +357,11 @@ static inline bool transparent_hugepage_active(struct vm_area_struct *vma)
> return false;
> }
>
> +static inline bool transhuge_vma_size_ok(struct vm_area_struct *vma)
> +{
> + return false;
> +}
> +
> static inline bool transhuge_vma_suitable(struct vm_area_struct *vma,
> unsigned long addr)
> {
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 80e8b58b4f39..d633f97452c1 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -71,10 +71,7 @@ unsigned long huge_zero_pfn __read_mostly = ~0UL;
>
> bool transparent_hugepage_active(struct vm_area_struct *vma)
> {
> - /* The addr is used to check if the vma size fits */
> - unsigned long addr = (vma->vm_end & HPAGE_PMD_MASK) - HPAGE_PMD_SIZE;
> -
> - if (!transhuge_vma_suitable(vma, addr))
> + if (!transhuge_vma_size_ok(vma))
> return false;
Given the comment added in 4/7, this patch adds change in semantic.
If that is intened, add some words in log message for it.
> if (vma_is_anonymous(vma))
> return __transparent_hugepage_enabled(vma);
next prev parent reply other threads:[~2022-05-21 1:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-20 21:15 [mm-unstable PATCH 0/7] Cleanup transhuge_xxx helpers Yang Shi
2022-05-20 21:15 ` [PATCH 1/7] mm: khugepaged: check THP flag in hugepage_vma_check() Yang Shi
2022-05-20 21:16 ` [PATCH 2/7] mm: thp: introduce transhuge_vma_size_ok() helper Yang Shi
2022-05-21 1:39 ` Hillf Danton [this message]
2022-05-23 18:12 ` Yang Shi
2022-05-20 21:16 ` [PATCH 3/7] mm: khugepaged: remove the redundant anon vma check Yang Shi
2022-05-20 21:16 ` [PATCH 4/7] mm: khugepaged: use transhuge_vma_suitable replace open-code Yang Shi
2022-05-20 21:16 ` [PATCH 5/7] mm: thp: kill transparent_hugepage_active() Yang Shi
2022-05-20 21:16 ` [PATCH 6/7] mm: thp: kill __transhuge_page_enabled() Yang Shi
2022-05-20 21:16 ` [PATCH 7/7] mm: khugepaged: reorg some khugepaged helpers 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=20220521013954.2695-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shy828301@gmail.com \
--cc=vbabka@suse.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox