Commit 3bc50163 by Andi Kleen Committed by Andi Kleen

Use more efficient alignment in ggc

Jakub had some concerns about the performance of page alignments in
ggc-page, which use a hardware division instructions currently.
This patch changes them all to use a new PAGE_ALIGN macro, which
exploits that pages are a power of two.

gcc/:
2011-10-21  Andi Kleen  <ak@linux.intel.com>

	* ggc-page (PAGE_ALIGN): Add.
	(alloc_page, ggc_pch_total_size, ggc_pch_this_base, ggc_pch_read):
	Replace ROUND_UP with PAGE_ALIGN.

From-SVN: r180650
parent 25f0ea81
2011-10-21 Andi Kleen <ak@linux.intel.com>
* ggc-page (PAGE_ALIGN): Add.
(alloc_page, ggc_pch_total_size, ggc_pch_this_base, ggc_pch_read):
Replace ROUND_UP with PAGE_ALIGN.
2011-10-20 Andi Kleen <ak@linux.intel.com> 2011-10-20 Andi Kleen <ak@linux.intel.com>
* ggc-page (alloc_anon): Add check argument. * ggc-page (alloc_anon): Add check argument.
...@@ -221,6 +221,10 @@ static const size_t extra_order_size_table[] = { ...@@ -221,6 +221,10 @@ static const size_t extra_order_size_table[] = {
#define ROUND_UP(x, f) (CEIL (x, f) * (f)) #define ROUND_UP(x, f) (CEIL (x, f) * (f))
/* Round X to next multiple of the page size */
#define PAGE_ALIGN(x) (((x) + G.pagesize - 1) & ~(G.pagesize - 1))
/* The Ith entry is the number of objects on a page or order I. */ /* The Ith entry is the number of objects on a page or order I. */
static unsigned objects_per_page_table[NUM_ORDERS]; static unsigned objects_per_page_table[NUM_ORDERS];
...@@ -739,7 +743,7 @@ alloc_page (unsigned order) ...@@ -739,7 +743,7 @@ alloc_page (unsigned order)
entry_size = num_objects * OBJECT_SIZE (order); entry_size = num_objects * OBJECT_SIZE (order);
if (entry_size < G.pagesize) if (entry_size < G.pagesize)
entry_size = G.pagesize; entry_size = G.pagesize;
entry_size = ROUND_UP (entry_size, G.pagesize); entry_size = PAGE_ALIGN (entry_size);
entry = NULL; entry = NULL;
page = NULL; page = NULL;
...@@ -2236,7 +2240,7 @@ ggc_pch_total_size (struct ggc_pch_data *d) ...@@ -2236,7 +2240,7 @@ ggc_pch_total_size (struct ggc_pch_data *d)
unsigned i; unsigned i;
for (i = 0; i < NUM_ORDERS; i++) for (i = 0; i < NUM_ORDERS; i++)
a += ROUND_UP (d->d.totals[i] * OBJECT_SIZE (i), G.pagesize); a += PAGE_ALIGN (d->d.totals[i] * OBJECT_SIZE (i));
return a; return a;
} }
...@@ -2249,7 +2253,7 @@ ggc_pch_this_base (struct ggc_pch_data *d, void *base) ...@@ -2249,7 +2253,7 @@ ggc_pch_this_base (struct ggc_pch_data *d, void *base)
for (i = 0; i < NUM_ORDERS; i++) for (i = 0; i < NUM_ORDERS; i++)
{ {
d->base[i] = a; d->base[i] = a;
a += ROUND_UP (d->d.totals[i] * OBJECT_SIZE (i), G.pagesize); a += PAGE_ALIGN (d->d.totals[i] * OBJECT_SIZE (i));
} }
} }
...@@ -2442,7 +2446,7 @@ ggc_pch_read (FILE *f, void *addr) ...@@ -2442,7 +2446,7 @@ ggc_pch_read (FILE *f, void *addr)
if (d.totals[i] == 0) if (d.totals[i] == 0)
continue; continue;
bytes = ROUND_UP (d.totals[i] * OBJECT_SIZE (i), G.pagesize); bytes = PAGE_ALIGN (d.totals[i] * OBJECT_SIZE (i));
num_objs = bytes / OBJECT_SIZE (i); num_objs = bytes / OBJECT_SIZE (i);
entry = XCNEWVAR (struct page_entry, (sizeof (struct page_entry) entry = XCNEWVAR (struct page_entry, (sizeof (struct page_entry)
- sizeof (long) - sizeof (long)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment