lkml.org 
[lkml]   [2018]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 2/3] mm: calculate deferred pages after skipping mirrored memory
On Tue, 24 Jul 2018 19:55:19 -0400 Pavel Tatashin <pasha.tatashin@oracle.com> wrote:

> update_defer_init() should be called only when struct page is about to be
> initialized. Because it counts number of initialized struct pages, but
> there we may skip struct pages if there is some mirrored memory.
>
> So move, update_defer_init() after checking for mirrored memory.
>
> Also, rename update_defer_init() to defer_init() and reverse the return
> boolean to emphasize that this is a boolean function, that tells that the
> reset of memmap initialization should be deferred.
>
> Make this function self-contained: do not pass number of already
> initialized pages in this zone by using static counters.
>
> ...
>
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -306,24 +306,28 @@ static inline bool __meminit early_page_uninitialised(unsigned long pfn)
> }
>
> /*
> - * Returns false when the remaining initialisation should be deferred until
> + * Returns true when the remaining initialisation should be deferred until
> * later in the boot cycle when it can be parallelised.
> */
> -static inline bool update_defer_init(pg_data_t *pgdat,
> - unsigned long pfn, unsigned long zone_end,
> - unsigned long *nr_initialised)
> +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.

--- 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?

\
 
 \ /
  Last update: 2018-07-25 03:33    [W:0.093 / U:7.692 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site