From: Andrew Morton <akpm@linux-foundation.org>
To: qiwuchen55@gmail.com
Cc: linux-mm@kvack.org, chenqiwu <chenqiwu@xiaomi.com>
Subject: Re: [RESEND PATCH] mm/sparse: remove duplicated pfn_to_section_nr()
Date: Fri, 20 Mar 2020 20:04:20 -0700 [thread overview]
Message-ID: <20200320200420.63d04e1fe92a642493e77cef@linux-foundation.org> (raw)
In-Reply-To: <1584345587-16769-1-git-send-email-qiwuchen55@gmail.com>
On Mon, 16 Mar 2020 15:59:47 +0800 qiwuchen55@gmail.com wrote:
> From: chenqiwu <chenqiwu@xiaomi.com>
>
> Remove duplicated pfn_to_section_nr() in pfn_valid() and pfn_present()
> to increase executing efficiency of code.
>
> ...
>
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -1358,10 +1358,11 @@ static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn)
> static inline int pfn_valid(unsigned long pfn)
> {
> struct mem_section *ms;
> + unsigned long sec_nr = pfn_to_section_nr(pfn);
>
> - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
> + if (sec_nr >= NR_MEM_SECTIONS)
> return 0;
> - ms = __nr_to_section(pfn_to_section_nr(pfn));
> + ms = __nr_to_section(sec_nr);
> if (!valid_section(ms))
> return 0;
> /*
> @@ -1374,9 +1375,11 @@ static inline int pfn_valid(unsigned long pfn)
>
> static inline int pfn_present(unsigned long pfn)
> {
> - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
> + unsigned long sec_nr = pfn_to_section_nr(pfn);
> +
> + if (sec_nr >= NR_MEM_SECTIONS)
> return 0;
> - return present_section(__nr_to_section(pfn_to_section_nr(pfn)));
> + return present_section(__nr_to_section(sec_nr));
> }
>
The compiler already makes this optimization (pfn_to_section_nr() is
very simple). Generated code appears to be identical.
I guess this patch could be sold as a cleanup, but I don't think it's
worthwhile, really.
prev parent reply other threads:[~2020-03-21 3:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-16 7:59 [RESEND PATCH] mm/sparse: remove duplicated pfn_to_section_nr() qiwuchen55
2020-03-16 8:45 ` Pankaj Gupta
2020-03-21 3:04 ` Andrew Morton [this message]
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=20200320200420.63d04e1fe92a642493e77cef@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=chenqiwu@xiaomi.com \
--cc=linux-mm@kvack.org \
--cc=qiwuchen55@gmail.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).