From: Chris Snook <csnook@redhat.com>
To: Matt Mackall <mpm@selenic.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
akpm <akpm@linuxfoundation.org>
Subject: Re: Bloatwatch 2.6.28-rc1: last_sysfs_file
Date: Mon, 27 Oct 2008 12:50:03 -0400 [thread overview]
Message-ID: <4905F13B.6000406@redhat.com> (raw)
In-Reply-To: <1225123898.3199.20.camel@calx>
Matt Mackall wrote:
> On Sat, 2008-10-25 at 06:38 -0400, Chris Snook wrote:
>> Matt Mackall wrote:
>>> On Fri, 2008-10-24 at 15:52 -0500, Matt Mackall wrote:
>>>> 2.6.28-rc1 adds 4k for last_sysfs_file debug tracking. That's one hell
>>>> of a long sysfs path.
>>>>
>>>> http://www.selenic.com/bloatwatch/?cmd=compare;v1=2.6.27;v2=2.6.28-rc1;part=/built-in/fs/sysfs
>>> ..especially given that printk is limited to 1k at a time.
>>>
>>>
>>> sysfs: shrink last_sysfs_file to a reasonable size
>>>
>>> sysfs was reserving 4k to store filenames for debug despite printk being
>>> limited to 1k. Shrink this to something more reasonable.
>>>
>>> Signed-off-by: Matt Mackall <mpm@selenic.com>
>>>
>>> diff -r ac8c82ff3be7 fs/sysfs/file.c
>>> --- a/fs/sysfs/file.c Fri Oct 24 13:13:04 2008 -0500
>>> +++ b/fs/sysfs/file.c Fri Oct 24 16:11:53 2008 -0500
>>> @@ -25,7 +25,7 @@
>>> #include "sysfs.h"
>>>
>>> /* used in crash dumps to help with debugging */
>>> -static char last_sysfs_file[PATH_MAX];
>>> +static char last_sysfs_file[200]; /* allow for disgustingly long paths */
>>> void sysfs_printk_last_file(void)
>>> {
>>> printk(KERN_EMERG "last sysfs file: %s\n", last_sysfs_file);
>>>
>>>
>> Please don't use magic numbers. Use a symbolic constant, and modify printk.c to
>> use the same.
>
> I'm explicitly not using a magic number because the relevant magic
> number is absurdly large. It is in fact 4 times larger than printk can
> print. And its 40 times larger than any path we are liable to encounter.
> Inventing a new use-once #define meaning "good enough for debugging
> 99.99% of sysfs bugs" one line up is not an improvement here.
>
> And why on earth would I modify anything in printk?
Because the 1024 limit is a created by an array declaration in printk.c, which
uses the number 1024. Instead, put something like this in a header file:
#define PRINTK_MAX 1024
Now use that in printk.c where the buffer is declared, and again in sysfs/file.c
where last_sysfs_file is defined, in place of PATH_MAX. 1024 isn't nearly as
bad as 4096. If you desperately need it to be even smaller, you might want to
make the printk buffer a CONFIG option to live under CONFIG_EMBEDDED, which
could be taken advantage of elsewhere in the kernel as well.
Arbitrarily clamping critical debugging features to limits pulled out of one's
ass is generally frowned upon. If you can justify some limit lower than the
length of the printk buffer, great, but "I want to save a few hundred bytes of
RAM, total" is insufficient, unless you want to restrict it to the
CONFIG_EMBEDDED world.
-- Chris
next prev parent reply other threads:[~2008-10-27 16:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-24 20:51 Bloatwatch 2.6.28-rc1: last_sysfs_file Matt Mackall
2008-10-24 21:15 ` Matt Mackall
2008-10-25 10:38 ` Chris Snook
2008-10-27 16:11 ` Matt Mackall
2008-10-27 16:50 ` Chris Snook [this message]
2008-10-27 17:46 ` Matt Mackall
2008-10-27 18:16 ` Chris Snook
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=4905F13B.6000406@redhat.com \
--to=csnook@redhat.com \
--cc=akpm@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
/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;
as well as URLs for NNTP newsgroup(s).