From: Andres Salomon <dilinger@queued.net>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: devicetree-discuss@lists.ozlabs.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: OLPC: speed up device tree creation during boot
Date: Wed, 27 Oct 2010 10:50:52 -0700 [thread overview]
Message-ID: <20101027105052.23aa1c17@queued.net> (raw)
In-Reply-To: <20101027103924.GB7822@angua.secretlab.ca>
On Wed, 27 Oct 2010 11:39:24 +0100
Grant Likely <grant.likely@secretlab.ca> wrote:
> On Fri, Oct 22, 2010 at 05:22:47PM -0700, Andres Salomon wrote:
> >
> > Calling alloc_bootmem() for tiny chunks of memory over and over is
> > really slow; on an XO-1, it caused the time between when the kernel
> > started booting and when the display came alive (post-lxfb probe)
> > to increase to 44s. This patch optimizes the prom_early_alloc
> > function by calling alloc_bootmem for 4k-sized blocks of memory,
> > and handing out chunks of that to callers. With this hack, the
> > time between kernel load and display initialization decreased to
> > 23s. If there's a better way to do this early in the boot process,
> > please let me know.
> >
> > (Note: increasing the chunk size to 16k didn't noticably affect
> > boot time, and wasted 9k.)
> >
> > Signed-off-by: Andres Salomon <dilinger@queued.net>
> > ---
> > arch/x86/kernel/olpc_dt.c | 27 +++++++++++++++++++++++----
> > 1 files changed, 23 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/kernel/olpc_dt.c b/arch/x86/kernel/olpc_dt.c
> > index f660a11..44dd2ae 100644
> > --- a/arch/x86/kernel/olpc_dt.c
> > +++ b/arch/x86/kernel/olpc_dt.c
> > @@ -123,16 +123,35 @@ static int __init olpc_dt_pkg2path(phandle
> > node, char *buf, }
> >
> > static unsigned int prom_early_allocated __initdata;
> > +#define DT_CHUNK_SIZE (1<<12)
>
> PAGE_SIZE perhaps?
>
I'd rather not imply that it's anything but completely arbitrary..
> >
> > void * __init prom_early_alloc(unsigned long size)
> > {
> > + static u8 *mem = NULL;
> > + static size_t free_mem = 0;
> > void *res;
> >
> > - res = alloc_bootmem(size);
> > - if (res)
> > - memset(res, 0, size);
> > + if (free_mem >= size) {
> > + /* allocate from the local cache */
> > + free_mem -= size;
> > + res = mem;
> > + mem += size;
> > + return res;
> > + }
> >
> > - prom_early_allocated += size;
> > + /*
> > + * To mimimize the number of allocations, grab 4k of
> > memory (that's
> > + * an arbitrary choice that matches PAGE_SIZE on the
> > platforms we care
> > + * about, and minimizes wasted bootmem) and hand off
> > chunks of it to
> > + * callers.
> > + */
> > + res = alloc_bootmem(DT_CHUNK_SIZE);
> > + if (res) {
> > + prom_early_allocated += DT_CHUNK_SIZE;
> > + memset(res, 0, DT_CHUNK_SIZE);
> > + free_mem = DT_CHUNK_SIZE - size;
> > + mem = res + size;
> > + }
>
> These two hunks should be flipped around so that only one chunk does
> the allocation from the pool. As so:
>
> /*
> * To mimimize the number of allocations, grab 4k of memory
> (that's
> * an arbitrary choice that matches PAGE_SIZE on the
> platforms we care
> * about, and minimizes wasted bootmem) and hand off chunks
> of it to
> * callers.
> */
> if (free_mem < size) {
> free_mem = max(DT_CHUNK_SIZE, size);
> mem = alloc_bootmem(free_mem);
> if (!mem) {
> free_mem = 0;
> return NULL;
> }
> memset(mem, 0, free_mem);
> prom_early_allocated += free_mem;
> }
>
> res = mem;
> free_mem -= size;
> mem += size;
> return res;
>
> g.
Makes sense, thanks.
WARNING: multiple messages have this Message-ID (diff)
From: Andres Salomon <dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
To: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
"H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH] x86: OLPC: speed up device tree creation during boot
Date: Wed, 27 Oct 2010 10:50:52 -0700 [thread overview]
Message-ID: <20101027105052.23aa1c17@queued.net> (raw)
In-Reply-To: <20101027103924.GB7822-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
On Wed, 27 Oct 2010 11:39:24 +0100
Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
> On Fri, Oct 22, 2010 at 05:22:47PM -0700, Andres Salomon wrote:
> >
> > Calling alloc_bootmem() for tiny chunks of memory over and over is
> > really slow; on an XO-1, it caused the time between when the kernel
> > started booting and when the display came alive (post-lxfb probe)
> > to increase to 44s. This patch optimizes the prom_early_alloc
> > function by calling alloc_bootmem for 4k-sized blocks of memory,
> > and handing out chunks of that to callers. With this hack, the
> > time between kernel load and display initialization decreased to
> > 23s. If there's a better way to do this early in the boot process,
> > please let me know.
> >
> > (Note: increasing the chunk size to 16k didn't noticably affect
> > boot time, and wasted 9k.)
> >
> > Signed-off-by: Andres Salomon <dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
> > ---
> > arch/x86/kernel/olpc_dt.c | 27 +++++++++++++++++++++++----
> > 1 files changed, 23 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/kernel/olpc_dt.c b/arch/x86/kernel/olpc_dt.c
> > index f660a11..44dd2ae 100644
> > --- a/arch/x86/kernel/olpc_dt.c
> > +++ b/arch/x86/kernel/olpc_dt.c
> > @@ -123,16 +123,35 @@ static int __init olpc_dt_pkg2path(phandle
> > node, char *buf, }
> >
> > static unsigned int prom_early_allocated __initdata;
> > +#define DT_CHUNK_SIZE (1<<12)
>
> PAGE_SIZE perhaps?
>
I'd rather not imply that it's anything but completely arbitrary..
> >
> > void * __init prom_early_alloc(unsigned long size)
> > {
> > + static u8 *mem = NULL;
> > + static size_t free_mem = 0;
> > void *res;
> >
> > - res = alloc_bootmem(size);
> > - if (res)
> > - memset(res, 0, size);
> > + if (free_mem >= size) {
> > + /* allocate from the local cache */
> > + free_mem -= size;
> > + res = mem;
> > + mem += size;
> > + return res;
> > + }
> >
> > - prom_early_allocated += size;
> > + /*
> > + * To mimimize the number of allocations, grab 4k of
> > memory (that's
> > + * an arbitrary choice that matches PAGE_SIZE on the
> > platforms we care
> > + * about, and minimizes wasted bootmem) and hand off
> > chunks of it to
> > + * callers.
> > + */
> > + res = alloc_bootmem(DT_CHUNK_SIZE);
> > + if (res) {
> > + prom_early_allocated += DT_CHUNK_SIZE;
> > + memset(res, 0, DT_CHUNK_SIZE);
> > + free_mem = DT_CHUNK_SIZE - size;
> > + mem = res + size;
> > + }
>
> These two hunks should be flipped around so that only one chunk does
> the allocation from the pool. As so:
>
> /*
> * To mimimize the number of allocations, grab 4k of memory
> (that's
> * an arbitrary choice that matches PAGE_SIZE on the
> platforms we care
> * about, and minimizes wasted bootmem) and hand off chunks
> of it to
> * callers.
> */
> if (free_mem < size) {
> free_mem = max(DT_CHUNK_SIZE, size);
> mem = alloc_bootmem(free_mem);
> if (!mem) {
> free_mem = 0;
> return NULL;
> }
> memset(mem, 0, free_mem);
> prom_early_allocated += free_mem;
> }
>
> res = mem;
> free_mem -= size;
> mem += size;
> return res;
>
> g.
Makes sense, thanks.
next prev parent reply other threads:[~2010-10-27 17:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 22:58 [PATCH] x86: OLPC: add OLPC device-tree support (v3) Andres Salomon
2010-10-22 22:58 ` Andres Salomon
2010-10-23 0:22 ` [PATCH] x86: OLPC: speed up device tree creation during boot Andres Salomon
2010-10-23 0:22 ` Andres Salomon
2010-10-27 10:39 ` Grant Likely
2010-10-27 10:39 ` Grant Likely
2010-10-27 17:50 ` Andres Salomon [this message]
2010-10-27 17:50 ` Andres Salomon
2010-10-27 10:19 ` [PATCH] x86: OLPC: add OLPC device-tree support (v3) Grant Likely
2010-10-27 10:19 ` Grant Likely
2010-10-27 13:35 ` Thomas Gleixner
2010-10-27 13:35 ` Thomas Gleixner
2010-10-27 14:41 ` H. Peter Anvin
2010-10-27 17:48 ` Andres Salomon
2010-10-27 17:48 ` Andres Salomon
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=20101027105052.23aa1c17@queued.net \
--to=dilinger@queued.net \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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.