From 3f04e7ddf47a1c821dfaa886161d94774af583fa Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 8 Nov 2005 21:34:46 -0800 Subject: [PATCH] kconfig: Fix Kconfig performance bug When doing its recursive dependency check, scripts/kconfig/conf uses the flag SYMBOL_CHECK_DONE to avoid rechecking a symbol it has already checked. However, that flag is only set at the top level, so if a symbol is first encountered as a dependency of another symbol it will be rechecked every time it is encountered until it's encountered at the top level. This patch adjusts the flag setting so that each symbol will only be checked once, regardless of whether it is first encountered at the top level, or while recursing down from another symbol. On complex configurations, this vastly speeds up scripts/kconfig/conf. The config in the powerpc merge tree is particularly bad: this patch reduces the time for 'scripts/kconfig/conf -o arch/powerpc/Kconfig' by a factor of 40 on a G5. That's even including the time to print the config, so the speedup in the actual checking is more likely 2 or 3 orders of magnitude. Signed-off-by: David Gibson Signed-off-by: Roman Zippel Cc: Sam Ravnborg Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/kconfig/symbol.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'scripts/kconfig/symbol.c') diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index affa52f5c65..10d96c4188d 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -731,12 +731,12 @@ struct symbol *sym_check_deps(struct symbol *sym) struct symbol *sym2; struct property *prop; - if (sym->flags & SYMBOL_CHECK_DONE) - return NULL; if (sym->flags & SYMBOL_CHECK) { printf("Warning! Found recursive dependency: %s", sym->name); return sym; } + if (sym->flags & SYMBOL_CHECKED) + return NULL; sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); sym2 = sym_check_expr_deps(sym->rev_dep.expr); @@ -756,8 +756,13 @@ struct symbol *sym_check_deps(struct symbol *sym) goto out; } out: - if (sym2) + if (sym2) { printf(" %s", sym->name); + if (sym2 == sym) { + printf("\n"); + sym2 = NULL; + } + } sym->flags &= ~SYMBOL_CHECK; return sym2; } -- cgit v1.2.3