From patchwork Mon Jul 30 19:43:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 1256281 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B93BDE00C6 for ; Mon, 30 Jul 2012 19:46:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755121Ab2G3Tpu (ORCPT ); Mon, 30 Jul 2012 15:45:50 -0400 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.122]:19735 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754656Ab2G3TpE (ORCPT ); Mon, 30 Jul 2012 15:45:04 -0400 X-Authority-Analysis: v=2.0 cv=IOWA+3TG c=1 sm=0 a=s5Htg7xnQOKvHEu9STBOug==:17 a=OpT9cpI26MMA:10 a=Ciwy3NGCPMMA:10 a=pGYlzOKfiEwA:10 a=5SG0PmZfjMsA:10 a=bbbx4UPp9XUA:10 a=meVymXHHAAAA:8 a=20KFwNOVAAAA:8 a=qrFA_WvyAAAA:8 a=qJgER5RU2pfj1r0b-p4A:9 a=QEXdDO2ut3YA:10 a=jEp0ucaQiEUA:10 a=bdmcM0_chmsA:10 a=jeBq3FmKZ4MA:10 a=V-Ktq1bX_zgNhkX_:21 a=fQ5rLMVGHjH3bZ7d:21 a=IRZufY1EXczceZzun44A:9 a=s5Htg7xnQOKvHEu9STBOug==:117 X-Cloudmark-Score: 0 X-Originating-IP: 72.230.195.127 Received: from [72.230.195.127] ([72.230.195.127:52003] helo=gandalf.stny.rr.com) by hrndva-oedge02.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id B6/6F-02978-F34E6105; Mon, 30 Jul 2012 19:45:03 +0000 Received: from rostedt by gandalf.stny.rr.com with local (Exim 4.80) (envelope-from ) id 1Svvtm-0002yw-Sj; Mon, 30 Jul 2012 15:45:03 -0400 Message-Id: <20120730194502.828052323@goodmis.org> User-Agent: quilt/0.60-1 Date: Mon, 30 Jul 2012 15:43:19 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: Linus Torvalds Subject: [PATCH 3/4] localmodconfig: Check if configs are already set for selects References: <20120730194316.768288008@goodmis.org> Content-Disposition: inline; filename=0003-localmodconfig-Check-if-configs-are-already-set-for-.patch Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Steven Rostedt There are some cases that a required module does not have a prompt and needs to have another module enabled that selects it to be set. As localmodconfig is conservative and tries to make the minimum config without breaking the user's kernel, or keeping the user from using devices that were loaded when the lsmod was done, all modules that select this module will also be enabled. If you needed module A, but module A did not have a prompt but needed module B to be selected, localmodconfig would make sure B was still enabled. If not only B selected A, but C, D, E, F, and G also selected A, then all of those would also be included, as well as the modules they depend on. This ballooned the number of configs that localmodconfig would keep. The fix here is to process the depends first, and then record those configs that did not have a prompt and needed to be selected. After the depends are done, check what configs are needed to select the configs in the list, and if a config that selects it is already set, then we don't need to do anything else. If no config that selects the config is set, then just pick one and try again. This change brought down the number of selected modules from 290 to 67! Both before and after were run against a config that had 3095 modules enabled. Tested-by: John David Yost # AlleyTrotter Signed-off-by: Steven Rostedt --- scripts/kconfig/streamline_config.pl | 115 ++++++++++++++++++++++++++++++---- 1 file changed, 104 insertions(+), 11 deletions(-) diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index ab4985f..fcfcb30 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -420,7 +420,7 @@ my $repeat = 1; # to keep on. If A was on in the original config, B would not have been # and B would not be turned on by this script. # -sub parse_config_dep_select +sub parse_config_depends { my ($p) = @_; @@ -448,26 +448,119 @@ sub parse_config_dep_select } } -while ($repeat) { - $repeat = 0; +# Select is treated a bit differently than depends. We call this +# when a config has no prompt and requires another config to be +# selected. We use to just select all configs that selected this +# config, but found that that can balloon into enabling hundreds +# of configs that we do not care about. +# +# The idea is we look at all the configs that select it. If one +# is already in our list of configs to enable, then there's nothing +# else to do. If there isn't, we pick the first config that was +# enabled in the orignal config and use that. +sub parse_config_selects +{ + my ($config, $p) = @_; - foreach my $config (keys %configs) { - $config =~ s/^CONFIG_//; + my $next_config; + + while ($p =~ /[$valid]/) { + + if ($p =~ /^[^$valid]*([$valid]+)/) { + my $conf = "CONFIG_" . $1; + + $p =~ s/^[^$valid]*[$valid]+//; - if (defined($depends{$config})) { - # This config has dependencies. Make sure they are also included - parse_config_dep_select $depends{$config}; + # Make sure that this config exists in the current .config file + if (!defined($orig_configs{$conf})) { + next; + } + + # Check if something other than a module selects this config + if (defined($orig_configs{$conf}) && $orig_configs{$conf} ne "m") { + # we are good with this + return; + } + if (defined($configs{$conf})) { + # A set config selects this config, we are good + return; + } + # Set this config to be selected + if (!defined($next_config)) { + $next_config = $conf; + } + } else { + die "this should never happen"; } + } - if (defined($prompts{$config}) || !defined($selects{$config})) { - next; + # If no possible config selected this, then something happened. + if (!defined($next_config)) { + print STDERR "WARNING: $config is required, but nothing in the\n"; + print STDERR " current config selects it.\n"; + return; + } + + # If we are here, then we found no config that is set and + # selects this config. Repeat. + $repeat = 1; + # Make this config need to be selected + $configs{$next_config} = 1; +} + +my %process_selects; + +# loop through all configs, select their dependencies. +sub loop_depend { + $repeat = 1; + + while ($repeat) { + $repeat = 0; + + forloop: + foreach my $config (keys %configs) { + + # If this config is not a module, we do not need to process it + if (defined($orig_configs{$config}) && $orig_configs{$config} ne "m") { + next forloop; + } + + $config =~ s/^CONFIG_//; + + if (defined($depends{$config})) { + # This config has dependencies. Make sure they are also included + parse_config_depends $depends{$config}; + } + + # If the config has no prompt, then we need to check if a config + # that is enabled selected it. Or if we need to enable one. + if (!defined($prompts{$config}) && defined($selects{$config})) { + $process_selects{$config} = 1; + } } + } +} + +sub loop_select { + + foreach my $config (keys %process_selects) { + $config =~ s/^CONFIG_//; # config has no prompt and must be selected. - parse_config_dep_select $selects{$config}; + parse_config_selects $config, $selects{$config}; } } +while ($repeat) { + # Get the first set of configs and their dependencies. + loop_depend; + + $repeat = 0; + + # Now we need to see if we have to check selects; + loop_select; +} + my %setconfigs; # Finally, read the .config file and turn off any module enabled that