Re: [PATCH] memblock: remove repeat round

From: Yajun Deng
Date: Wed Oct 26 2022 - 02:18:10 EST


October 26, 2022 2:04 PM, "Mike Rapoport" <rppt@xxxxxxxxxx> wrote:

> On Tue, Oct 25, 2022 at 03:24:58AM +0000, Yajun Deng wrote:
>
>> October 25, 2022 12:15 AM, "Mike Rapoport" <rppt@xxxxxxxxxx> wrote:
>>
>> @@ -598,22 +597,6 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,
>> return 0;
>> }
>>
>> - /*
>> - * The worst case is when new range overlaps all existing regions,
>> - * then we'll need type->cnt + 1 empty regions in @type. So if
>> - * type->cnt * 2 + 1 is less than type->max, we know
>> - * that there is enough empty regions in @type, and we can insert
>> - * regions directly.
>> - */
>> - if (type->cnt * 2 + 1 < type->max)
>> - insert = true;
>> -
>> -repeat:
>> - /*
>> - * The following is executed twice. Once with %false @insert and
>> - * then with %true. The first counts the number of regions needed
>> - * to accommodate the new area. The second actually inserts them.
>> - */
>> base = obase;
>> nr_new = 0;
>>
>> I believe nr_new variable is no longer needed, is it?
>>
>> No, nr_new is needed before memblock_merge_regions() for return.
>
> Why?
>
Sorry, nr_new was removed, and added ocnt variable for the original of type->cnt.

I already sent another patch with '[PATCH v2] memblock: don't run loop in
memblock_add_range() twice' subject, you can see that.

> --
> Sincerely yours,
> Mike.