linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>,
	Ding Tianhong <dingtianhong@huawei.com>,
	Christoph Hellwig <hch@infradead.org>,
	Jonathan Cameron <Jonathan.Cameron@Huawei.com>,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Rick Edgecombe <rick.p.edgecombe@intel.com>,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH v13 00/14] huge vmalloc mappings
Date: Thu, 18 Mar 2021 13:50:55 +1000	[thread overview]
Message-ID: <1616036421.amjz2efujj.astroid@bobo.none> (raw)
In-Reply-To: <20210317155843.c15e71f966f1e4da508dea04@linux-foundation.org>

Excerpts from Andrew Morton's message of March 18, 2021 8:58 am:
> On Wed, 17 Mar 2021 16:23:48 +1000 Nicholas Piggin <npiggin@gmail.com> wrote:
> 
>> 
>> *** BLURB HERE ***
>> 
> 
> That's really not what it means ;)
 
Sigh, wasn't having a good yesterday.

> Could we please get a nice description for the [0/n]?  What's it all
> about, what's the benefit, what are potential downsides.
>
> And performance testing results!  Because if it ain't faster, there's
> no point in merging it?
> 

It's supposed to have a bit of description in patch 13, and has some
performance reuslts in patch 14. Is it better to put a bigger writeup
in 0? I thought that tends to get lost.

I'll write something here to discuss for now, and can fit it into the 
appropriate place in the series after that.

The kernel virtual mapping layer grew support for mapping memory with > 
PAGE_SIZE ptes with 0ddab1d2ed664 ("lib/ioremap.c: add huge I/O map 
capability interfaces"), and implemented support for using those huge
page mappings with ioremap.

According to the submission, the use-case is mapping very large 
non-volatile memory devices, which could be GB or TB.
https://lore.kernel.org/lkml/1425404664-19675-1-git-send-email-toshi.kani@hp.com/
The benefit is said to be in the overhead of maintaining the mapping,
perhaps both in memory overhead and setup / teardown time. Memory
overhead for the mapping with a 4kB page and 8 byte page table is 2GB
per TB of mapping, down to 4MB / TB with 2MB pages.

The same huge page vmap infrastructure can be quite easily adapted and
used for mapping vmalloc memory pages without more complexity for arch
or core vmap code. However unlike ioremap, vmalloc page table overhead 
is not a real problem, so the advantage to justify this is performance.

Several of the most structures in the kernel (e.g., vfs and network hash 
tables) are allocated with vmalloc on NUMA machines, in order to 
distribute access bandwidth over the machine. Mapping these with larger
pages can improve TLB usage significantly, for example this reduces TLB 
misses by nearly 30x on a `git diff` workload on a 2-node POWER9 (59,800 
-> 2,100) and reduces CPU cycles by 0.54%, due to vfs hashes being 
allocated with 2MB pages.

[ Other numbers?
  - The difference is even larger in a guest due to more costly TLB 
    misses.
  - Eric Dumazet was keen on the network hash performance possibilities.
  - Other archs? Ding was doing x86 testing. ]

The kernel module allocator also uses vmalloc to map module images even 
on non-NUMA, which can result in high iTLB pressure on highly modular 
distro type of kernels. This series does not implement huge mappings for 
modules yet, but it's a step along the way. Rick Edgecombe was looking 
at that IIRC.

The per-cpu allocator similarly might be able to take advantage of this.
Also on the todo list.

The disadvantages of this I can see are:
* Memory fragmentation can waste some physical memory because it will 
  attempt to allocate larger pages to fit the required size, rounding up 
  (once the requested size is >= 2MB).
  - I don't see it being a big problem in practice unless some user 
    crops up that allocates thousands of 2.5MB ranges. We can tewak 
    heuristics a bit there if needed to reduce peak waste.
* Less granular mappings can make the NUMA distribution less balanced.
  - Similar to the above.
  - Could also allocate all major system hashes with one allocation
    up-front and spread them all across the one block, which should help
    overall NUMA distribution and reduce fragmentation waste.
* Callers might expect something about the underlying allocated pages.
  - Tried to keep the apperance of base PAGE_SIZE pages throughout the 
    APIs and exposed data structures.
  - Added a VM_NO_HUGE_VMAP flag to hammer troublesome cases with.

- Finally, added a nohugevmalloc boot option to turn it off (independent
  of nohugeiomap).

Is that helpful?

Thanks,
Nick

      reply	other threads:[~2021-03-18  3:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17  6:23 [PATCH v13 00/14] huge vmalloc mappings Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 01/14] ARM: mm: add missing pud_page define to 2-level page tables Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 02/14] mm/vmalloc: fix HUGE_VMAP regression by enabling huge pages in vmalloc_to_page Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 03/14] mm: apply_to_pte_range warn and fail if a large pte is encountered Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 04/14] mm/vmalloc: rename vmap_*_range vmap_pages_*_range Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 05/14] mm/ioremap: rename ioremap_*_range to vmap_*_range Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 06/14] mm: HUGE_VMAP arch support cleanup Nicholas Piggin
2021-04-28  8:32   ` Christophe Leroy
2021-04-28  8:34     ` Christophe Leroy
2021-03-17  6:23 ` [PATCH v13 07/14] powerpc: inline huge vmap supported functions Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 08/14] arm64: " Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 09/14] x86: " Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 10/14] mm/vmalloc: provide fallback arch huge vmap support functions Nicholas Piggin
2021-03-17  6:23 ` [PATCH v13 11/14] mm: Move vmap_range from mm/ioremap.c to mm/vmalloc.c Nicholas Piggin
2021-03-17  6:24 ` [PATCH v13 12/14] mm/vmalloc: add vmap_range_noflush variant Nicholas Piggin
2021-03-17  6:24 ` [PATCH v13 13/14] mm/vmalloc: Hugepage vmalloc mappings Nicholas Piggin
2021-03-17  6:24 ` [PATCH v13 14/14] powerpc/64s/radix: Enable huge " Nicholas Piggin
2021-04-15 10:23   ` Christophe Leroy
2021-04-15 18:55     ` Andrew Morton
2021-04-15 23:04       ` Stephen Rothwell
2021-04-17  2:39       ` Nicholas Piggin
2021-03-17 22:58 ` [PATCH v13 00/14] " Andrew Morton
2021-03-18  3:50   ` Nicholas Piggin [this message]

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=1616036421.amjz2efujj.astroid@bobo.none \
    --to=npiggin@gmail.com \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=dingtianhong@huawei.com \
    --cc=eric.dumazet@gmail.com \
    --cc=hch@infradead.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rick.p.edgecombe@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).