linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mel@csn.ul.ie>
To: linux-mm@kvack.org
Cc: Mel Gorman <mel@csn.ul.ie>,
	linux-kernel@vger.kernel.org, lhms-devel@lists.sourceforge.net
Subject: [PATCH 3/5] x86 - Specify amount of kernel memory at boot time
Date: Thu, 19 Jan 2006 19:09:01 +0000 (GMT)	[thread overview]
Message-ID: <20060119190901.16909.62307.sendpatchset@skynet.csn.ul.ie> (raw)
In-Reply-To: <20060119190846.16909.14133.sendpatchset@skynet.csn.ul.ie>

This patch was originally written by Kamezawa Hiroyuki.

It should be possible for the administrator to specify at boot-time how much
memory should be used for the kernel and how much should go to ZONE_EASYRCLM.
After this patch is applied, the boot option kernelcore= can be used to
specify how much memory should be used by the kernel.

(Note that Kamezawa called this parameter coremem= . This was renamed because
of the way ppc64 parses command line arguments and would confuse coremem=
with mem=. The name was chosen that could be used across architectures)

The value of kernelcore is important. If it is too small, there will be more
pressure on ZONE_NORMAL and a potential loss of performance. If it is about
896MB, it means that ZONE_HIGHMEM will have a size of zero. Any differences in
tests will depend on whether CONFIG_HIGHPTE is set in the standard kernel or
not. With lots of memory, the ideal is to specify a kernelcore that gives
ZONE_NORMAL it's full size and a ZONE_HIGHMEM for PTEs. The right value
depends, like any tunable, on the workload.

It is also important to note that if kernelcore is less than the maximum
size of ZONE_NORMAL, GFP_HIGHMEM allocations will use ZONE_NORMAL, not the
reachable portion of ZONE_EASYRCLM.

Signed-off-by: Mel Gorman <mel@csn.ul.ie>
diff -rup -X /usr/src/patchset-0.5/bin//dontdiff linux-2.6.16-rc1-mm1-102_addzone/arch/i386/kernel/setup.c linux-2.6.16-rc1-mm1-103_x86coremem/arch/i386/kernel/setup.c
--- linux-2.6.16-rc1-mm1-102_addzone/arch/i386/kernel/setup.c	2006-01-19 11:21:57.000000000 +0000
+++ linux-2.6.16-rc1-mm1-103_x86coremem/arch/i386/kernel/setup.c	2006-01-19 11:44:49.000000000 +0000
@@ -121,6 +121,9 @@ int bootloader_type;
 /* user-defined highmem size */
 static unsigned int highmem_pages = -1;
 
+/* user-defined easy-reclaim-size */
+static unsigned int core_mem_pages = -1;
+static unsigned int easyrclm_pages = 0;
 /*
  * Setup options
  */
@@ -921,6 +924,15 @@ static void __init parse_cmdline_early (
 		 */
 		else if (!memcmp(from, "vmalloc=", 8))
 			__VMALLOC_RESERVE = memparse(from+8, &from);
+		 /*
+		  * kernelcore=size sets the amount of memory for use for
+		  * kernel allocations that cannot be reclaimed easily.
+		  * The remaining memory is set aside for easy reclaim
+	          * for features like memory remove or huge page allocations
+		  */
+		else if (!memcmp(from, "kernelcore=",11)) {
+			core_mem_pages = memparse(from + 11, &from) >> PAGE_SHIFT;
+		}
 
 	next_char:
 		c = *(from++);
@@ -990,6 +1002,17 @@ void __init find_max_pfn(void)
 	}
 }
 
+unsigned long  __init calculate_core_memory(unsigned long max_low_pfn)
+{
+	if (max_low_pfn < core_mem_pages) {
+		highmem_pages -= (core_mem_pages - max_low_pfn);
+	} else {
+		max_low_pfn = core_mem_pages;
+		highmem_pages = 0;
+	}
+	easyrclm_pages = max_pfn - core_mem_pages;
+	return max_low_pfn;
+}
 /*
  * Determine low and high memory ranges:
  */
@@ -1046,6 +1069,8 @@ unsigned long __init find_max_low_pfn(vo
 			printk(KERN_ERR "ignoring highmem size on non-highmem kernel!\n");
 #endif
 	}
+	if (core_mem_pages != -1)
+		max_low_pfn = calculate_core_memory(max_low_pfn);
 	return max_low_pfn;
 }
 
@@ -1166,7 +1191,8 @@ void __init zone_sizes_init(void)
 		zones_size[ZONE_DMA] = max_dma;
 		zones_size[ZONE_NORMAL] = low - max_dma;
 #ifdef CONFIG_HIGHMEM
-		zones_size[ZONE_HIGHMEM] = highend_pfn - low;
+		zones_size[ZONE_HIGHMEM] = highend_pfn - low - easyrclm_pages;
+		zones_size[ZONE_EASYRCLM] = easyrclm_pages;
 #endif
 	}
 	free_area_init(zones_size);

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

  parent reply	other threads:[~2006-01-19 19:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-19 19:08 [PATCH 0/5] Reducing fragmentation using zones Mel Gorman
2006-01-19 19:08 ` [PATCH 1/5] Add __GFP_EASYRCLM flag and update callers Mel Gorman
2006-01-19 19:08 ` [PATCH 2/5] Create the ZONE_EASYRCLM zone Mel Gorman
2006-01-19 19:09 ` Mel Gorman [this message]
2006-01-19 19:09 ` [PATCH 4/5] ppc64 - Specify amount of kernel memory at boot time Mel Gorman
2006-01-19 19:09 ` [PATCH 5/5] ForTesting - Prevent OOM killer firing for high-order allocations Mel Gorman
2006-01-19 19:24 ` [PATCH 0/5] Reducing fragmentation using zones Joel Schopp
2006-01-20  0:13   ` [Lhms-devel] " KAMEZAWA Hiroyuki
2006-01-20  1:09     ` Mel Gorman
2006-01-20  1:25       ` KAMEZAWA Hiroyuki
2006-01-20  9:44         ` Mel Gorman
2006-01-20 10:40           ` KAMEZAWA Hiroyuki
2006-01-20 14:53             ` Mel Gorman
2006-01-20 18:10               ` Kamezawa Hiroyuki
2006-01-20 12:08           ` Yasunori Goto
2006-01-20 12:25             ` Mel Gorman
2006-01-20 13:22               ` Yasunori Goto
2006-01-20  0:42   ` Mel Gorman
2006-01-20  1:18     ` KAMEZAWA Hiroyuki
2006-01-20 12:03       ` Mel Gorman
2006-01-20 13:28         ` [Lhms-devel] " Yasunori Goto
2006-01-20 14:02           ` Mel Gorman

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=20060119190901.16909.62307.sendpatchset@skynet.csn.ul.ie \
    --to=mel@csn.ul.ie \
    --cc=lhms-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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