Re: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

Ard Biesheuvel

On Tue, 2 Aug 2022 at 17:32, Jeff Brasen <jbrasen@...> wrote:

-----Original Message-----
From: Ard Biesheuvel <ardb@...>
Sent: Friday, July 29, 2022 9:48 AM
To: Jeff Brasen <jbrasen@...>
Cc:; hao.a.wu@...;;
quic_llindhol@...; ardb+tianocore@...
Subject: Re: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
Allow partial FreeBuffer

External email: Use caution opening links or attachments

On Thu, 28 Jul 2022 at 13:25, Jeff Brasen <jbrasen@...> wrote:

Adding Leif/Ard to CC incase they have any comments on this patch.
This generally looks ok to me. I just wonder if it wouldn't be simpler to reuse
the existing allocation descriptor if it is not being freed entirely. Given the
[presumably] the most common case is to allocate and then free some pages
at the end, lowering the page count on the existing descriptor would cover
most cases, and we'd only need to allocate new ones if pages are being freed
at the start or in the middle.
There is often freeing at the beginning as well as this is being used to create a 64K aligned section of memory in the case. So it over allocates and the free's some at the beginning and the end. I could probably make it detect and use that but figured this code would support all cases and required less case specific detection.
Ah interesting. Would it help if the allocate routine aligned
allocations to their size?

Join to automatically receive all group messages.