From: Baoquan He <bhe@redhat.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
mike.kravetz@oracle.com, david@redhat.com,
akpm@linux-foundation.org
Subject: Re: [PATCH v2 2/4] mm/hugetlb.c: Remove the unnecessary non_swap_entry()
Date: Thu, 23 Jul 2020 14:14:37 +0800 [thread overview]
Message-ID: <20200723061437.GQ32539@MiWiFi-R3L-srv> (raw)
In-Reply-To: <f66035ea-abfa-2523-8df5-ceb3599c9395@arm.com>
On 07/23/20 at 10:36am, Anshuman Khandual wrote:
>
>
> On 07/23/2020 08:52 AM, Baoquan He wrote:
> > The checking is_migration_entry() and is_hwpoison_entry() are stricter
> > than non_swap_entry(), means they have covered the conditional check
> > which non_swap_entry() is doing.
>
> They are no stricter as such but implicitly contains non_swap_entry() in itself.
> If a swap entry tests positive for either is_[migration|hwpoison]_entry(), then
> its swap_type() is among SWP_MIGRATION_READ, SWP_MIGRATION_WRITE and SWP_HWPOISON.
> All these types >= MAX_SWAPFILES, exactly what is asserted with non_swap_entry().
>
> >
> > Hence remove the unnecessary non_swap_entry() in is_hugetlb_entry_migration()
> > and is_hugetlb_entry_hwpoisoned() to simplify code.
> >
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
> > Reviewed-by: David Hildenbrand <david@redhat.com>
> > ---
> > mm/hugetlb.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> > index 3569e731e66b..c14837854392 100644
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -3748,7 +3748,7 @@ bool is_hugetlb_entry_migration(pte_t pte)
> > if (huge_pte_none(pte) || pte_present(pte))
> > return false;
> > swp = pte_to_swp_entry(pte);
> > - if (non_swap_entry(swp) && is_migration_entry(swp))
> > + if (is_migration_entry(swp))
> > return true;
> > else
> > return false;
> > @@ -3761,7 +3761,7 @@ static bool is_hugetlb_entry_hwpoisoned(pte_t pte)
> > if (huge_pte_none(pte) || pte_present(pte))
> > return false;
> > swp = pte_to_swp_entry(pte);
> > - if (non_swap_entry(swp) && is_hwpoison_entry(swp))
> > + if (is_hwpoison_entry(swp))
> > return true;
> > else
> > return false;
> >
>
> It would be better if the commit message contains details about
> the existing redundant check. But either way.
Thanks for your advice. Do you think updating the log as below is OK?
~~~~~~~~
If a swap entry tests positive for either is_[migration|hwpoison]_entry(), then
its swap_type() is among SWP_MIGRATION_READ, SWP_MIGRATION_WRITE and SWP_HWPOISON.
All these types >= MAX_SWAPFILES, exactly what is asserted with non_swap_entry().
So the checking non_swap_entry() in is_hugetlb_entry_migration() and
is_hugetlb_entry_hwpoisoned() is redundant.
Let's remove it to optimize code.
~~~~~~~~
Thanks
Baoquan
next prev parent reply other threads:[~2020-07-23 6:14 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-23 3:22 [PATCH v2 0/4] mm/hugetlb: Small cleanup and improvement Baoquan He
2020-07-23 3:22 ` [PATCH v2 1/4] mm/hugetlb.c: make is_hugetlb_entry_hwpoisoned return bool Baoquan He
2020-07-23 4:46 ` Anshuman Khandual
2020-07-23 3:22 ` [PATCH v2 2/4] mm/hugetlb.c: Remove the unnecessary non_swap_entry() Baoquan He
2020-07-23 5:06 ` Anshuman Khandual
2020-07-23 6:14 ` Baoquan He [this message]
2020-07-23 8:52 ` Anshuman Khandual
2020-07-23 10:46 ` [PATCH v3 " Baoquan He
2020-07-23 3:22 ` [PATCH v2 3/4] doc/vm: fix typo in the hugetlb admin documentation Baoquan He
2020-07-23 5:17 ` Anshuman Khandual
2020-07-23 5:57 ` Baoquan He
2020-07-23 3:22 ` [PATCH v2 4/4] mm/hugetl.c: warn out if expected count of huge pages adjustment is not achieved Baoquan He
2020-07-23 6:16 ` Anshuman Khandual
2020-07-23 9:11 ` Baoquan He
2020-07-23 18:21 ` Mike Kravetz
2020-07-24 14:59 ` Baoquan He
2020-08-11 2:11 ` Baoquan He
2020-08-11 3:35 ` Mike Kravetz
2020-08-11 7:24 ` Michal Hocko
2020-08-11 23:11 ` Mike Kravetz
2020-08-24 21:57 ` [PATCH v2 0/4] mm/hugetlb: Small cleanup and improvement Mike Kravetz
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=20200723061437.GQ32539@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).