Re: [PATCH v3 08/30] kho: don't unpreserve memory during abort

From: Pasha Tatashin

Date: Mon Sep 22 2025 - 10:58:17 EST


On Thu, Aug 14, 2025 at 9:30 AM Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:
>
> On Thu, Aug 07, 2025 at 01:44:14AM +0000, Pasha Tatashin wrote:
> > static int __kho_abort(void)
> > {
> > - int err = 0;
> > - unsigned long order;
> > - struct kho_mem_phys *physxa;
> > -
> > - xa_for_each(&kho_out.track.orders, order, physxa) {
> > - struct kho_mem_phys_bits *bits;
> > - unsigned long phys;
> > -
> > - xa_for_each(&physxa->phys_bits, phys, bits)
> > - kfree(bits);
> > -
> > - xa_destroy(&physxa->phys_bits);
> > - kfree(physxa);
> > - }
> > - xa_destroy(&kho_out.track.orders);
>
> Now nothing ever cleans this up :\

It is solved with stateless KHO. The current implementation is broken,
dropping everything in abort should never happen for stuff that was
independently preserved.

> Are you sure the issue isn't in the caller that it shouldn't be
> calling kho abort until all the other stuff is cleaned up first?
>
> I feel like this is another case of absuing globals gives an unclear
> lifecycle model.

Yes. But, we have a fix for that.

Pasha