Re: [GIT PULL] perf fixes

From: Ingo Molnar
Date: Thu Sep 12 2013 - 16:31:28 EST



* Arnaldo Carvalho de Melo <acme@xxxxxxxxxxxxxxxxxx> wrote:

> Em Thu, Sep 12, 2013 at 12:58:28PM -0700, David Ahern escreveu:
> > On 9/12/13 11:43 AM, Arnaldo Carvalho de Melo wrote:
> >
> > > Its something that annoys me as well, but not so much as to make me
> > > figure out how to make those be done only if some source file
> > > changed.
> >
> > Jiri and I have both taken stabs at a config-based build rather than
> > probing. Just need to finish it.
>
> But even then it would be nice to have a:
>
> make autoconfig
>
> That is what we have now, but only then we would try to do all that
> probing. Caching it somehow, as Ingo suggested, would get the best of
> both worlds.

Caching should be relatively straightforward: I'd suggest splitting up all
the feature tests current present in tools/perf/config/feature-tests.mak
into separate .c files which build into working binaries.

Instead of having 20 testcases crammed into a single Makefile:

comet:~/tip/tools/perf> git grep -w main config/feature-tests.mak
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(int argc, char *argv[])
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)
config/feature-tests.mak:int main(void)

Why not put those into 20x standalone .c files and try to build them as an
explicit make command attempt from within the main Makefile? If the build
fails then the feature flag is set to off, if it succeeds it's defined.

That makes feature tests generally easier to debug, easier to understand
and generally easier to extend as well.

'Feature test binaries' that are already built will be 'cached'
automatically, and the result of their build attempt will be a quick
success.

This is relatively simple, well-known, powerful and I see no reason why it
wouldn't work. No separate config language or special files are needed -
just .c files, binaries and a Makefile.

'make clean' would get rid of the binaries.

[ It could even be made to work against package removal if we really
wanted to: if there's a common, known include file related to the
feature (such as /usr/include/libaudit.h), then that include file
could be added to the feature-test binary's list of dependencies. If the
package is removed and the include file goes away, then the dependency
breaks automatically and the binary is 'rebuilt', auto-detecting the
failed dependency. ]

Thanks,

Ingo
--
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/