diff mbox

[3/6] kconfig: do not call conf_set_all_new_symbols() for (all)defconfig

Message ID 1515567374-12722-3-git-send-email-yamada.masahiro@socionext.com (mailing list archive)
State New, archived
Headers show

Commit Message

Masahiro Yamada Jan. 10, 2018, 6:56 a.m. UTC
(all)defconfig does not need to call conf_set_all_new_symbols() because
conf_write() calculates all symbols based on their default unless they
have been user-defined.

conf_set_all_new_symbols(def_default) is no-op except for "choice".
It calls sym_cal_value() for "choice", but the SYMBOL_VALID is cleared
by set_all_choice_values() later on.  So, conf_write() will re-calculate
it, which is just a wasteful computation.  The only difference I see
is SYMBOL_DEF_USER flag for "choice", but it gives no difference to the
resulted .config file.

I confirmed this change still produced the same .config for all ARCH.

I also moved savedefconfig to collect the no-op cases at the end of
the switch statement.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 scripts/kconfig/conf.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Ulf Magnusson Jan. 12, 2018, 2:28 p.m. UTC | #1
On Wed, Jan 10, 2018 at 7:56 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> (all)defconfig does not need to call conf_set_all_new_symbols() because
> conf_write() calculates all symbols based on their default unless they
> have been user-defined.
>
> conf_set_all_new_symbols(def_default) is no-op except for "choice".
> It calls sym_cal_value() for "choice", but the SYMBOL_VALID is cleared
> by set_all_choice_values() later on.  So, conf_write() will re-calculate
> it, which is just a wasteful computation.  The only difference I see
> is SYMBOL_DEF_USER flag for "choice", but it gives no difference to the
> resulted .config file.
>
> I confirmed this change still produced the same .config for all ARCH.
>
> I also moved savedefconfig to collect the no-op cases at the end of
> the switch statement.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  scripts/kconfig/conf.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
> index 52cbe5d..8364811 100644
> --- a/scripts/kconfig/conf.c
> +++ b/scripts/kconfig/conf.c
> @@ -655,18 +655,10 @@ int main(int ac, char **av)
>         case allmodconfig:
>                 conf_set_all_new_symbols(def_mod);
>                 break;
> -       case alldefconfig:
> -               conf_set_all_new_symbols(def_default);
> -               break;
>         case randconfig:
>                 /* Really nothing to do in this loop */
>                 while (conf_set_all_new_symbols(def_random)) ;
>                 break;
> -       case defconfig:
> -               conf_set_all_new_symbols(def_default);
> -               break;
> -       case savedefconfig:
> -               break;
>         case oldaskconfig:
>                 rootEntry = &rootmenu;
>                 conf(&rootmenu);
> @@ -681,7 +673,10 @@ int main(int ac, char **av)
>                         check_conf(&rootmenu);
>                 } while (conf_cnt && input_mode != listnewconfig);
>                 break;
> +       case alldefconfig:
> +       case defconfig:
>         case olddefconfig:
> +       case savedefconfig:
>         default:
>                 break;
>         }
> --
> 2.7.4
>

Another side effect of conf_set_all_new_symbols(def_default) is that
SYMBOL_NEED_SET_CHOICE_VALUES is set on all choice values. Might want
to check fbe98bb9ed3d ("kconfig: Fix defconfig when one choice menu
selects options that another choice menu depends on") to make sure
nothing breaks related to that.

Cheers,
Ulf
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada Jan. 16, 2018, 4:47 p.m. UTC | #2
Hi Ulf,

2018-01-12 23:28 GMT+09:00 Ulf Magnusson <ulfalizer@gmail.com>:
> On Wed, Jan 10, 2018 at 7:56 AM, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> (all)defconfig does not need to call conf_set_all_new_symbols() because
>> conf_write() calculates all symbols based on their default unless they
>> have been user-defined.
>>
>> conf_set_all_new_symbols(def_default) is no-op except for "choice".
>> It calls sym_cal_value() for "choice", but the SYMBOL_VALID is cleared
>> by set_all_choice_values() later on.  So, conf_write() will re-calculate
>> it, which is just a wasteful computation.  The only difference I see
>> is SYMBOL_DEF_USER flag for "choice", but it gives no difference to the
>> resulted .config file.
>>
>> I confirmed this change still produced the same .config for all ARCH.
>>
>> I also moved savedefconfig to collect the no-op cases at the end of
>> the switch statement.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> ---
>>
>>  scripts/kconfig/conf.c | 11 +++--------
>>  1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
>> index 52cbe5d..8364811 100644
>> --- a/scripts/kconfig/conf.c
>> +++ b/scripts/kconfig/conf.c
>> @@ -655,18 +655,10 @@ int main(int ac, char **av)
>>         case allmodconfig:
>>                 conf_set_all_new_symbols(def_mod);
>>                 break;
>> -       case alldefconfig:
>> -               conf_set_all_new_symbols(def_default);
>> -               break;
>>         case randconfig:
>>                 /* Really nothing to do in this loop */
>>                 while (conf_set_all_new_symbols(def_random)) ;
>>                 break;
>> -       case defconfig:
>> -               conf_set_all_new_symbols(def_default);
>> -               break;
>> -       case savedefconfig:
>> -               break;
>>         case oldaskconfig:
>>                 rootEntry = &rootmenu;
>>                 conf(&rootmenu);
>> @@ -681,7 +673,10 @@ int main(int ac, char **av)
>>                         check_conf(&rootmenu);
>>                 } while (conf_cnt && input_mode != listnewconfig);
>>                 break;
>> +       case alldefconfig:
>> +       case defconfig:
>>         case olddefconfig:
>> +       case savedefconfig:
>>         default:
>>                 break;
>>         }
>> --
>> 2.7.4
>>
>
> Another side effect of conf_set_all_new_symbols(def_default) is that
> SYMBOL_NEED_SET_CHOICE_VALUES is set on all choice values. Might want
> to check fbe98bb9ed3d ("kconfig: Fix defconfig when one choice menu
> selects options that another choice menu depends on") to make sure
> nothing breaks related to that.
>
> Cheers,
> Ulf
> --

Thanks for your comments!

From a quick test, this patch seems OK,
but I need to take a closer look at this.
diff mbox

Patch

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 52cbe5d..8364811 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -655,18 +655,10 @@  int main(int ac, char **av)
 	case allmodconfig:
 		conf_set_all_new_symbols(def_mod);
 		break;
-	case alldefconfig:
-		conf_set_all_new_symbols(def_default);
-		break;
 	case randconfig:
 		/* Really nothing to do in this loop */
 		while (conf_set_all_new_symbols(def_random)) ;
 		break;
-	case defconfig:
-		conf_set_all_new_symbols(def_default);
-		break;
-	case savedefconfig:
-		break;
 	case oldaskconfig:
 		rootEntry = &rootmenu;
 		conf(&rootmenu);
@@ -681,7 +673,10 @@  int main(int ac, char **av)
 			check_conf(&rootmenu);
 		} while (conf_cnt && input_mode != listnewconfig);
 		break;
+	case alldefconfig:
+	case defconfig:
 	case olddefconfig:
+	case savedefconfig:
 	default:
 		break;
 	}