Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2478662ybk; Mon, 11 May 2020 23:54:50 -0700 (PDT) X-Google-Smtp-Source: APiQypIWIO+qZHesihM+QztBzt1tray17SR04vrlgZcF4qSl+EhIQ6Cm0VokYVTT7imnokjFhCQe X-Received: by 2002:aa7:c649:: with SMTP id z9mr16842806edr.288.1589266489840; Mon, 11 May 2020 23:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589266489; cv=none; d=google.com; s=arc-20160816; b=v83YiTTazfEBOfGA7oQOMniDRgOjdNGcJ2MdhWf1h80rIPMDlHEkxE9cLEAa+S5sIw atJNPt+cehwgHiuN27mfE5sajWuYaI/rBw6W4jLd56TSPAaYemuSBSel5Fw+U0PPZk2t upLj2pQy1z/Y/VhaAVwEkHWTNqk2Gn5vrPfpJNdh2SX3VgGfFhWJUEoh97Ry0dvhHU6L +kxlZZ2qhTa1fBoV3udGvGL6SuGFXjG8ikgQ6UdvrAkWxvK6l/Jx7xfgDAttQ+GH6jsH 44jXY9kTk7xmHO0RGzj/ritTgp+5RuBosmCJaxAm3ZiyuyT5bvY0aQt6uzQr23qc2ycC VEwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=UwPvBry7yPGOUilCJDkKrbKYyu1A4n8MuWA4AkJQmPc=; b=kh0rEhTljGfVg8oiDvCwSpbFKVjY8rf9492SQOgW4ZUuCWl92HaIwy1hg1WSO76E3r fYJSj/vp/l2fzSh5VS0HBXiXu9/5sqZLLAwS5GUgKd9Vj20vo6DiknE7f6S87hg/URWd gk3Urp652pvj4KsNytrbDWF7Rm3/7rMsk/5kePI7tKMXxM58h8zKMBCJAK7oyVJuN2rr jyQd00QrG7zLpdgwc7jQCq7hmp+3NDusPPQ2vOD6P0nt/qPgd/AI3GS+HDFvgCdFw2x/ Wowp5pXcXVNiXGdhOlt6xvBCigcvkaP9F2+GN6r6M+R8XCR8GWaHX1KSt551liTV0gq7 2C3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=uOyUjH4L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si7420554ejo.146.2020.05.11.23.54.26; Mon, 11 May 2020 23:54:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=uOyUjH4L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728836AbgELGw5 (ORCPT + 99 others); Tue, 12 May 2020 02:52:57 -0400 Received: from conssluserg-02.nifty.com ([210.131.2.81]:64357 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbgELGw4 (ORCPT ); Tue, 12 May 2020 02:52:56 -0400 Received: from mail-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 04C6qeQt027831; Tue, 12 May 2020 15:52:41 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 04C6qeQt027831 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1589266362; bh=UwPvBry7yPGOUilCJDkKrbKYyu1A4n8MuWA4AkJQmPc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=uOyUjH4Lk6Bz11TLsUUQeyavZZNYpk9WP+oUZjYw9IzNsPKYVxy0T28akwEZasKcY 7heuEiz5sbqoaYXxHP1hUQ56FCd/eyvpxbKRFwdHn/D+bdb1unws11xIK3WkA95ZD4 4vsqylaQBd4pp3iToF5CcQbcIHzJ58oi96aTz4TDgydslMNW96eU8PYwUJKvE22D0h pH/6UecfPDadhnrEN9S7dvChDe3PkNX7Wlpahao66CjiXJ/3RFxgaPCn5cLDCGtBlB OIKpLNtF4ghm3YBb8/Zlp6gmrKim94rEI3Oq8elJ4pKgAto4TkPh1loapJFCCLbLL/ WWb9RwgaXkdYQ== X-Nifty-SrcIP: [209.85.217.52] Received: by mail-vs1-f52.google.com with SMTP id z1so7197186vsn.11; Mon, 11 May 2020 23:52:41 -0700 (PDT) X-Gm-Message-State: AGi0PubrEpFYgJZQ8+hxu27bNYOmh5hoYiqqE7Xa4peQyzSvKqFaeYLP cT1NAZokzm3im4jsVoK4I9RdY+XbI5GxIZFqVmg= X-Received: by 2002:a67:db0d:: with SMTP id z13mr14479268vsj.155.1589266360272; Mon, 11 May 2020 23:52:40 -0700 (PDT) MIME-Version: 1.0 References: <20200510010603.3896-1-changbin.du@gmail.com> In-Reply-To: <20200510010603.3896-1-changbin.du@gmail.com> From: Masahiro Yamada Date: Tue, 12 May 2020 15:52:04 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5] streamline_config.pl: add LMC_KEEP to preserve some kconfigs To: Changbin Du Cc: Jonathan Corbet , "open list:DOCUMENTATION" , Steven Rostedt , Linux Kernel Mailing List , Linux Kbuild mailing list , Randy Dunlap Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 10, 2020 at 10:06 AM Changbin Du 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 LMC_KEEP="drivers/usb:fs" localmodconfig > > Signed-off-by: Changbin Du > > --- > v4: fix typo. > v3: rename LOCALMODCONFIG_PRESERVE to shorter LMC_KEEP. > v2: fix typo in documentation. (Randy Dunlap) > --- > Documentation/admin-guide/README.rst | 8 +++++++- > scripts/kconfig/Makefile | 1 + > scripts/kconfig/streamline_config.pl | 21 +++++++++++++++++++++ > 3 files changed, 29 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/README.rst b/Documentation/admin-guide/README.rst > index cc6151fc0845..407aa206bb70 100644 > --- a/Documentation/admin-guide/README.rst > +++ b/Documentation/admin-guide/README.rst > @@ -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 certain folders > + or kconfig files by specifying their paths in > + parameter LMC_KEEP. > + > target$ lsmod > /tmp/mylsmod > target$ scp /tmp/mylsmod host:/tmp > > - host$ make LSMOD=/tmp/mylsmod localmodconfig > + host$ make LSMOD=/tmp/mylsmod \ > + LMC_KEEP="drivers/usb:drivers/gpu:fs" \ > + localmodconfig > > The above also works when cross compiling. > > diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile > index c9d0a4a8efb3..e0abbf5805f5 100644 > --- a/scripts/kconfig/Makefile > +++ b/scripts/kconfig/Makefile > @@ -123,6 +123,7 @@ help: > @echo ' gconfig - Update current config utilising a GTK+ based front-end' > @echo ' oldconfig - Update current config utilising a provided .config as base' > @echo ' localmodconfig - Update current config disabling modules not loaded' > + @echo ' except those preserved by LMC_KEEP environment variable' > @echo ' localyesconfig - Update current config converting local mods to core' Just a nitpicking. I was just about to apply this patch, then noticed this. This works for localyesconfig as well as localmodconfig. Do you want to add the note to localyesconfig too? LMC_ is an acronym of LOCAL_MOD_CONFIG_. Maybe it is OK because we mostly use localmodconfig, using localyesconfig is somewhat rare, I guess. Just a reminder, if you want to send v6 or if you want me to pick this up as-is. Thanks. > @echo ' defconfig - New config with default from ARCH supplied defconfig' > @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' > diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl > index e2f8504f5a2d..19857d18d814 100755 > --- a/scripts/kconfig/streamline_config.pl > +++ b/scripts/kconfig/streamline_config.pl > @@ -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++) { > @@ -591,6 +593,20 @@ while ($repeat) { > } > > my %setconfigs; > +my @preserved_kconfigs = split(/:/,$ENV{LMC_KEEP}); > + > +sub in_preserved_kconfigs { > + my $kconfig = $config2kfile{$_[0]}; > + if (!defined($kconfig)) { > + return 0; > + } > + foreach my $excl (@preserved_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. > @@ -644,6 +660,11 @@ foreach my $line (@config_file) { > } > > if (/^(CONFIG.*)=(m|y)/) { > + if (in_preserved_kconfigs($1)) { > + dprint "Preserve config $1"; > + print; > + next; > + } > if (defined($configs{$1})) { > if ($localyesconfig) { > $setconfigs{$1} = 'y'; > -- > 2.25.1 > -- Best Regards Masahiro Yamada