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

From: Paul Jackson
Date: Thu Jun 03 2004 - 23:29:42 EST


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@xxxxxxx> 1.650.933.1373
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/