streamline_config.pl: add LOCALMODCONFIG_PRESERVE to preserve some kconfigs
Subsystems (3)
PATCH 1/1 streamline_config.pl: add LOCALMODCONFIG_PRESERVE to preserve some kconfigs
Sometimes it is useful to preserve batches of configs when making localmodconfig. For example, I usually don't want any usb and fs modules to be disabled. Now we can do it by:
$ make LOCALMODCONFIG_PRESERVE="drivers/usb;fs" localmodconfig
--- Documentation/admin-guide/README.rst | 8 +++++++- scripts/kconfig/streamline_config.pl | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)
Documentation/admin-guide/README.rst +7 -1
@@ -209,10 +209,16 @@ Configuring the kernel store the lsmod of that machine into a file and pass it in as a LSMOD parameter. + Also, you can preserve modules in certen folders + or kconfig files by spcifying there paths in + parameter LOCALMODCONFIG_PRESERVE. + target$ lsmod > /tmp/mylsmod target$ scp /tmp/mylsmod host:/tmp - host$ make LSMOD=/tmp/mylsmod localmodconfig + host$ make LSMOD=/tmp/mylsmod \ + LOCALMODCONFIG_PRESERVE="drivers/usb;drivers/gpu;fs" \ + localmodconfig The above also works when cross compiling.
scripts/kconfig/streamline_config.pl +23 -0
@@ -143,6 +143,7 @@ my %depends; my %selects; my %prompts; my %objects; +my %config2kfile; my $var; my $iflevel = 0; my @ifdeps;
@@ -201,6 +202,7 @@ sub read_kconfig { if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; + $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) {
@@ -592,6 +594,22 @@ while ($repeat) { my %setconfigs; +my @presevered_kconfigs; +@presevered_kconfigs = split(/;/,$ENV{LOCALMODCONFIG_PRESERVE}) if (defined($ENV{LOCALMODCONFIG_PRESERVE})); + +sub in_presevered_kconfigs { + my $kconfig = $config2kfile{$_[0]}; + if (!defined($kconfig)) { + return 0; + } + foreach my $excl (@presevered_kconfigs) { + if($kconfig =~ /^$excl/) { + return 1; + } + } + return 0; +} + # Finally, read the .config file and turn off any module enabled that # we could not find a reason to keep enabled. foreach my $line (@config_file) {
@@ -644,6 +662,11 @@ foreach my $line (@config_file) { } if (/^(CONFIG.*)=(m|y)/) { + if (in_presevered_kconfigs($1)) { + dprint "Preserve config $1"; + print; + next; + } if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y';
Signature · 1 line
2.25.1
Randy Dunlap
reviewerQuoted 17 lines · Changbin Du
Sometimes it is useful to preserve batches of configs when making localmodconfig. For example, I usually don't want any usb and fs modules to be disabled. Now we can do it by:
$ make LOCALMODCONFIG_PRESERVE="drivers/usb;fs" localmodconfigSigned-off-by Changbin Du <[email protected]>--- Documentation/admin-guide/README.rst | 8 +++++++- scripts/kconfig/streamline_config.pl | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)Documentation/admin-guide/README.rst +0
-0
Documentation/admin-guide/README.rst Configuring the kernel · line 212
Quoted 4 lines
Documentation/admin-guide/README.rst +1
-0@@ -209,10 +209,16 @@ Configuring the kernel store the lsmod of that machine into a file and pass it in as a LSMOD parameter. + Also, you can preserve modules in certen folders
typo: certain
Documentation/admin-guide/README.rst Configuring the kernel · line 213
Quoted 1 line
Documentation/admin-guide/README.rst +1
-0+ or kconfig files by spcifying there paths in
again: specifying their
Quoted 68 lines
Documentation/admin-guide/README.rst +5
-1+ parameter LOCALMODCONFIG_PRESERVE. + target$ lsmod > /tmp/mylsmod target$ scp /tmp/mylsmod host:/tmp - host$ make LSMOD=/tmp/mylsmod localmodconfig + host$ make LSMOD=/tmp/mylsmod \ + LOCALMODCONFIG_PRESERVE="drivers/usb;drivers/gpu;fs" \ + localmodconfig The above also works when cross compiling.scripts/kconfig/streamline_config.pl +23
-0@@ -143,6 +143,7 @@ my %depends; my %selects; my %prompts; my %objects; +my %config2kfile; my $var; my $iflevel = 0; my @ifdeps;@@ -201,6 +202,7 @@ sub read_kconfig { if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; + $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) {@@ -592,6 +594,22 @@ while ($repeat) { my %setconfigs; +my @presevered_kconfigs; +@presevered_kconfigs = split(/;/,$ENV{LOCALMODCONFIG_PRESERVE}) if (defined($ENV{LOCALMODCONFIG_PRESERVE})); + +sub in_presevered_kconfigs { + my $kconfig = $config2kfile{$_[0]}; + if (!defined($kconfig)) { + return 0; + } + foreach my $excl (@presevered_kconfigs) { + if($kconfig =~ /^$excl/) { + return 1; + } + } + return 0; +} + # Finally, read the .config file and turn off any module enabled that # we could not find a reason to keep enabled. foreach my $line (@config_file) {@@ -644,6 +662,11 @@ foreach my $line (@config_file) { } if (/^(CONFIG.*)=(m|y)/) { + if (in_presevered_kconfigs($1)) { + dprint "Preserve config $1"; + print; + next; + } if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y';
Signature · 2 lines
~Randy Reported-by: Randy Dunlap <[email protected]>
Quoted 5 lines · On Fri, 1 May 2020 10:37:08 +0800 Changbin Du <[email protected]> wrote:
Sometimes it is useful to preserve batches of configs when making localmodconfig. For example, I usually don't want any usb and fs modules to be disabled. Now we can do it by:
$ make LOCALMODCONFIG_PRESERVE="drivers/usb;fs" localmodconfig
That's too much typing ;-) What about just "KEEP='drivers/usb;fs'"?
Quoted 74 lines
Signed-off-by Changbin Du <[email protected]>--- Documentation/admin-guide/README.rst | 8 +++++++- scripts/kconfig/streamline_config.pl | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)Documentation/admin-guide/README.rst +7
-1@@ -209,10 +209,16 @@ Configuring the kernel store the lsmod of that machine into a file and pass it in as a LSMOD parameter. + Also, you can preserve modules in certen folders + or kconfig files by spcifying there paths in + parameter LOCALMODCONFIG_PRESERVE. + target$ lsmod > /tmp/mylsmod target$ scp /tmp/mylsmod host:/tmp - host$ make LSMOD=/tmp/mylsmod localmodconfig + host$ make LSMOD=/tmp/mylsmod \ + LOCALMODCONFIG_PRESERVE="drivers/usb;drivers/gpu;fs" \ + localmodconfig The above also works when cross compiling.scripts/kconfig/streamline_config.pl +18
-0@@ -143,6 +143,7 @@ my %depends; my %selects; my %prompts; my %objects; +my %config2kfile; my $var; my $iflevel = 0; my @ifdeps;@@ -201,6 +202,7 @@ sub read_kconfig { if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; + $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) {@@ -592,6 +594,22 @@ while ($repeat) { my %setconfigs; +my @presevered_kconfigs; +@presevered_kconfigs = split(/;/,$ENV{LOCALMODCONFIG_PRESERVE}) if (defined($ENV{LOCALMODCONFIG_PRESERVE})); + +sub in_presevered_kconfigs { + my $kconfig = $config2kfile{$_[0]}; + if (!defined($kconfig)) { + return 0; + } + foreach my $excl (@presevered_kconfigs) { + if($kconfig =~ /^$excl/) { + return 1; + } + } + return 0; +} + # Finally, read the .config file and turn off any module enabled that # we could not find a reason to keep enabled. foreach my $line (@config_file) {@@ -644,6 +662,11 @@ foreach my $line (@config_file) { }
scripts/kconfig/streamline_config.pl foreach my $line (@config_file) { · line 672
Quoted 10 lines
scripts/kconfig/streamline_config.pl +5
-0if (/^(CONFIG.*)=(m|y)/) { + if (in_presevered_kconfigs($1)) { + dprint "Preserve config $1"; + print; + next; + } if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y';
I'll have to test it out, but I like the idea!
-- Steve
Quoted 21 lines · Randy Dunlap
Quoted 20 lines · Changbin Du
Sometimes it is useful to preserve batches of configs when making localmodconfig. For example, I usually don't want any usb and fs modules to be disabled. Now we can do it by:
$ make LOCALMODCONFIG_PRESERVE="drivers/usb;fs" localmodconfigSigned-off-by Changbin Du <[email protected]>--- Documentation/admin-guide/README.rst | 8 +++++++- scripts/kconfig/streamline_config.pl | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)Documentation/admin-guide/README.rst +0
-0@@ -209,10 +209,16 @@ Configuring the kernel store the lsmod of that machine into a file and pass it in as a LSMOD parameter.
Quoted 8 lines
Documentation/admin-guide/README.rst Configuring the kernel · line 212
Quoted 1 line
Documentation/admin-guide/README.rst +1
-0+ Also, you can preserve modules in certen folderstypo: certain
Documentation/admin-guide/README.rst Configuring the kernel · line 213
Quoted 1 line
Documentation/admin-guide/README.rst +1
-0+ or kconfig files by spcifying there paths inagain: specifying their
Thank you, I will fix them.
Quoted 73 lines
Quoted 68 lines
Documentation/admin-guide/README.rst +5
-1+ parameter LOCALMODCONFIG_PRESERVE. + target$ lsmod > /tmp/mylsmod target$ scp /tmp/mylsmod host:/tmp - host$ make LSMOD=/tmp/mylsmod localmodconfig + host$ make LSMOD=/tmp/mylsmod \ + LOCALMODCONFIG_PRESERVE="drivers/usb;drivers/gpu;fs" \ + localmodconfig The above also works when cross compiling.scripts/kconfig/streamline_config.pl +23
-0@@ -143,6 +143,7 @@ my %depends; my %selects; my %prompts; my %objects; +my %config2kfile; my $var; my $iflevel = 0; my @ifdeps;@@ -201,6 +202,7 @@ sub read_kconfig { if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; + $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) {@@ -592,6 +594,22 @@ while ($repeat) { my %setconfigs; +my @presevered_kconfigs; +@presevered_kconfigs = split(/;/,$ENV{LOCALMODCONFIG_PRESERVE}) if (defined($ENV{LOCALMODCONFIG_PRESERVE})); + +sub in_presevered_kconfigs { + my $kconfig = $config2kfile{$_[0]}; + if (!defined($kconfig)) { + return 0; + } + foreach my $excl (@presevered_kconfigs) { + if($kconfig =~ /^$excl/) { + return 1; + } + } + return 0; +} + # Finally, read the .config file and turn off any module enabled that # we could not find a reason to keep enabled. foreach my $line (@config_file) {@@ -644,6 +662,11 @@ foreach my $line (@config_file) { } if (/^(CONFIG.*)=(m|y)/) { + if (in_presevered_kconfigs($1)) { + dprint "Preserve config $1"; + print; + next; + } if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y';Signature · 2 lines
~Randy Reported-by: Randy Dunlap <[email protected]>
Signature · 2 lines
Cheers, Changbin Du
Quoted 11 lines · Steven Rostedt
Quoted 5 lines · On Fri, 1 May 2020 10:37:08 +0800 Changbin Du <[email protected]> wrote:
Sometimes it is useful to preserve batches of configs when making localmodconfig. For example, I usually don't want any usb and fs modules to be disabled. Now we can do it by:
$ make LOCALMODCONFIG_PRESERVE="drivers/usb;fs" localmodconfigThat's too much typing ;-) What about just "KEEP='drivers/usb;fs'"?
I think we'd better use a long name since it will be passed to the entire kbuild. And we alreay have one named LOCALMODCONFIG_DEBUG. The prefix LOCALMODCONFIG_ can help to avoid namespace pollution.
Quoted 89 lines
Quoted 75 lines
Signed-off-by Changbin Du <[email protected]>--- Documentation/admin-guide/README.rst | 8 +++++++- scripts/kconfig/streamline_config.pl | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)Documentation/admin-guide/README.rst +7
-1@@ -209,10 +209,16 @@ Configuring the kernel store the lsmod of that machine into a file and pass it in as a LSMOD parameter. + Also, you can preserve modules in certen folders + or kconfig files by spcifying there paths in + parameter LOCALMODCONFIG_PRESERVE. + target$ lsmod > /tmp/mylsmod target$ scp /tmp/mylsmod host:/tmp - host$ make LSMOD=/tmp/mylsmod localmodconfig + host$ make LSMOD=/tmp/mylsmod \ + LOCALMODCONFIG_PRESERVE="drivers/usb;drivers/gpu;fs" \ + localmodconfig The above also works when cross compiling.scripts/kconfig/streamline_config.pl +18
-0@@ -143,6 +143,7 @@ my %depends; my %selects; my %prompts; my %objects; +my %config2kfile; my $var; my $iflevel = 0; my @ifdeps;@@ -201,6 +202,7 @@ sub read_kconfig { if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; + $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) {@@ -592,6 +594,22 @@ while ($repeat) { my %setconfigs; +my @presevered_kconfigs; +@presevered_kconfigs = split(/;/,$ENV{LOCALMODCONFIG_PRESERVE}) if (defined($ENV{LOCALMODCONFIG_PRESERVE})); + +sub in_presevered_kconfigs { + my $kconfig = $config2kfile{$_[0]}; + if (!defined($kconfig)) { + return 0; + } + foreach my $excl (@presevered_kconfigs) { + if($kconfig =~ /^$excl/) { + return 1; + } + } + return 0; +} + # Finally, read the .config file and turn off any module enabled that # we could not find a reason to keep enabled. foreach my $line (@config_file) {@@ -644,6 +662,11 @@ foreach my $line (@config_file) { }scripts/kconfig/streamline_config.pl foreach my $line (@config_file) { · line 672
Quoted 10 lines
scripts/kconfig/streamline_config.pl +5
-0if (/^(CONFIG.*)=(m|y)/) { + if (in_presevered_kconfigs($1)) { + dprint "Preserve config $1"; + print; + next; + } if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y';I'll have to test it out, but I like the idea!
-- Steve
Signature · 2 lines
Cheers, Changbin Du
Quoted 11 lines · On Sat, 2 May 2020 21:30:54 +0800 Changbin Du <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Sometimes it is useful to preserve batches of configs when making localmodconfig. For example, I usually don't want any usb and fs modules to be disabled. Now we can do it by:
$ make LOCALMODCONFIG_PRESERVE="drivers/usb;fs" localmodconfigThat's too much typing ;-) What about just "KEEP='drivers/usb;fs'"?
I think we'd better use a long name since it will be passed to the entire kbuild. And we alreay have one named
LOCALMODCONFIG_DEBUG. The prefixLOCALMODCONFIG_can help to avoid namespace pollution.
I politely disagree. Build options is not common. The LOCALMODCONFIG_DEBUG is an environment variable, which I couldn't just use DEBUG.
If you absolutely require a prefix, shorten it to LMC_ or something. I already hate typing 'localmodconfig' once ;-)
-- Steve
Hi, Steven,
Quoted 11 lines · Steven Rostedt
Quoted 8 lines · On Sat, 2 May 2020 21:30:54 +0800 Changbin Du <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Sometimes it is useful to preserve batches of configs when making localmodconfig. For example, I usually don't want any usb and fs modules to be disabled. Now we can do it by:
$ make LOCALMODCONFIG_PRESERVE="drivers/usb;fs" localmodconfigThat's too much typing ;-) What about just "KEEP='drivers/usb;fs'"?
Quoted 8 lines
Quoted 3 lines
I think we'd better use a long name since it will be passed to the entire kbuild. And we alreay have one named
LOCALMODCONFIG_DEBUG. The prefixLOCALMODCONFIG_can help to avoid namespace pollution.I politely disagree. Build options is not common. The
LOCALMODCONFIG_DEBUGis an environment variable, which I couldn't just use DEBUG.
This is what I am worried about since LOCALMODCONFIG_PRESERVE also is an environment variable. A short name possibly overwrite internal kbuild variables.
Quoted 3 lines
If you absolutely require a prefix, shorten it to
LMC_or something. I already hate typing 'localmodconfig' once ;-)
I undstand your pain. This why I never type 'localmodconfig' but copy it from 'make help' :). Maybe we can get more inputs from others.
Quoted 1 line
-- Steve
Signature · 2 lines
Cheers, Changbin Du