On Thu, 2013-05-23 at 13:31 -0700, Richard Henderson wrote: > > /* The Ith entry is the number of objects on a page or order I. */ > > > > -static unsigned objects_per_page_table[NUM_ORDERS]; > > +DEFINE_STATIC_STATE_ARRAY(unsigned, objects_per_page_table, NUM_ORDERS) > > > > /* The Ith entry is the size of an object on a page of order I. */ > > > > -static size_t object_size_table[NUM_ORDERS]; > > +DEFINE_STATIC_STATE_ARRAY(size_t, object_size_table, NUM_ORDERS) > > > > /* The Ith entry is a pair of numbers (mult, shift) such that > > ((k * mult) >> shift) mod 2^32 == (k / OBJECT_SIZE(I)) mod 2^32, > > for all k evenly divisible by OBJECT_SIZE(I). */ > > > > -static struct > > +struct inverse_table_def > > { > > size_t mult; > > unsigned int shift; > > -} > > -inverse_table[NUM_ORDERS]; > > +}; > > +DEFINE_STATIC_STATE_ARRAY(inverse_table_def, inverse_table, NUM_ORDERS) > > > > /* A page_entry records the status of an allocation page. This > > structure is dynamically sized to fit the bitmap in_use_p. */ > > @@ -343,7 +346,7 @@ struct free_object > > #endif > > > > /* The rest of the global variables. */ > > -static struct globals > > +struct globals > > { > > /* The Nth element in this array is a page with objects of size 2^N. > > If there are any pages with free objects, they will be at the > > @@ -457,7 +460,11 @@ static struct globals > > /* The overhead for each of the allocation orders. */ > > unsigned long long total_overhead_per_order[NUM_ORDERS]; > > } stats; > > -} G; > > +}; > > + > > +DEFINE_STATIC_STATE(globals, G) > > Be careful here. Note that all of the arrays that you convert are notionally > static constants defining the bucket sizes for the algorithm, except we don't > actually compute them at compile time. They would be true global data shared > by all threads.
I know - but when you have a big hammer, sometimes it's easier just to hit all of the nails, rather than just the ones you need to :) [...]