From: Stefan Bader <stefan.bader@canonical.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org,
Eric Dumazet <eric.dumazet@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Andy Whitcroft <apw@canonical.com>
Subject: Re: fs/stat: Reduce memory requirements for stat_open
Date: Tue, 08 Jul 2014 15:30:43 +0200 [thread overview]
Message-ID: <53BBF283.40202@canonical.com> (raw)
In-Reply-To: <20140708130958.GG6758@twins.programming.kicks-ass.net>
[-- Attachment #1: Type: text/plain, Size: 2034 bytes --]
On 08.07.2014 15:09, Peter Zijlstra wrote:
> On Thu, Jun 12, 2014 at 03:00:17PM +0200, Stefan Bader wrote:
>> When reading from /proc/stat we allocate a large buffer to maximise
>> the chances of the results being from a single run and thus internally
>> consistent. This currently is sized at 128 * num_possible_cpus() which,
>> in the face of kernels sized to handle large configurations (256 cpus
>> plus), results in the buffer being an order-4 allocation or more.
>> When system memory becomes fragmented these cannot be guarenteed, leading
>> to read failures due to allocation failures.
>
>> @@ -184,7 +184,7 @@ static int show_stat(struct seq_file *p, void *v)
>>
>> static int stat_open(struct inode *inode, struct file *file)
>> {
>> - size_t size = 1024 + 128 * num_possible_cpus();
>> + size_t size = 1024 + 128 * num_online_cpus();
>> char *buf;
>> struct seq_file *m;
>> int res;
>
> Old thread, and already solved in the meantime, but note that
> CONFIG_NR_CPUS _should_ have no reflection on num_possible_cpus().
>
> The arch (x86 does) should detect at boot time the max possible CPUs the
> actual hardware supports and put num_possible_cpus() to that number. So
> your typical laptop will mostly have num_possible_cpus() <= 4, even
> though CONFIG_NR_CPUS could be 4k.
>
> Of course, if you actually do put 256+ cpus in your system, well, then
> the difference between possible and online isn't going to help either.
>
> If on the other hand your 'board' reports it can hold 256 CPUs while in
> fact it cannot, go kick your vendor in the nuts.
>
Odd. So at least for the reporter the board must be doing that. For the other
way round at least back then when we did the change, some of the big hoovers
which end up claiming 64 or so CPUs (including threads) would not boot with a
too low CONFIG_NR_CPUS. So that seems to have changed at some point.
But at least this would explain why there have not been too many reports.
Thanks for the detail,
Stefan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]
prev parent reply other threads:[~2014-07-08 13:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-12 13:00 fs/stat: Reduce memory requirements for stat_open Stefan Bader
2014-06-12 13:41 ` Heiko Carstens
2014-06-12 14:02 ` Stefan Bader
2014-06-24 23:44 ` David Rientjes
2014-06-25 7:04 ` Stefan Bader
2014-06-25 22:52 ` David Rientjes
2014-06-25 22:54 ` Andrew Morton
2014-07-08 13:09 ` Peter Zijlstra
2014-07-08 13:30 ` Stefan Bader [this message]
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=53BBF283.40202@canonical.com \
--to=stefan.bader@canonical.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.