Skip to contentSkip to conversation

Why does mem_init call map_cb twice?

uml-devel John Reiser 2 participants 2 messages Dec 14, 2007 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

In arch/um/kernel/mem.c, mem_init calls map_cb twice:
once directly and once indirectly via initial_thread_cb. Why?

-----
void mem_init(void)

{
        /* clear the zero-page */
        memset((void *) empty_zero_page, 0, PAGE_SIZE);

        /* Map in the area just after the brk now that kmalloc is about
         * to be turned on.
         */
        brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
        map_cb(NULL);
        initial_thread_cb(map_cb, NULL);

-----

Signature · 12 lines
John Reiser, [email protected]

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#1 lore raw
Quoted 15 lines · John Reiser

In arch/um/kernel/mem.c, mem_init calls map_cb twice:
once directly and once indirectly via initial_thread_cb. Why?

-----
void mem_init(void)

{
        /* clear the zero-page */
        memset((void *) empty_zero_page, 0, PAGE_SIZE);

        /* Map in the area just after the brk now that kmalloc is about
         * to be turned on.
         */
        brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
        map_cb(NULL);
        initial_thread_cb(map_cb, NULL);
Quoted 1 line

-----

It's a bug. That's left over from the tt mode days, when the kernel ran in the same address spaces as its processes and there was a separate thread ptracing everything. The tracing thread address space needed to be kept in sync with the others, and this was one part of that.

Jeff

Signature · 12 lines
Work email - jdike at linux dot intel dot com

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel