* Re: [PATCH] memblock: stop using implicit alignement to SMP_CACHE_BYTES [not found] <1538687224-17535-1-git-send-email-rppt@linux.vnet.ibm.com> @ 2018-10-05 3:25 ` Benjamin Herrenschmidt 2018-10-05 15:05 ` Mike Rapoport 2018-10-05 22:19 ` Andrew Morton 1 sibling, 1 reply; 4+ messages in thread From: Benjamin Herrenschmidt @ 2018-10-05 3:25 UTC (permalink / raw) To: Mike Rapoport, linux-mm Cc: linux-mips, linux-m68k, Michal Hocko, linux-ia64, Catalin Marinas, Richard Weinberger, Russell King, Ingo Molnar, Geert Uytterhoeven, Matt Turner, linux-um, Thomas Gleixner, Guan Xuetao, linux-arm-kernel, Chris Zankel, Michal Simek, Tony Luck, linux-kernel, Paul Burton, linux-alpha, Andrew Morton, linuxppc-dev On Fri, 2018-10-05 at 00:07 +0300, Mike Rapoport wrote: > When a memblock allocation APIs are called with align = 0, the alignment is > implicitly set to SMP_CACHE_BYTES. > > Replace all such uses of memblock APIs with the 'align' parameter explicitly > set to SMP_CACHE_BYTES and stop implicit alignment assignment in the > memblock internal allocation functions. > > For the case when memblock APIs are used via helper functions, e.g. like > iommu_arena_new_node() in Alpha, the helper functions were detected with > Coccinelle's help and then manually examined and updated where appropriate. > > The direct memblock APIs users were updated using the semantic patch below: What is the purpose of this ? It sounds rather counter-intuitive... Ben. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memblock: stop using implicit alignement to SMP_CACHE_BYTES 2018-10-05 3:25 ` [PATCH] memblock: stop using implicit alignement to SMP_CACHE_BYTES Benjamin Herrenschmidt @ 2018-10-05 15:05 ` Mike Rapoport 0 siblings, 0 replies; 4+ messages in thread From: Mike Rapoport @ 2018-10-05 15:05 UTC (permalink / raw) To: Benjamin Herrenschmidt, linux-mm Cc: linux-mips, Michal Hocko, linux-ia64, Catalin Marinas, Richard Weinberger, Russell King, Ingo Molnar, Geert Uytterhoeven, Matt Turner, linux-um, linux-m68k, Thomas Gleixner, Guan Xuetao, linux-arm-kernel, Chris Zankel, Michal Simek, Tony Luck, linux-kernel, Paul Burton, linux-alpha, Andrew Morton, linuxppc-dev On October 5, 2018 6:25:38 AM GMT+03:00, Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote: >On Fri, 2018-10-05 at 00:07 +0300, Mike Rapoport wrote: >> When a memblock allocation APIs are called with align = 0, the >alignment is >> implicitly set to SMP_CACHE_BYTES. >> >> Replace all such uses of memblock APIs with the 'align' parameter >explicitly >> set to SMP_CACHE_BYTES and stop implicit alignment assignment in the >> memblock internal allocation functions. >> >> For the case when memblock APIs are used via helper functions, e.g. >like >> iommu_arena_new_node() in Alpha, the helper functions were detected >with >> Coccinelle's help and then manually examined and updated where >appropriate. >> >> The direct memblock APIs users were updated using the semantic patch >below: > >What is the purpose of this ? It sounds rather counter-intuitive... Why? I think it actually more intuitive to explicitly set alignment to SMP_CACHE_BYTES rather than use align = 0 because deeply inside allocator it will be implicitly reset to SMP_CACHE_BYTES... >Ben. -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memblock: stop using implicit alignement to SMP_CACHE_BYTES [not found] <1538687224-17535-1-git-send-email-rppt@linux.vnet.ibm.com> 2018-10-05 3:25 ` [PATCH] memblock: stop using implicit alignement to SMP_CACHE_BYTES Benjamin Herrenschmidt @ 2018-10-05 22:19 ` Andrew Morton 2018-10-11 6:08 ` Mike Rapoport 1 sibling, 1 reply; 4+ messages in thread From: Andrew Morton @ 2018-10-05 22:19 UTC (permalink / raw) To: Mike Rapoport Cc: linux-mm, Catalin Marinas, Chris Zankel, Geert Uytterhoeven, Guan Xuetao, Ingo Molnar, Matt Turner, Michael Ellerman, Michal Hocko, Michal Simek, Paul Burton, Richard Weinberger, Russell King, Thomas Gleixner, Tony Luck, linux-alpha, linux-arm-kernel, linux-ia64, linux-kernel, linux-m68k, linux-mips, linuxppc-dev, linux-um On Fri, 5 Oct 2018 00:07:04 +0300 Mike Rapoport <rppt@linux.vnet.ibm.com> wrote: > When a memblock allocation APIs are called with align = 0, the alignment is > implicitly set to SMP_CACHE_BYTES. > > Replace all such uses of memblock APIs with the 'align' parameter explicitly > set to SMP_CACHE_BYTES and stop implicit alignment assignment in the > memblock internal allocation functions. > > For the case when memblock APIs are used via helper functions, e.g. like > iommu_arena_new_node() in Alpha, the helper functions were detected with > Coccinelle's help and then manually examined and updated where appropriate. > > ... > > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -1298,9 +1298,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, > { > phys_addr_t found; > > - if (!align) > - align = SMP_CACHE_BYTES; > - Can we add a WARN_ON_ONCE(!align) here? To catch unconverted code which sneaks in later on. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memblock: stop using implicit alignement to SMP_CACHE_BYTES 2018-10-05 22:19 ` Andrew Morton @ 2018-10-11 6:08 ` Mike Rapoport 0 siblings, 0 replies; 4+ messages in thread From: Mike Rapoport @ 2018-10-11 6:08 UTC (permalink / raw) To: Andrew Morton Cc: linux-mm, Catalin Marinas, Chris Zankel, Geert Uytterhoeven, Guan Xuetao, Ingo Molnar, Matt Turner, Michael Ellerman, Michal Hocko, Michal Simek, Paul Burton, Richard Weinberger, Russell King, Thomas Gleixner, Tony Luck, linux-alpha, linux-arm-kernel, linux-ia64, linux-kernel, linux-m68k, linux-mips, linuxppc-dev, linux-um On Fri, Oct 05, 2018 at 03:19:34PM -0700, Andrew Morton wrote: > On Fri, 5 Oct 2018 00:07:04 +0300 Mike Rapoport <rppt@linux.vnet.ibm.com> wrote: > > > When a memblock allocation APIs are called with align = 0, the alignment is > > implicitly set to SMP_CACHE_BYTES. > > > > Replace all such uses of memblock APIs with the 'align' parameter explicitly > > set to SMP_CACHE_BYTES and stop implicit alignment assignment in the > > memblock internal allocation functions. > > > > For the case when memblock APIs are used via helper functions, e.g. like > > iommu_arena_new_node() in Alpha, the helper functions were detected with > > Coccinelle's help and then manually examined and updated where appropriate. > > > > ... > > > > --- a/mm/memblock.c > > +++ b/mm/memblock.c > > @@ -1298,9 +1298,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, > > { > > phys_addr_t found; > > > > - if (!align) > > - align = SMP_CACHE_BYTES; > > - > > Can we add a WARN_ON_ONCE(!align) here? To catch unconverted code > which sneaks in later on. Here it goes: >From baec825c58e8bc11371433d3a4b20b2216877a50 Mon Sep 17 00:00:00 2001 From: Mike Rapoport <rppt@linux.vnet.ibm.com> Date: Mon, 8 Oct 2018 11:22:10 +0300 Subject: [PATCH] memblock: warn if zero alignment was requested After update of all memblock users to explicitly specify SMP_CACHE_BYTES alignment rather than use 0, it is still possible that uncovered users may sneak in. Add a WARN_ON_ONCE for such cases. Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> --- mm/memblock.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/memblock.c b/mm/memblock.c index 0bbae56..5fefc70 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1298,6 +1298,9 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, { phys_addr_t found; + if (WARN_ON_ONCE(!align)) + align = SMP_CACHE_BYTES; + found = memblock_find_in_range_node(size, align, start, end, nid, flags); if (found && !memblock_reserve(found, size)) { @@ -1420,6 +1423,9 @@ static void * __init memblock_alloc_internal( if (WARN_ON_ONCE(slab_is_available())) return kzalloc_node(size, GFP_NOWAIT, nid); + if (WARN_ON_ONCE(!align)) + align = SMP_CACHE_BYTES; + if (max_addr > memblock.current_limit) max_addr = memblock.current_limit; again: -- 2.7.4 -- Sincerely yours, Mike. ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-11 6:08 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <1538687224-17535-1-git-send-email-rppt@linux.vnet.ibm.com> 2018-10-05 3:25 ` [PATCH] memblock: stop using implicit alignement to SMP_CACHE_BYTES Benjamin Herrenschmidt 2018-10-05 15:05 ` Mike Rapoport 2018-10-05 22:19 ` Andrew Morton 2018-10-11 6:08 ` Mike Rapoport
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).