LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] mm: allow deferred page init for vmemmap only
@ 2018-05-09 19:17 Pavel Tatashin
  2018-05-09 21:09 ` Michal Hocko
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Tatashin @ 2018-05-09 19:17 UTC (permalink / raw)
  To: steven.sistare, daniel.m.jordan, akpm, linux-kernel, tglx,
	mhocko, linux-mm, mgorman, mingo, peterz, rostedt, fengguang.wu,
	dennisszhou

It is unsafe to do virtual to physical translations before mm_init() is
called if struct page is needed in order to determine the memory section
number (see SECTION_IN_PAGE_FLAGS). This is because only in mm_init() we
initialize struct pages for all the allocated memory when deferred struct
pages are used.

My recent fix exposed this problem, because it greatly reduced number of
pages that are initialized before mm_init(), but the problem existed even
before my fix, as Fengguang Wu found.

Since FLATMEM is already disallowed for deferred struct pages, it makes
sense to allow deferred struct pages only on systems with
SPARSEMEM_VMEMMAP.

The problems are discussed in these threads:
http://lkml.kernel.org/r/20180418135300.inazvpxjxowogyge@wfg-t540p.sh.intel.com
http://lkml.kernel.org/r/20180419013128.iurzouiqxvcnpbvz@wfg-t540p.sh.intel.com
http://lkml.kernel.org/r/20180426202619.2768-1-pasha.tatashin@oracle.com

Fixes: 3a80a7fa7989 ("mm: meminit: initialise a subset of struct pages if CONFIG_DEFERRED_STRUCT_PAGE_INIT is set")
Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
---
 mm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index d5004d82a1d6..1cd32d67ca30 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -635,7 +635,7 @@ config DEFERRED_STRUCT_PAGE_INIT
 	bool "Defer initialisation of struct pages to kthreads"
 	default n
 	depends on NO_BOOTMEM
-	depends on !FLATMEM
+	depends on SPARSEMEM_VMEMMAP
 	help
 	  Ordinarily all struct pages are initialised during early boot in a
 	  single thread. On very large machines this can take a considerable
-- 
2.17.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: allow deferred page init for vmemmap only
  2018-05-09 19:17 [PATCH] mm: allow deferred page init for vmemmap only Pavel Tatashin
@ 2018-05-09 21:09 ` Michal Hocko
  2018-05-10 11:55   ` Pavel Tatashin
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2018-05-09 21:09 UTC (permalink / raw)
  To: Pavel Tatashin
  Cc: steven.sistare, daniel.m.jordan, akpm, linux-kernel, tglx,
	linux-mm, mgorman, mingo, peterz, rostedt, fengguang.wu,
	dennisszhou

On Wed 09-05-18 15:17:13, Pavel Tatashin wrote:
> It is unsafe to do virtual to physical translations before mm_init() is
> called if struct page is needed in order to determine the memory section
> number (see SECTION_IN_PAGE_FLAGS). This is because only in mm_init() we
> initialize struct pages for all the allocated memory when deferred struct
> pages are used.
> 
> My recent fix exposed this problem, because it greatly reduced number of
> pages that are initialized before mm_init(), but the problem existed even
> before my fix, as Fengguang Wu found.
> 
> Since FLATMEM is already disallowed for deferred struct pages, it makes
> sense to allow deferred struct pages only on systems with
> SPARSEMEM_VMEMMAP.

This doesn't really explain why CONFIG_SPARSMEM or DISCONTIG has the
problem.

> The problems are discussed in these threads:
> http://lkml.kernel.org/r/20180418135300.inazvpxjxowogyge@wfg-t540p.sh.intel.com
> http://lkml.kernel.org/r/20180419013128.iurzouiqxvcnpbvz@wfg-t540p.sh.intel.com
> http://lkml.kernel.org/r/20180426202619.2768-1-pasha.tatashin@oracle.com

Using references is good but there should be a highlevel summary in the
chaneglog as well.

> Fixes: 3a80a7fa7989 ("mm: meminit: initialise a subset of struct pages if CONFIG_DEFERRED_STRUCT_PAGE_INIT is set")
> Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
> ---
>  mm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/Kconfig b/mm/Kconfig
> index d5004d82a1d6..1cd32d67ca30 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -635,7 +635,7 @@ config DEFERRED_STRUCT_PAGE_INIT
>  	bool "Defer initialisation of struct pages to kthreads"
>  	default n
>  	depends on NO_BOOTMEM
> -	depends on !FLATMEM
> +	depends on SPARSEMEM_VMEMMAP
>  	help
>  	  Ordinarily all struct pages are initialised during early boot in a
>  	  single thread. On very large machines this can take a considerable
> -- 
> 2.17.0
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: allow deferred page init for vmemmap only
  2018-05-09 21:09 ` Michal Hocko
@ 2018-05-10 11:55   ` Pavel Tatashin
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Tatashin @ 2018-05-10 11:55 UTC (permalink / raw)
  To: mhocko
  Cc: Steven Sistare, Daniel Jordan, Andrew Morton, LKML, tglx,
	Linux Memory Management List, mgorman, mingo, peterz,
	Steven Rostedt, Fengguang Wu, Dennis Zhou

> This doesn't really explain why CONFIG_SPARSMEM or DISCONTIG has the
> problem.

Hi Michal,

Thank you for reviewing this patch. I sent out a version two of this patch,
with expanded explanation of the problem.

Thank you,
Pavel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-10 11:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09 19:17 [PATCH] mm: allow deferred page init for vmemmap only Pavel Tatashin
2018-05-09 21:09 ` Michal Hocko
2018-05-10 11:55   ` Pavel Tatashin

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).