linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: akpm@linux-foundation.org, tj@kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm/page_alloc: optimize find_min_pfn_for_node() by geting the minimal pfn directly
Date: Wed, 28 Mar 2018 16:02:47 +0200	[thread overview]
Message-ID: <20180328140247.GP9275@dhcp22.suse.cz> (raw)
In-Reply-To: <20180328133456.GB543@WeideMacBook-Pro.local>

On Wed 28-03-18 21:34:56, Wei Yang wrote:
> On Wed, Mar 28, 2018 at 01:58:53PM +0200, Michal Hocko wrote:
> >On Wed 28-03-18 11:47:52, Wei Yang wrote:
> >[...]
[...]
> >> @@ -6365,14 +6365,16 @@ unsigned long __init node_map_pfn_alignment(void)
> >>  /* Find the lowest pfn for a node */
> >>  static unsigned long __init find_min_pfn_for_node(int nid)
> >>  {
> >> -	unsigned long min_pfn = ULONG_MAX;
> >> -	unsigned long start_pfn;
> >> -	int i;
> >> +	unsigned long min_pfn;
> >> +	int i = -1;
> >>  
> >> -	for_each_mem_pfn_range(i, nid, &start_pfn, NULL, NULL)
> >> -		min_pfn = min(min_pfn, start_pfn);
> >> +	/*
> >> +	 * The first pfn on nid node is the minimal one, as the pfn's are
> >> +	 * stored in ascending order.
> >> +	 */
> >> +	first_mem_pfn(i, nid, &min_pfn);
> >>  
> >> -	if (min_pfn == ULONG_MAX) {
> >> +	if (i == -1) {
> >>  		pr_warn("Could not find start_pfn for node %d\n", nid);
> >>  		return 0;
> >>  	}
> >
> >I would just open code it. Other than that I strongly suspect this will
> >not have any measurable impact becauser we usually only have handfull of
> >memory ranges but why not. Just make the new implementation less ugly
> >than it is cuurrently - e.g. opencode first_mem_pfn and you can add
> 
> Open code here means use __next_mem_pfn_range() directly instead of using
> first_mem_pfn()?

Yes with the comment explaining how we rely on sorted ranges the way you
did.
-- 
Michal Hocko
SUSE Labs

      reply	other threads:[~2018-03-28 14:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27  3:57 [PATCH] mm/page_alloc: break on the first hit of mem range Wei Yang
2018-03-27 10:58 ` Michal Hocko
2018-03-28  0:39   ` Wei Yang
2018-03-28  7:02     ` Michal Hocko
2018-03-28 13:17       ` Wei Yang
2018-03-27 22:47 ` Andrew Morton
2018-03-28  0:51   ` Wei Yang
2018-03-28  1:37     ` Andrew Morton
2018-03-28  3:44       ` Wei Yang
2018-03-28  3:47       ` [PATCH] mm/page_alloc: optimize find_min_pfn_for_node() by geting the minimal pfn directly Wei Yang
2018-03-28 11:58         ` Michal Hocko
2018-03-28 13:34           ` Wei Yang
2018-03-28 14:02             ` Michal Hocko [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=20180328140247.GP9275@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=richard.weiyang@gmail.com \
    --cc=tj@kernel.org \
    /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).