linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Christopher Lameter <cl@linux.com>
Cc: Michal Hocko <mhocko@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Vlastimil Babka <vbabka@suse.cz>, Mel Gorman <mgorman@suse.de>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-doc@vger.kernel.org
Subject: Re: [patch 1/2] mm, page_alloc: extend kernelcore and movablecore for percent
Date: Thu, 15 Feb 2018 12:14:05 -0800	[thread overview]
Message-ID: <20180215201405.GA22948@bombadil.infradead.org> (raw)
In-Reply-To: <alpine.DEB.2.20.1802150947240.1902@nuc-kabylake>

On Thu, Feb 15, 2018 at 09:49:00AM -0600, Christopher Lameter wrote:
> On Thu, 15 Feb 2018, Matthew Wilcox wrote:
> 
> > What if ... on startup, slab allocated a MAX_ORDER page for itself.
> > It would then satisfy its own page allocation requests from this giant
> > page.  If we start to run low on memory in the rest of the system, slab
> > can be induced to return some of it via its shrinker.  If slab runs low
> > on memory, it tries to allocate another MAX_ORDER page for itself.
> 
> The inducing of releasing memory back is not there but you can run SLUB
> with MAX_ORDER allocations by passing "slab_min_order=9" or so on bootup.

Maybe we should try this patch in order to automatically scale the slub
page size with the amount of memory in the machine?

diff --git a/mm/internal.h b/mm/internal.h
index e6bd35182dae..7059a8389194 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -167,6 +167,7 @@ extern void prep_compound_page(struct page *page, unsigned int order);
 extern void post_alloc_hook(struct page *page, unsigned int order,
 					gfp_t gfp_flags);
 extern int user_min_free_kbytes;
+extern unsigned long __meminitdata nr_kernel_pages;
 
 #if defined CONFIG_COMPACTION || defined CONFIG_CMA
 
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ef9c259db041..3c51bb22403f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -264,7 +264,7 @@ int min_free_kbytes = 1024;
 int user_min_free_kbytes = -1;
 int watermark_scale_factor = 10;
 
-static unsigned long __meminitdata nr_kernel_pages;
+unsigned long __meminitdata nr_kernel_pages;
 static unsigned long __meminitdata nr_all_pages;
 static unsigned long __meminitdata dma_reserve;
 
diff --git a/mm/slub.c b/mm/slub.c
index e381728a3751..abca4a6e9b6c 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4194,6 +4194,23 @@ void __init kmem_cache_init(void)
 
 	if (debug_guardpage_minorder())
 		slub_max_order = 0;
+	if (slub_min_order == 0) {
+		unsigned long numentries = nr_kernel_pages;
+
+		/*
+		 * Above 4GB, we start to care more about fragmenting large
+		 * pages than about using the minimum amount of memory.
+		 * Scale the slub page size at half the rate that we scale
+		 * the memory size; at 4GB we double the page size to 8k,
+		 * 16GB to 16k, 64GB to 32k, 256GB to 64k.
+		 */
+		while (numentries > (4UL << 30)) {
+			if (slub_min_order >= slub_max_order)
+				break;
+			slub_min_order++;
+			numentries /= 4;
+		}
+	}
 
 	kmem_cache_node = &boot_kmem_cache_node;
 	kmem_cache = &boot_kmem_cache;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2018-02-15 20:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-13  0:24 [patch 1/2] mm, page_alloc: extend kernelcore and movablecore for percent David Rientjes
2018-02-13  0:24 ` [patch 2/2] mm, page_alloc: move mirrored_kernelcore to __meminitdata David Rientjes
2018-02-13 23:46 ` [patch 1/2] mm, page_alloc: extend kernelcore and movablecore for percent Andrew Morton
2018-02-13 23:55   ` David Rientjes
2018-02-14  1:14     ` Andrew Morton
2018-02-14  0:37 ` Mike Kravetz
2018-02-14  0:53   ` David Rientjes
2018-02-14  1:00     ` [patch -mm] mm, page_alloc: extend kernelcore and movablecore for percent fix David Rientjes
2018-02-14  1:10       ` Mike Kravetz
2018-02-14  9:59 ` [patch 1/2] mm, page_alloc: extend kernelcore and movablecore for percent Michal Hocko
2018-02-14 10:28   ` David Rientjes
2018-02-15 14:45     ` Michal Hocko
2018-02-15 15:11       ` Matthew Wilcox
2018-02-15 15:49         ` Christopher Lameter
2018-02-15 20:14           ` Matthew Wilcox [this message]
2018-02-16 15:41             ` Christopher Lameter
2018-02-15 20:48           ` Matthew Wilcox
2018-02-16  0:45             ` David Rientjes
2018-02-16 15:44             ` Christopher Lameter
2018-02-16 16:01               ` Matthew Wilcox
2018-02-16 16:08                 ` Christopher Lameter
2018-02-16 17:09                   ` Matthew Wilcox
2018-02-15 20:47       ` David Rientjes

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=20180215201405.GA22948@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@kernel.org \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    /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).