• Jinyu Tang's avatar
    memblock: avoid some repeat when add new range · 28e1a8f4
    Jinyu Tang authored
    The worst case is that the new memory range overlaps all existing
    regions, which requires type->cnt + 1 empty struct memblock_region slots in
    the type->regions array.
    So if type->cnt + 1 + type->cnt is less than type->max, we can insert
    regions directly rather than calculate the needed amount before the
    insertion.
    And becase of merge operation in the end of function, tpye->cnt will
    increase slowly for many cases.
    
    This change allows to avoid unnecessary repeat of memblock ranges traversal
    for many cases when adding new memory range.
    Signed-off-by: default avatarJinyu Tang <tjytimi@163.com>
    [rppt: massaged comment and changelog text]
    Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
    28e1a8f4
memblock.c 61 KB