mm/bootmem.c: cleanup on addition to bootmem data list
The objects of "struct bootmem_data_t" are linked together to form double-linked list sequentially based on its minimal page frame number. The current implementation implicitly supports the following cases, which means the inserting point for current bootmem data depends on how "list_for_each" works. That makes the code a little hard to read. Besides, "list_for_each" and "list_entry" can be replaced with "list_for_each_entry". - The linked list is empty. - There has no entry in the linked list, whose minimal page frame number is bigger than current one. Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Родитель
e48982734e
Коммит
5c2b8a162b
14
mm/bootmem.c
14
mm/bootmem.c
|
@ -77,16 +77,16 @@ unsigned long __init bootmem_bootmap_pages(unsigned long pages)
|
||||||
*/
|
*/
|
||||||
static void __init link_bootmem(bootmem_data_t *bdata)
|
static void __init link_bootmem(bootmem_data_t *bdata)
|
||||||
{
|
{
|
||||||
struct list_head *iter;
|
|
||||||
|
|
||||||
list_for_each(iter, &bdata_list) {
|
|
||||||
bootmem_data_t *ent;
|
bootmem_data_t *ent;
|
||||||
|
|
||||||
ent = list_entry(iter, bootmem_data_t, list);
|
list_for_each_entry(ent, &bdata_list, list) {
|
||||||
if (bdata->node_min_pfn < ent->node_min_pfn)
|
if (bdata->node_min_pfn < ent->node_min_pfn) {
|
||||||
break;
|
list_add_tail(&bdata->list, &ent->list);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
list_add_tail(&bdata->list, iter);
|
}
|
||||||
|
|
||||||
|
list_add_tail(&bdata->list, &bdata_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче