Commit eb25b5b2 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] Fix up compiler inefficiencies

Oh, bugger...

The recent mmzone.h change triggered some very, very ugly things in
next_zone(), is_highmem(), is_normal() and zone_idx() because it changed
the size of "struct zone" subtly.

Pointer subtraction is no fun when sizeof of object gets weird and poor
gcc blows its brains out trying to optimize that...  This slowed down an
ARM cross-build by a factor of 2.5. 

Turn the pointer subtraction tests into pointer addition tests instead
where possible, making them trivial to deal with (and gets better code,
in addition to faster compile).

zone_idx() still does a subtraction.
parent 1e95245b
...@@ -311,7 +311,7 @@ static inline struct zone *next_zone(struct zone *zone) ...@@ -311,7 +311,7 @@ static inline struct zone *next_zone(struct zone *zone)
{ {
pg_data_t *pgdat = zone->zone_pgdat; pg_data_t *pgdat = zone->zone_pgdat;
if (zone - pgdat->node_zones < MAX_NR_ZONES - 1) if (zone < pgdat->node_zones + MAX_NR_ZONES - 1)
zone++; zone++;
else if (pgdat->pgdat_next) { else if (pgdat->pgdat_next) {
pgdat = pgdat->pgdat_next; pgdat = pgdat->pgdat_next;
...@@ -357,12 +357,12 @@ static inline int is_normal_idx(int idx) ...@@ -357,12 +357,12 @@ static inline int is_normal_idx(int idx)
*/ */
static inline int is_highmem(struct zone *zone) static inline int is_highmem(struct zone *zone)
{ {
return (is_highmem_idx(zone - zone->zone_pgdat->node_zones)); return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM;
} }
static inline int is_normal(struct zone *zone) static inline int is_normal(struct zone *zone)
{ {
return (is_normal_idx(zone - zone->zone_pgdat->node_zones)); return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL;
} }
/* These two functions are used to setup the per zone pages min values */ /* These two functions are used to setup the per zone pages min values */
......
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