Re: [PATCH] cpumask 5/10 rewrite cpumask.h - single bitmap based implementation

Paul Jackson
2004-06-04T04:27:22Z

Rusty wrote:
> > +/* No static inline type checking - see Subtlety (1) above. */
> > +#define cpu_isset(cpu, cpumask) test_bit((cpu), (cpumask).bits)
>
> How about something really grungy like:
>
> #define cpu_isset(cpu, cpumask) \
> ({ __typeof__(cpumask) __cpumask; \
> (void)(&__cpumask) == (cpumask_t *)0); \
> test_bit((cpu), (cpumask).bits); })

Well ... we agree on the "grungy" part ... ;).

Your flavor has the same problem as I saw with the static inline nested
inside a #define macro flavor. On i386, SMP, gcc 3.3.2, when the
cpu_isset() is part of a for-loop control, both the normal and 'grungy'
flavors cost one extra jump instruction, whereas the flavor I ended up
using places one chunk of code more optimally, saving a hard jump
instruction.

This saves 196 bytes of kernel text space.

If you can show me a type checked cpu_isset() that generates code
as tight as what I ended up using, let me know.

Or if you would prefer I spend the 196 bytes to get this type checked,
that's worthy of consideration as well.

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373