linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Tatashin <pasha.tatashin@oracle.com>
To: dave.hansen@intel.com
Cc: Steven Sistare <steven.sistare@oracle.com>,
	Daniel Jordan <daniel.m.jordan@oracle.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	kirill.shutemov@linux.intel.com, Michal Hocko <mhocko@suse.com>,
	Linux Memory Management List <linux-mm@kvack.org>,
	dan.j.williams@intel.com, jack@suse.cz, jglisse@redhat.com,
	Souptick Joarder <jrdr.linux@gmail.com>,
	bhe@redhat.com, gregkh@linuxfoundation.org,
	Vlastimil Babka <vbabka@suse.cz>,
	Wei Yang <richard.weiyang@gmail.com>,
	rientjes@google.com, mingo@kernel.org,
	osalvador@techadventures.net
Subject: Re: [PATCH v3 2/2] mm/sparse: start using sparse_init_nid(), and remove old code
Date: Mon, 2 Jul 2018 16:12:12 -0400	[thread overview]
Message-ID: <CAGM2reb5KG1k1A9NRk8XZ6GyJ3AejvE0WN0CNr9WH4UvSEGLZg@mail.gmail.com> (raw)
In-Reply-To: <38a2629d-689c-4592-9bd7-a77ab1b2045c@intel.com>

On Mon, Jul 2, 2018 at 4:00 PM Dave Hansen <dave.hansen@intel.com> wrote:
>
> On 07/02/2018 12:54 PM, Pavel Tatashin wrote:
> >
> >
> > On 07/02/2018 03:47 PM, Dave Hansen wrote:
> >> On 07/01/2018 07:04 PM, Pavel Tatashin wrote:
> >>> +   for_each_present_section_nr(pnum_begin + 1, pnum_end) {
> >>> +           int nid = sparse_early_nid(__nr_to_section(pnum_end));
> >>>
> >>> +           if (nid == nid_begin) {
> >>> +                   map_count++;
> >>>                     continue;
> >>>             }
> >>
> >>> +           sparse_init_nid(nid_begin, pnum_begin, pnum_end, map_count);
> >>> +           nid_begin = nid;
> >>> +           pnum_begin = pnum_end;
> >>> +           map_count = 1;
> >>>     }
> >>
> >> Ugh, this is really hard to read.  Especially because the pnum "counter"
> >> is called "pnum_end".
> >
> > I called it pnum_end, because that is what is passed to
> > sparse_init_nid(), but I see your point, and I can rename pnum_end to
> > simply pnum if that will make things look better.
>
> Could you just make it a helper that takes a beginning pnum and returns
> the number of consecutive sections?

But sections do not have to be consequent. Some nodes may have
sections that are not present. So we are looking for two values:
map_count -> which is number of present sections and node_end for the
current node i.e. the first section of the next node. So the helper
would need to return two things, and would basically repeat the same
code that is done in this function.

>
> >> So, this is basically a loop that collects all of the adjacent sections
> >> in a given single nid and then calls sparse_init_nid().  pnum_end in
> >> this case is non-inclusive, so the sparse_init_nid() call is actually
> >> for the *previous* nid that pnum_end is pointing _past_.
> >>
> >> This *really* needs commenting.
> >
> > There is a comment before sparse_init_nid() about inclusiveness:
> >
> > 434 /*
> > 435  * Initialize sparse on a specific node. The node spans [pnum_begin, pnum_end)
> > 436  * And number of present sections in this node is map_count.
> > 437  */
> > 438 static void __init sparse_init_nid(int nid, unsigned long pnum_begin,
> > 439                                    unsigned long pnum_end,
> > 440                                    unsigned long map_count)
>
> Which I totally missed.  Could you comment the code, please?

Sure, I will add a comment into sparse_init() as well.

  reply	other threads:[~2018-07-02 20:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-02  2:04 [PATCH v3 0/2] sparse_init rewrite Pavel Tatashin
2018-07-02  2:04 ` [PATCH v3 1/2] mm/sparse: add sparse_init_nid() Pavel Tatashin
2018-07-02  2:11   ` Baoquan He
2018-07-02  2:18     ` Pavel Tatashin
2018-07-02  2:31       ` Baoquan He
2018-07-02  2:43         ` Pavel Tatashin
2018-07-02  2:53           ` Baoquan He
2018-07-02  3:03             ` Pavel Tatashin
2018-07-02  3:14               ` Baoquan He
2018-07-02  3:17                 ` Baoquan He
2018-07-02  3:28                 ` Pavel Tatashin
2018-07-02  3:42                   ` Baoquan He
2018-07-02  2:56   ` Baoquan He
2018-07-02  3:05     ` Pavel Tatashin
2018-07-02 19:59   ` Dave Hansen
2018-07-02 20:29     ` Pavel Tatashin
2018-07-05 13:39       ` Dave Hansen
2018-07-09 14:31         ` Pavel Tatashin
2018-07-02  2:04 ` [PATCH v3 2/2] mm/sparse: start using sparse_init_nid(), and remove old code Pavel Tatashin
2018-07-02 14:04   ` Oscar Salvador
2018-07-02 19:47   ` Dave Hansen
2018-07-02 19:54     ` Pavel Tatashin
2018-07-02 20:00       ` Dave Hansen
2018-07-02 20:12         ` Pavel Tatashin [this message]
2018-07-02 16:20 ` [PATCH v3 0/2] sparse_init rewrite Dave Hansen
2018-07-02 17:46   ` Pavel Tatashin

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=CAGM2reb5KG1k1A9NRk8XZ6GyJ3AejvE0WN0CNr9WH4UvSEGLZg@mail.gmail.com \
    --to=pasha.tatashin@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=daniel.m.jordan@oracle.com \
    --cc=dave.hansen@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=jglisse@redhat.com \
    --cc=jrdr.linux@gmail.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=osalvador@techadventures.net \
    --cc=richard.weiyang@gmail.com \
    --cc=rientjes@google.com \
    --cc=steven.sistare@oracle.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