public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Giacomo A. Catenazzi" <cate@cateee.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: diet-kconfig: a script to trim unneeded kconfigs
Date: Thu, 18 Sep 2008 22:09:18 +0200	[thread overview]
Message-ID: <s5hljxpusgh.wl%tiwai@suse.de> (raw)
In-Reply-To: <48D25F4E.4050405@cateee.net>

At Thu, 18 Sep 2008 16:01:50 +0200,
Giacomo A. Catenazzi wrote:
> 
> Takashi Iwai wrote:
> > Hi,
> > 
> > a topic that just came up in kernel summit is a script to remove
> > unneeded kernel configs automatically to reduce the compile time.
> > Incidentally, I already wrote such a script during the last SUSE hack
> > week a couple of weeks ago, so I'd like to share here, hopefully to
> > give an idea for further improvements.
> > 
> > The script checks the currently loaded modules and trims other
> > CONFIG_XXX=m simply, and tries make oldconfig, and writes out the
> > resultant .config in the current directory after some checks. 
> > You can specify the config file via option,  as default, it reads from
> > /proc/config.gz. 
> > 
> > The script is VERY hackish.  I should have begun with perl or whatever
> > better script language, but I chose bash and co.  So, don't expect
> > much code quality.  I'm no script guy after all :)
> 
> Check my AutoKernConf (http://cateee.net/autokernconf/), it has
> huge (and automatically generated) database about drivers, modules,
> and configuration, and it gives a minimal kernel configuration for the
> most of the hardware hardware.
> 
> It needs a real maintainer and tools for non-hardware drivers
> (fs, net, ...) and special hardware (CPU capabilities,
> architecture specific drivers, etc).

Thanks, this looks good.  Nice to see other people already working
on a similar issue.

> > subarch=$(uname -i)
> 
> -i is wrong (gives "unkwnown" on Debian).
> Check the main Makefile how to extract the architecture from uname.

Oh yeah, another hackish thing...

> > 	c)
> > 	    oldconfig="$OPTARG"
> > 	    if [ ! -f "$oldconfig" ]; then
> > 		echo "Cannot find old config $oldconfig"
> > 		exit 1
> > 	    fi
> 
> Check also the config-* in /boot

OK, such distro specific things have to be handled better.  I didn't
know of /boot/config-* at all.

OTOH, if /proc/config.gz exists, it's the right place to see because
of an obvious reason.   So, checking other paths should be a kind of
fallback.

> > find_kconfig () {
> >     module=$1
> >     modregex=$(echo $1 | sed -e's/_/[_-]/g')
> > 
> >     grep -E '^[[:space:]]*obj-\$\([A-Za-z0-9_]*\)[[:space:]]*[+:]=.*[[:space:]]'"$modregex"'\.o' $tmpd/makefiles | \
> > 	sed -e's/^.*://g' -e's/^[[:space:]]*obj-\$(\(.*\)).*$/\1/g'
> > }
> 
> My python code works better (handle "alias", etc.).

We don't need to handle alias because the whole module names
come from lsmod output.  That's so simple.
OTOH, I don't think the parsing in my script is perfect at all,
though.  It's a result of one or two hours hack.
Improving that function a bit more robust would be pretty helpful.

Regarding the kernel config database: it's nice, indeed.
But, I don't think the whole database is required for the task I tried
to achieve.  It wasn't intended to create a kernel config from
scratch.  It's not necessarily the absolute minimum.  Instead, it just
trims the unnecessary module builds.  For that purpose, the database
is not needed by assumption of the all required modules have been
loaded.  This is rather a safer option than creating a minimum kconfig
from scratch.


thanks,

Takashi

  reply	other threads:[~2008-09-18 20:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-16 23:55 diet-kconfig: a script to trim unneeded kconfigs Takashi Iwai
2008-09-18 14:01 ` Giacomo A. Catenazzi
2008-09-18 20:09   ` Takashi Iwai [this message]
2008-09-18 15:25 ` Mauro Carvalho Chehab
2008-09-18 15:43   ` Giacomo A. Catenazzi
2008-09-18 16:27     ` Mauro Carvalho Chehab
2008-09-19  9:12       ` Giacomo A. Catenazzi
2008-09-19 16:01         ` Takashi Iwai
2008-09-19 23:55           ` Chris Li
2008-09-19 23:57             ` Chris Li
2008-09-22 10:01             ` Takashi Iwai
2008-09-22 13:39               ` Giacomo A. Catenazzi
2008-09-22 15:41                 ` Steven Rostedt
2008-09-22 15:50                   ` Takashi Iwai
2008-09-22 19:25               ` Chris Li
2008-09-23 11:31                 ` Takashi Iwai
2008-09-23 18:15                   ` Chris Li
2008-09-23 18:50                     ` Takashi Iwai
2008-09-23 19:40                       ` Chris Li
2008-09-18 20:20     ` Takashi Iwai
2008-09-18 20:17   ` Takashi Iwai
2008-09-18 21:09     ` Valdis.Kletnieks
2008-09-18 22:14       ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hljxpusgh.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=cate@cateee.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox