>-----Original Message-----
>From: Kiryl Shutsemau <[email protected]>
>Subject: Re: [RFCv2 PATCH 5/6] mm/memory_hotplug: Support ACPI
>hotplug/unplug for coco guest
>
>On Tue, Jun 23, 2026 at 06:17:36AM -0400, Zhenzhong Duan wrote:
>> +    spin_lock_irqsave(&unaccepted_memory_lock, flags);
>> +    for (; range_start < bitmap_size; range_start = range_end) {
>> +            unsigned long phys_start, phys_end;
>> +            unsigned long unaccepted_one, plugged_zero;
>> +
>> +            range_start = find_next_andnot_bit(plugged_bitmap,
>unaccepted->bitmap,
>> +                                               bitmap_size, range_start);
>> +
>> +            if (range_start >= bitmap_size)
>> +                    break;
>> +
>> +            unaccepted_one = find_next_bit(unaccepted->bitmap,
>bitmap_size, range_start);
>> +            plugged_zero = find_next_zero_bit(plugged_bitmap, bitmap_size,
>range_start);
>> +            range_end = min(unaccepted_one, plugged_zero);
>> +
>> +            phys_start = range_start * unit_size + unaccepted->phys_base;
>> +            phys_end = range_end * unit_size + unaccepted->phys_base;
>> +
>> +            arch_unaccept_memory(phys_start, phys_end);
>> +            bitmap_set(unaccepted->bitmap, range_start, range_end -
>range_start);
>> +    }
>> +    spin_unlock_irqrestore(&unaccepted_memory_lock, flags);
>
>Accept TDCALL under the spin lock will kill scalability.

OK, I can drop the lock during arch_unaccept_memory() and avoid race
by checking the accepting_list just like in accept_memory().

I initially wrapped this in the spinlock because TDG.MEM.PAGE.RELEASE
is a quick local TDX module call to transition pages back to PENDING state,
without the heavy VMM trapping/faulting overhead associated with
memory acceptance paths.

Thanks
Zhenzhong

Reply via email to