Skip to content

Commit 3f04e7d

Browse files
dgibsonLinus Torvalds
authored andcommitted
[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 <david@gibson.dropbear.id.au> Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Cc: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent cecd1ca commit 3f04e7d

4 files changed

Lines changed: 10 additions & 12 deletions

File tree

‎scripts/kconfig/expr.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ struct symbol {
9393
#define SYMBOL_NEW 0x0800
9494
#define SYMBOL_AUTO 0x1000
9595
#define SYMBOL_CHECKED 0x2000
96-
#define SYMBOL_CHECK_DONE 0x4000
9796
#define SYMBOL_WARNED 0x8000
9897

9998
#define SYMBOL_MAXLENGTH 256

‎scripts/kconfig/symbol.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,12 +731,12 @@ struct symbol *sym_check_deps(struct symbol *sym)
731731
struct symbol *sym2;
732732
struct property *prop;
733733

734-
if (sym->flags & SYMBOL_CHECK_DONE)
735-
return NULL;
736734
if (sym->flags & SYMBOL_CHECK) {
737735
printf("Warning! Found recursive dependency: %s", sym->name);
738736
return sym;
739737
}
738+
if (sym->flags & SYMBOL_CHECKED)
739+
return NULL;
740740

741741
sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
742742
sym2 = sym_check_expr_deps(sym->rev_dep.expr);
@@ -756,8 +756,13 @@ struct symbol *sym_check_deps(struct symbol *sym)
756756
goto out;
757757
}
758758
out:
759-
if (sym2)
759+
if (sym2) {
760760
printf(" %s", sym->name);
761+
if (sym2 == sym) {
762+
printf("\n");
763+
sym2 = NULL;
764+
}
765+
}
761766
sym->flags &= ~SYMBOL_CHECK;
762767
return sym2;
763768
}

‎scripts/kconfig/zconf.tab.c_shipped‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,10 +1933,7 @@ void conf_parse(const char *name)
19331933
exit(1);
19341934
menu_finalize(&rootmenu);
19351935
for_all_symbols(i, sym) {
1936-
if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym))
1937-
printf("\n");
1938-
else
1939-
sym->flags |= SYMBOL_CHECK_DONE;
1936+
sym_check_deps(sym);
19401937
}
19411938

19421939
sym_change_count = 1;

‎scripts/kconfig/zconf.y‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,7 @@ void conf_parse(const char *name)
495495
exit(1);
496496
menu_finalize(&rootmenu);
497497
for_all_symbols(i, sym) {
498-
if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym))
499-
printf("\n");
500-
else
501-
sym->flags |= SYMBOL_CHECK_DONE;
498+
sym_check_deps(sym);
502499
}
503500

504501
sym_change_count = 1;

0 commit comments

Comments
 (0)