linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Tatashin <pasha.tatashin@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Steven Sistare <steven.sistare@oracle.com>,
	Daniel Jordan <daniel.m.jordan@oracle.com>,
	LKML <linux-kernel@vger.kernel.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>,
	dave.hansen@intel.com, rientjes@google.com, mingo@kernel.org,
	osalvador@techadventures.net, abdhalee@linux.vnet.ibm.com,
	mpe@ellerman.id.au
Subject: Re: [PATCH 2/3] mm: calculate deferred pages after skipping mirrored memory
Date: Thu, 26 Jul 2018 11:39:04 -0400	[thread overview]
Message-ID: <CAGM2reZ-DLcSw_DnBFfR8yvZBxpT4W1pUPo5+R6HDNvumx-nsA@mail.gmail.com> (raw)
In-Reply-To: <20180725143007.25d5bff352872aba90ca731b@linux-foundation.org>

On Wed, Jul 25, 2018 at 5:30 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Tue, 24 Jul 2018 21:46:25 -0400 Pavel Tatashin <pasha.tatashin@oracle.com> wrote:
>
> > > > +static inline bool defer_init(int nid, unsigned long pfn, unsigned long end_pfn)
> > > >  {
> > > > +     static unsigned long prev_end_pfn, nr_initialised;
> > >
> > > So answer me quick, what happens with a static variable in an inlined
> > > function?  Is there one copy kernel-wide?  One copy per invocation
> > > site?  One copy per compilation unit?
> > >
> > > Well I didn't know so I wrote a little test.  One copy per compilation
> > > unit (.o file), it appears.
> > >
> > > It's OK in this case because the function is in .c (and has only one
> > > call site).  But if someone moves it into a header and uses it from a
> > > different .c file, they have problems.
> > >
> > > So it's dangerous, and poor practice.  I'll make this non-static
> > > __meminit.
> >
> > I agree, it should not be moved to header it is dangerous.
> >
> > But, on the other hand this is a hot-path. memmap_init_zone() might
> > need to go through billions of struct pages early in boot, and I did
> > not want us to waste time on function calls. With defer_init() this is
> > not a problem, because if CONFIG_DEFERRED_STRUCT_PAGE_INIT is set
> > memmap_init_zone() won't have much work to do, but for
> > overlap_memmap_init() this is a problem, especially because I expect
> > compiler to optimize the pfn dereference usage in inline function.
>
> Well.  The compiler will just go and inline defer_init() anwyay - it
> has a single callsite and is in the same __meminint section as its
> calling function.  My gcc-7.2.0 does this.  Marking it noninline
> __meminit is basically syntactic fluff designed to encourage people to
> think twice.

Makes sense. I will do the change in the next version of the patches.

>
> > >
> > > --- a/mm/page_alloc.c~mm-calculate-deferred-pages-after-skipping-mirrored-memory-fix
> > > +++ a/mm/page_alloc.c
> > > @@ -309,7 +309,8 @@ static inline bool __meminit early_page_
> > >   * Returns true when the remaining initialisation should be deferred until
> > >   * later in the boot cycle when it can be parallelised.
> > >   */
> > > -static inline bool defer_init(int nid, unsigned long pfn, unsigned long end_pfn)
> > > +static bool __meminit
> > > +defer_init(int nid, unsigned long pfn, unsigned long end_pfn)
> > >  {
> > >         static unsigned long prev_end_pfn, nr_initialised;
> > >
> > >
> > > Also, what locking protects these statics?  Our knowledge that this
> > > code is single-threaded, presumably?
> >
> > Correct, this is called only from "context == MEMMAP_EARLY", way
> > before smp_init().
>
> Might be worth a little comment to put readers minds at ease.

Will add it.

Thank you,
Pavel

  reply	other threads:[~2018-07-26 15:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-24 23:55 [PATCH 0/3] memmap_init_zone improvements Pavel Tatashin
2018-07-24 23:55 ` [PATCH 1/3] mm: make memmap_init a proper function Pavel Tatashin
2018-07-26  7:50   ` Oscar Salvador
2018-07-24 23:55 ` [PATCH 2/3] mm: calculate deferred pages after skipping mirrored memory Pavel Tatashin
2018-07-25  1:12   ` Andrew Morton
2018-07-25  1:19     ` Pavel Tatashin
2018-07-25  1:31   ` Andrew Morton
2018-07-25  1:46     ` Pavel Tatashin
2018-07-25 21:30       ` Andrew Morton
2018-07-26 15:39         ` Pavel Tatashin [this message]
2018-07-25 12:14   ` Oscar Salvador
2018-07-25 13:32     ` Pavel Tatashin
2018-07-24 23:55 ` [PATCH 3/3] mm: move mirrored memory specific code outside of memmap_init_zone Pavel Tatashin
2018-07-25  1:18   ` Andrew Morton
2018-07-25  1:31     ` Pavel Tatashin
2018-07-25 11:48   ` Oscar Salvador

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=CAGM2reZ-DLcSw_DnBFfR8yvZBxpT4W1pUPo5+R6HDNvumx-nsA@mail.gmail.com \
    --to=pasha.tatashin@oracle.com \
    --cc=abdhalee@linux.vnet.ibm.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=mpe@ellerman.id.au \
    --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