Re: [PATCH] mask ADT: replace cpumask_t implementation [3/22]

Matthew Dobson
2004-04-01T20:41:51Z

On Thu, 2004-04-01 at 07:22, Paul Jackson wrote:
> > > #define cpu_online_map cpumask_of_cpu(0)
> > > #define cpu_possible_map cpumask_of_cpu(0)
> > > ...
> > Might it make more sense to actually define a cpu_online_map &
> > cpu_possible_map for UP, rather than generating this code:
> >
> > #define mask_of_bit(bit, T) \
> > ({ \
> > typeof(T) m; \
> > mask_clearall(m); \
> > mask_setbit((bit), m); \
> > m; \
> > })
> >
> > every time some code references cpu_online_map? It'll only cost us 2
> > unsigned longs on 32-bit == 8 bytes...
>
> Perhaps.
>
> When I looked at the code just now, this only seemed to take a
> couple of instructions. Do you think that there is much to gain?
> Better a couple of inline instructions than a possible uncached
> memory reference, I suspect.

Yeah, you may be right about that.

On UP it should compile as such:

cpu_online_map => cpumask_of_cpu(0) =>
mask_of_bit(0, _unused_cpumask_arg_) =>
({ typeof(_unused_cpumask_arg_) m; mask_clearall(m); mask_setbit(0, m);
m; }) =>
({ cpumask_t m; m._m[0] = 0UL; set_bit(0, m._m); m; })

Maybe we could #define it better on UP. Something along the lines of:

#define cpu_online_map ({ cpumask_t up_cpu_map = { 1UL }; })

That way we'll get this inlined, plus very little code to execute?

Cheers!

-Matt