public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: Linux 3.19-rc3
Date: Sat, 10 Jan 2015 21:16:02 +0100	[thread overview]
Message-ID: <4665410.x9Uu42bKmJ@wuerfel> (raw)
In-Reply-To: <CA+55aFz74hjhCcdz5J4r-xK4KW7oqNDA3i=jXHW0prGMMwgMvw@mail.gmail.com>

On Friday 09 January 2015 18:27:38 Linus Torvalds wrote:
> On Fri, Jan 9, 2015 at 4:35 PM, Kirill A. Shutemov <kirill@shutemov.name> wrote:
> >
> > With bigger page size there's also reduction in number of entities to
> > handle by kernel: less memory occupied by struct pages, fewer pages on
> > lru, etc.
> 
> Really, do the math. [...]
>
> With a 64kB page, that means that for caching the kernel tree (what,
> closer to 50k files by now), you are basically wasting 60kB for most
> source files. Say, 60kB * 30k files, or 1.8GB.

On a recent kernel, I get 628 MB for storing all files of the
kernel tree in 4KB pages, and 3141 MB for storing the same data
in 64KB pages, almost exactly factor 5, or 2.45 GiB wasted.

> Maybe things have changed, and maybe I did my math wrong, and people
> can give a more exact number. But it's an example of why 64kB
> granularity is completely unacceptable in any kind of general-purpose
> load.

I'd say it's unacceptable for any file backed mappings in general, but
usually an improvement for anonymous maps, for the same reasons that
transparent huge pages are great. IIRC, AIX works great with 64k
pages, but only because of two reasons that don't apply on Linux:

a) The PowerPC MMU can mix 4KB and 64KB pages in a single process.
   Linux doesn't use this feature except for very special cases,
   although it could be done on PowerPC but not most other architectures.

b) Linux has a unified page cache page size that is used for both
   anonymous and file backed mappings. It's a great feature of the
   Linux MM code (it avoids having two copies of each mapped file
   in memory), but other OSs can just use 4KB blocks in the file
   system cache independent of the page size.

> 4kB works well. 8kB is perfectly acceptable. 16kB is already wasting a
> lot of memory. 32kB and up is complete garbage for general-purpose
> computing.

I was expecting 16KB pages to work better, but you are right:

arnd:~/linux$ for i in 1 2 4 8 16 32 64 128 256 ; do echo -n "$i KiB pages: " ; total=0 ; git ls-files | xargs ls -ld | while read a b c d e f ; do echo $[((e + $i*1024 - 1) / (1024 * $i))  ]  ; done | sort -n | uniq -c | while read num size ; do total=$[$total + ($num * $size) * $i] ; echo $[total / 1024] MiB ; done  | tail -n 1 ; done
1 KiB pages: 544 MiB
2 KiB pages: 571 MiB
4 KiB pages: 628 MiB
8 KiB pages: 759 MiB
16 KiB pages: 1055 MiB
32 KiB pages: 1717 MiB
64 KiB pages: 3141 MiB
128 KiB pages: 6103 MiB
256 KiB pages: 12125 MiB

Regarding ARM64 in particular, I think it would be nice to investigate
how to extend the THP code to cover 64KB TLBs when running with the 4KB
page size. There is a hint bit in the page table to tell the CPU that
a set of 16 aligned pages can share one TLB, and it would be nice to
use that bit in Linux, and to make this case more common for anonymous
mappings, and possible large file based mappings.

	Arnd

  parent reply	other threads:[~2015-01-10 20:16 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CA+55aFwsxoyLb9OWMSCL3doe_cz_EQtKsEFCyPUYn_T87pbz0A@mail.gmail.com>
2015-01-08 12:51 ` Linux 3.19-rc3 Mark Langsdorf
2015-01-08 13:45   ` Catalin Marinas
2015-01-08 17:29     ` Mark Langsdorf
2015-01-08 17:34       ` Catalin Marinas
2015-01-08 18:48         ` Mark Langsdorf
2015-01-08 19:21           ` Linus Torvalds
2015-01-09 23:27             ` Catalin Marinas
2015-01-10  0:35               ` Kirill A. Shutemov
2015-01-10  2:27                 ` Linus Torvalds
2015-01-10  2:51                   ` David Lang
2015-01-10  3:06                     ` Linus Torvalds
2015-01-10 10:46                       ` Andreas Mohr
2015-01-10 19:42                         ` Linus Torvalds
2015-01-13  3:33                     ` Rik van Riel
2015-01-13 10:28                       ` Catalin Marinas
2015-01-10  3:17                   ` Tony Luck
2015-01-10 20:16                   ` Arnd Bergmann [this message]
2015-01-10 21:00                     ` Linus Torvalds
2015-01-10 21:36                       ` Arnd Bergmann
2015-01-10 21:48                         ` Linus Torvalds
2015-01-12 11:37                         ` Kirill A. Shutemov
2015-01-12 12:18                         ` Catalin Marinas
2015-01-12 13:57                           ` Arnd Bergmann
2015-01-12 14:23                             ` Catalin Marinas
2015-01-12 15:42                               ` Arnd Bergmann
2015-01-12 11:53                     ` Catalin Marinas
2015-01-12 13:15                       ` Arnd Bergmann
2015-01-08 15:08   ` Michal Hocko
2015-01-08 16:37     ` Mark Langsdorf
2015-01-09 15:56       ` Michal Hocko
2015-01-09 12:13   ` Mark Rutland
2015-01-09 14:19     ` Steve Capper
2015-01-09 14:27       ` Mark Langsdorf
2015-01-09 17:57         ` Mark Rutland
2015-01-09 18:37           ` Marc Zyngier
2015-01-09 19:43             ` Will Deacon
2015-01-10  3:29               ` Laszlo Ersek
2015-01-10  4:39                 ` Linus Torvalds
2015-01-10 13:37                   ` Will Deacon
2015-01-10 19:47                     ` Laszlo Ersek
2015-01-10 19:56                       ` Linus Torvalds
2015-01-10 20:08                         ` Laszlo Ersek
2015-01-10 19:51                     ` Linus Torvalds
2015-01-12 12:42                       ` Will Deacon
2015-01-12 13:22                         ` Mark Langsdorf
2015-01-12 19:03                         ` Dave Hansen
2015-01-12 19:06                         ` Linus Torvalds
2015-01-12 19:07                           ` Linus Torvalds
2015-01-12 19:24                             ` Will Deacon
2015-01-10 15:22                 ` Kyle McMartin

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=4665410.x9Uu42bKmJ@wuerfel \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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