Subject: /proc/config reducing kernel image size

I've written a small patch that reduces the size of /proc/config.

There is no point in storing all the comments and unused options in the
kernel image. This typically reduces the config size to about 1/5th
before compressing, and to about 1/4th after compressing.

I've also added the configuration option of how you want to compress it.

In order to do the comment stripping I was forced to add a small script
to the scripts, section, this has to be made executable. However if it
is possible, the script should be skipped altogether, but I can't figure
out how to do the proper escaping of the special characters in the
kernel/Makefile. So if anyone could help me with that, I would be
grateful.

I'm interessted in comments on the concept.

Sincerely
--
BFG


Attachments:
linux-2.6.8.1-config-compress-patch.diff (6.54 kB)

2004-09-14 17:28:22

by DervishD

[permalink] [raw]
Subject: Re: /proc/config reducing kernel image size

Hi Tom :)

* Tom Fredrik Blenning Klaussen <[email protected]> dixit:
> There is no point in storing all the comments and unused options in the
> kernel image. This typically reduces the config size to about 1/5th
> before compressing, and to about 1/4th after compressing.

I'm with you in that there is no point in storing the comments,
but I disagree about the unused options. Storing the unused options
as comments is more useful than it seems ;)

Look at this example. You want to know if you have 'CONFIG_PNP'
enabled, so you do something like 'grep CONFIG_PMP /proc/config' (the
typo PNP->PMP is intended here). Of course that commands doesn't
print anything due to the typo. If you store the disabled options as
comments and a grep fails, you probably mispelled the config option,
or you're referring to a config option not present in your old
kernel, but if you remove them and you mispell the config option
there is no (automatic) way of knowing if you made a typo or if the
option is disabled. Any automatic search can, potentially, give you a
false negative.

I'm not really sure about it, but I think that the unset options
are left as comments for the sake of automation. The space saving
doesn't (IMHO) worth the pain.

> I've also added the configuration option of how you want to compress it.

Compression is always welcome, I suppose ;) Thanks for the idea.

Ra?l N??ez de Arenas Coronado

--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/

Subject: Re: /proc/config reducing kernel image size

On Tue, 2004-09-14 at 19:26, DervishD wrote:
> Hi Tom :)
>
> * Tom Fredrik Blenning Klaussen <[email protected]> dixit:
> > There is no point in storing all the comments and unused options in the
> > kernel image. This typically reduces the config size to about 1/5th
> > before compressing, and to about 1/4th after compressing.
>
> I'm with you in that there is no point in storing the comments,
> but I disagree about the unused options. Storing the unused options
> as comments is more useful than it seems ;)

This is why I added a config option.

> Look at this example. You want to know if you have 'CONFIG_PNP'
> enabled, so you do something like 'grep CONFIG_PMP /proc/config' (the
> typo PNP->PMP is intended here). Of course that commands doesn't
> print anything due to the typo. If you store the disabled options as
> comments and a grep fails, you probably mispelled the config option,
> or you're referring to a config option not present in your old
> kernel, but if you remove them and you mispell the config option
> there is no (automatic) way of knowing if you made a typo or if the
> option is disabled. Any automatic search can, potentially, give you a
> false negative.

A small util could easily be written to do the same job, just comparing
it to the default config. Although I agree it's much easier to do a
search like this when it is in it's original form.

> I'm not really sure about it, but I think that the unset options
> are left as comments for the sake of automation. The space saving
> doesn't (IMHO) worth the pain.

I'm not sure either, but I don't know of any programs that uses this.
Putting this config file inside the same source tree as it was compiled
with, and then just starting and stopping menuconfig will restore it to
it's original form.

> > I've also added the configuration option of how you want to compress it.
>
> Compression is always welcome, I suppose ;) Thanks for the idea.

Sincerely
--
BFG

2004-09-14 17:53:05

by Norberto Bensa

[permalink] [raw]
Subject: Re: /proc/config reducing kernel image size

Tom Fredrik Blenning Klaussen wrote:
> There is no point in storing all the comments and unused options in the

Try this:

mv .config .config-saveme
grep -v ^# .config-saveme > .config
make oldconfig

Do you get the exact same kernel (hint: diff .config .config-saveme) ?


Regards,
Norberto

Subject: Re: /proc/config reducing kernel image size

On Tue, 2004-09-14 at 19:44, Norberto Bensa wrote:
> Tom Fredrik Blenning Klaussen wrote:
> > There is no point in storing all the comments and unused options in the
>
> Try this:
>
> mv .config .config-saveme
> grep -v ^# .config-saveme > .config
> make oldconfig
>
> Do you get the exact same kernel (hint: diff .config .config-saveme) ?

You're right.
Am I correct when I say that when an option is not present, it assumes
it's default?

Sincerely
--
BFG

2004-09-14 18:12:53

by DervishD

[permalink] [raw]
Subject: Re: /proc/config reducing kernel image size

Hi Tom :)

* Tom Fredrik Blenning Klaussen <[email protected]> dixit:
> > > There is no point in storing all the comments and unused options in the
> > > kernel image. This typically reduces the config size to about 1/5th
> > > before compressing, and to about 1/4th after compressing.
> > I'm with you in that there is no point in storing the comments,
> > but I disagree about the unused options. Storing the unused options
> > as comments is more useful than it seems ;)
> This is why I added a config option.

But removing the comments is a good idea. Even reformatting the
contents, or something like that.

> > I'm not really sure about it, but I think that the unset options
> > are left as comments for the sake of automation. The space saving
> > doesn't (IMHO) worth the pain.
> I'm not sure either, but I don't know of any programs that uses this.

Neither do I.

> Putting this config file inside the same source tree as it was compiled
> with, and then just starting and stopping menuconfig will restore it to
> it's original form.

That's true.

Ra?l N??ez de Arenas Coronado

--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/

2004-09-14 21:58:44

by Norberto Bensa

[permalink] [raw]
Subject: Re: /proc/config reducing kernel image size

Tom Fredrik Blenning Klaussen wrote:
> On Tue, 2004-09-14 at 19:44, Norberto Bensa wrote:
> > Try this:
>
> You're right.
> Am I correct when I say that when an option is not present, it assumes
> it's default?

Exactly.

Best regards,
Norberto

2004-09-15 10:13:03

by Herbert Poetzl

[permalink] [raw]
Subject: Re: /proc/config reducing kernel image size

On Tue, Sep 14, 2004 at 08:01:24PM +0200, DervishD wrote:
> Hi Tom :)
>
> * Tom Fredrik Blenning Klaussen <[email protected]> dixit:
> > > > There is no point in storing all the comments and unused options in the
> > > > kernel image. This typically reduces the config size to about 1/5th
> > > > before compressing, and to about 1/4th after compressing.
> > > I'm with you in that there is no point in storing the comments,
> > > but I disagree about the unused options. Storing the unused options
> > > as comments is more useful than it seems ;)
> > This is why I added a config option.
>
> But removing the comments is a good idea. Even reformatting the
> contents, or something like that.
>
> > > I'm not really sure about it, but I think that the unset options
> > > are left as comments for the sake of automation. The space saving
> > > doesn't (IMHO) worth the pain.
> > I'm not sure either, but I don't know of any programs that uses this.
>
> Neither do I.

well, the kernel config uses it, to decide if
some option is known, or has to be defaulted/asked

try to remove one of those 'comments' from a config
and run 'make oldconfig', you'll get asked for this
specific option ...

best,
Herbert

> > Putting this config file inside the same source tree as it was compiled
> > with, and then just starting and stopping menuconfig will restore it to
> > it's original form.
>
> That's true.
>
> Ra?l N??ez de Arenas Coronado
>
> --
> Linux Registered User 88736
> http://www.pleyades.net & http://raul.pleyades.net/
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/