Patchwork [1/2] Add missing page rounding of a page_entry

login
register
mail settings
Submitter Andi Kleen
Date Oct. 19, 2011, 6:40 a.m.
Message ID <1319006408-6012-1-git-send-email-andi@firstfloor.org>
Download mbox | patch
Permalink /patch/120561/
State New
Headers show

Comments

Andi Kleen - Oct. 19, 2011, 6:40 a.m.
From: Andi Kleen <ak@linux.intel.com>

This one place in ggc forgot to round page_entry->bytes to the
next page boundary, which lead to all the heuristics in freeing to
check for continuous memory failing. Round here too, like all other
allocators already do. The memory consumed should be the same
for MMAP because the kernel would round anyways. It may slightly
increase memory usage when malloc groups are used.

This will also increase the hitrate on the free page list
slightly.

gcc/:

2011-10-18  Andi Kleen  <ak@linux.intel.com>

	* ggc-page.c (alloc_pages): Always round up entry_size.
---
 gcc/ggc-page.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Jakub Jelinek - Oct. 19, 2011, 8:21 a.m.
On Wed, Oct 19, 2011 at 08:40:07AM +0200, Andi Kleen wrote:
> diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
> index 2da99db..ba88e3f 100644
> --- a/gcc/ggc-page.c
> +++ b/gcc/ggc-page.c
> @@ -736,6 +736,7 @@ alloc_page (unsigned order)
>    entry_size = num_objects * OBJECT_SIZE (order);
>    if (entry_size < G.pagesize)
>      entry_size = G.pagesize;
> +  entry_size = ROUND_UP (entry_size, G.pagesize);

Isn't the "if (entry_size < G.pagesize) entry_size = G.pagesize;"
above this now redundant?  I'm fairly sure we never call this with
zero num_objects or zero OBJECT_SIZE (order) and for anything
else ROUND_UP should round < pagesize to pagesize, right?

	Jakub

Patch

diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 2da99db..ba88e3f 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -736,6 +736,7 @@  alloc_page (unsigned order)
   entry_size = num_objects * OBJECT_SIZE (order);
   if (entry_size < G.pagesize)
     entry_size = G.pagesize;
+  entry_size = ROUND_UP (entry_size, G.pagesize);
 
   entry = NULL;
   page = NULL;