bootmem_data_t and __initdata qualifier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

In the file mm/bootmem.c, there is a declaration:

bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata;

(Please see: http://lxr.linux.no/linux+v2.6.33/mm/bootmem.c#L35)

The above declaration allocates space at compile time for an array of
bootmem_data_t type inside the .init.data section of the vmlinux. Each
member of this array is further pointing to a bitmap which is
allocated at run-time. (Please see the node_bootmem_map field inside
bootmem_data_t structure -
http://lxr.linux.no/linux+v2.6.33/include/linux/bootmem.h#L37)

Now, when the kernel function alloc_bootmem() (or its variants
alloc_bootmem_low() , alloc_bootmem_pages() or
alloc_bootmem_low_pages()) are used, it results in invocation of
alloc_bootmem_core() which seems to be scanning this bitmap to set the
bits inside it, depending upon the size argument passed to it.

Also, as I understand from my perusal of the kernel code, all the code
and data marked with __initdata qualifier are freed by the kernel,
when free_initmem() is invoked.

Now I have following queries:

1. I fail to understand why is this declaration marked with __initdata
qualifier? Does it mean that this array bootmem_node_data would not be
used by the kernel anytime after booting is complete?

2. The usage of __initdata qualifier with bootmem_node_data variable
also implies that alloc_bootmem() and free_bootmem( along with their
variants) can be used only before free_initmem() is invoked by the
kernel.

Is there any such implicit or explicit dependency or relation between
the invocation order of alloc_bootmem() and free_initmem()?

I am saying this because, alloc_bootmem() seems to be scanning the
associated bitmap of bootmem_data_t and free_bootmem() seems to be
again scanning the bitmap.

3. Also, What would happen in case, the associated data structure (i.e
bootmem_node_data) itself is freed by the kernel during free_initmem()
first, and then some piece of code has still not called its
free_bootmem() ? Would it not result in lost references to the
bootmem’s bitmap. How does kernel ensure that these kind of lost
references to the bitmap does not happen?

I think I have explained my doubts clearly. Some of the understanding
of kernel concepts might not be totally correct here.

Thanks to everyone for their help in understanding this.

With Regards,
Himanshu Aggarwal

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux