* kmalloc before kmem_cache_init
[not found] <CAEfq6QR4K1i4Xp8TBYxorFYnDk1CPM1F2c+gYnfoc3J3Zj4yvA@mail.gmail.com>
@ 2012-01-29 6:02 ` Sukanto Ghosh
2012-01-29 6:58 ` Dave Hylands
0 siblings, 1 reply; 6+ messages in thread
From: Sukanto Ghosh @ 2012-01-29 6:02 UTC (permalink / raw)
To: kernelnewbies
I am kind of lost trying to figure out how can kmallocs work if they
are called before kmem_cache_init
(e.g. such a case occurs when in start_kernel() we call
parse_early_param() (which in turn might call
early_serial8250_setup() if earlycon= is used in kernel command-line)
before mm_init() ?(which later calls
kmem_cache_init() )
>From what I understood, kmalloc() (SLUB implementation) first tries to
find out the slab fit for the size
being kmalloced and slabs are nothing but kmalloc_caches[]. Now these
kmalloc_caches get initialized in
kmem_cache_init().
What am I missing here ?
Regards,
Sukanto Ghosh
--
Regards,
Sukanto Ghosh
^ permalink raw reply [flat|nested] 6+ messages in thread
* kmalloc before kmem_cache_init
2012-01-29 6:02 ` kmalloc before kmem_cache_init Sukanto Ghosh
@ 2012-01-29 6:58 ` Dave Hylands
2012-01-29 7:25 ` Sukanto Ghosh
0 siblings, 1 reply; 6+ messages in thread
From: Dave Hylands @ 2012-01-29 6:58 UTC (permalink / raw)
To: kernelnewbies
Hi Sukanto
On Sat, Jan 28, 2012 at 10:02 PM, Sukanto Ghosh
<sukanto.cse.iitb@gmail.com> wrote:
> I am kind of lost trying to figure out how can kmallocs work if they
> are called before kmem_cache_init
>
> (e.g. such a case occurs when in start_kernel() we call
> parse_early_param() (which in turn might call
> early_serial8250_setup() if earlycon= is used in kernel command-line)
> before mm_init() ?(which later calls
> kmem_cache_init() )
I don't think that you're allowed to call kmalloc during early_setup.
I don't see where early_serial8250_setup calls kmalloc.
--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* kmalloc before kmem_cache_init
2012-01-29 6:58 ` Dave Hylands
@ 2012-01-29 7:25 ` Sukanto Ghosh
2012-01-29 9:33 ` Dave Hylands
0 siblings, 1 reply; 6+ messages in thread
From: Sukanto Ghosh @ 2012-01-29 7:25 UTC (permalink / raw)
To: kernelnewbies
Hi Dave,
If you look into start_kernel() the call to parse_early_param()
precedes mm_init().
parse_early_param() eventually calls do_early_param().
do_early_param() parses for "earlycon" in kernel commandline and then calls the
setup_function associated with earlycon.
I have in my commandline: earlycon=uart8250,mmio32,0x10000000,9600
Call flow starting from drivers/tty/serial/8250_early.c will lead to kmalloc
early_param("early_con", setup_early_serial8250_console)
setup_early_serial8250_console()
early_serial8250_setup()
parse_options()
ioremap_nocache()
... arch-specific-ioremap
-- some form of arch specific __ioremap_caller
--- get_vm_area_caller()
__get_vm_area_node
kzalloc_node
kmalloc_node
kmalloc
Regards,
Sukanto
On Jan 29, 2012 12:28 PM, "Dave Hylands" <dhylands@gmail.com> wrote:
>
> Hi Sukanto
>
> On Sat, Jan 28, 2012 at 10:02 PM, Sukanto Ghosh
> <sukanto.cse.iitb@gmail.com> wrote:
> > I am kind of lost trying to figure out how can kmallocs work if they
> > are called before kmem_cache_init
> >
> > (e.g. such a case occurs when in start_kernel() we call
> > parse_early_param() (which in turn might call
> > early_serial8250_setup() if earlycon= is used in kernel command-line)
> > before mm_init() ?(which later calls
> > kmem_cache_init() )
>
> I don't think that you're allowed to call kmalloc during early_setup.
> I don't see where early_serial8250_setup calls kmalloc.
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.davehylands.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* kmalloc before kmem_cache_init
2012-01-29 7:25 ` Sukanto Ghosh
@ 2012-01-29 9:33 ` Dave Hylands
2012-01-29 12:29 ` Sukanto Ghosh
0 siblings, 1 reply; 6+ messages in thread
From: Dave Hylands @ 2012-01-29 9:33 UTC (permalink / raw)
To: kernelnewbies
Hi Sukanto,
On Sat, Jan 28, 2012 at 11:25 PM, Sukanto Ghosh
<sukanto.cse.iitb@gmail.com> wrote:
> Hi Dave,
>
> If you look into start_kernel() the call to parse_early_param()
> precedes mm_init().
> parse_early_param() eventually calls do_early_param().
> do_early_param() parses for "earlycon" in kernel commandline and then calls the
> setup_function associated with earlycon.
>
> I have in my commandline: earlycon=uart8250,mmio32,0x10000000,9600
>
> Call flow starting from drivers/tty/serial/8250_early.c will lead to kmalloc
>
> early_param("early_con", setup_early_serial8250_console)
> ? setup_early_serial8250_console()
> ? ? ? early_serial8250_setup()
> ? ? ? ? ? parse_options()
> ? ? ? ? ? ? ? ioremap_nocache()
> ? ? ? ? ? ? ? ? ?... arch-specific-ioremap
> ? ? ? ? ? ? ? ? ? ? ? ?-- some form of arch specific __ioremap_caller
> ? ? ? ? ? ? ? ? ? ? ? ? ? ?--- get_vm_area_caller()
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?__get_vm_area_node
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? kzalloc_node
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? kmalloc_node
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?kmalloc
It looks like CONFIG_FIX_EARLYCON_MEM defaults to y (on x86 anyways),
so this would cause the path that doesn't call ioremam_nocache to be
taken.
I'm guessing that if you specify earycon, then you also need to ensure
that CONFIG_FIX_EARLYCON is set.
You didn't mention which architecture you were using. ARM has an
early_printk which is sort of like an early console.
--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* kmalloc before kmem_cache_init
2012-01-29 9:33 ` Dave Hylands
@ 2012-01-29 12:29 ` Sukanto Ghosh
2012-01-29 13:27 ` Fredrick
0 siblings, 1 reply; 6+ messages in thread
From: Sukanto Ghosh @ 2012-01-29 12:29 UTC (permalink / raw)
To: kernelnewbies
So to use a MMIO based 8250 as "earlycon", either we need to have some
sort of fixmap
(as in case of x86) or otherwise we need to have a ioremap_nocache()
version that works
even before kmem_cache_init() is called.
I am not sure how many architectures will have such form of ioremap
other than maybe
nommu variants.
Greg,
Has anyone used the ioremap path so far ? If not, then why have it
there as usual ioremap
can be used only after mm_init(), but this driver whenever used will
get called earlier than that ?
Regards,
Sukanto
On Sun, Jan 29, 2012 at 3:03 PM, Dave Hylands <dhylands@gmail.com> wrote:
> Hi Sukanto,
>
> On Sat, Jan 28, 2012 at 11:25 PM, Sukanto Ghosh
> <sukanto.cse.iitb@gmail.com> wrote:
>> Hi Dave,
>>
>> If you look into start_kernel() the call to parse_early_param()
>> precedes mm_init().
>> parse_early_param() eventually calls do_early_param().
>> do_early_param() parses for "earlycon" in kernel commandline and then calls the
>> setup_function associated with earlycon.
>>
>> I have in my commandline: earlycon=uart8250,mmio32,0x10000000,9600
>>
>> Call flow starting from drivers/tty/serial/8250_early.c will lead to kmalloc
>>
>> early_param("early_con", setup_early_serial8250_console)
>> ? setup_early_serial8250_console()
>> ? ? ? early_serial8250_setup()
>> ? ? ? ? ? parse_options()
>> ? ? ? ? ? ? ? ioremap_nocache()
>> ? ? ? ? ? ? ? ? ?... arch-specific-ioremap
>> ? ? ? ? ? ? ? ? ? ? ? ?-- some form of arch specific __ioremap_caller
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ?--- get_vm_area_caller()
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?__get_vm_area_node
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? kzalloc_node
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? kmalloc_node
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?kmalloc
>
> It looks like CONFIG_FIX_EARLYCON_MEM defaults to y (on x86 anyways),
> so this would cause the path that doesn't call ioremam_nocache to be
> taken.
>
> I'm guessing that if you specify earycon, then you also need to ensure
> that CONFIG_FIX_EARLYCON is set.
>
> You didn't mention which architecture you were using. ARM has an
> early_printk which is sort of like an early console.
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.davehylands.com
--
Regards,
Sukanto Ghosh
^ permalink raw reply [flat|nested] 6+ messages in thread
* kmalloc before kmem_cache_init
2012-01-29 12:29 ` Sukanto Ghosh
@ 2012-01-29 13:27 ` Fredrick
0 siblings, 0 replies; 6+ messages in thread
From: Fredrick @ 2012-01-29 13:27 UTC (permalink / raw)
To: kernelnewbies
On 01/29/2012 04:29 AM, Sukanto Ghosh wrote:
> So to use a MMIO based 8250 as "earlycon", either we need to have some
> sort of fixmap
> (as in case of x86) or otherwise we need to have a ioremap_nocache()
> version that works
> even before kmem_cache_init() is called.
> I am not sure how many architectures will have such form of ioremap
> other than maybe
> nommu variants.
>
Some architectures check for mem_init_done.
Probably every architecture must provide an "early_ioremap" function to
be used in early _code_.
> Greg,
>
> Has anyone used the ioremap path so far ? If not, then why have it
> there as usual ioremap
> can be used only after mm_init(), but this driver whenever used will
> get called earlier than that ?
>
> Regards,
> Sukanto
>
>
>
> On Sun, Jan 29, 2012 at 3:03 PM, Dave Hylands<dhylands@gmail.com> wrote:
>> Hi Sukanto,
>>
>> On Sat, Jan 28, 2012 at 11:25 PM, Sukanto Ghosh
>> <sukanto.cse.iitb@gmail.com> wrote:
>>> Hi Dave,
>>>
>>> If you look into start_kernel() the call to parse_early_param()
>>> precedes mm_init().
>>> parse_early_param() eventually calls do_early_param().
>>> do_early_param() parses for "earlycon" in kernel commandline and then calls the
>>> setup_function associated with earlycon.
>>>
>>> I have in my commandline: earlycon=uart8250,mmio32,0x10000000,9600
>>>
>>> Call flow starting from drivers/tty/serial/8250_early.c will lead to kmalloc
>>>
>>> early_param("early_con", setup_early_serial8250_console)
>>> setup_early_serial8250_console()
>>> early_serial8250_setup()
>>> parse_options()
>>> ioremap_nocache()
>>> ... arch-specific-ioremap
>>> -- some form of arch specific __ioremap_caller
>>> --- get_vm_area_caller()
>>> __get_vm_area_node
>>> kzalloc_node
>>> kmalloc_node
>>> kmalloc
>>
>> It looks like CONFIG_FIX_EARLYCON_MEM defaults to y (on x86 anyways),
>> so this would cause the path that doesn't call ioremam_nocache to be
>> taken.
>>
>> I'm guessing that if you specify earycon, then you also need to ensure
>> that CONFIG_FIX_EARLYCON is set.
>>
>> You didn't mention which architecture you were using. ARM has an
>> early_printk which is sort of like an early console.
>>
>> --
>> Dave Hylands
>> Shuswap, BC, Canada
>> http://www.davehylands.com
>
>
>
-Fredrick
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-01-29 13:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAEfq6QR4K1i4Xp8TBYxorFYnDk1CPM1F2c+gYnfoc3J3Zj4yvA@mail.gmail.com>
2012-01-29 6:02 ` kmalloc before kmem_cache_init Sukanto Ghosh
2012-01-29 6:58 ` Dave Hylands
2012-01-29 7:25 ` Sukanto Ghosh
2012-01-29 9:33 ` Dave Hylands
2012-01-29 12:29 ` Sukanto Ghosh
2012-01-29 13:27 ` Fredrick
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).