Re: [PATCH v2 1/3] kho: Adopt KHO radix tree data structures
From: Jason Gunthorpe
Date: Fri Oct 24 2025 - 07:46:51 EST
On Thu, Oct 23, 2025 at 09:23:30PM -0400, Pasha Tatashin wrote:
> On Thu, Oct 23, 2025 at 7:45 PM Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:
> >
> > On Mon, Oct 20, 2025 at 03:03:04AM -0700, Jason Miu wrote:
> >
> > > +static struct kho_radix_tree *kho_alloc_radix_tree(void)
> > > {
> > > + return (struct kho_radix_tree *)get_zeroed_page(GFP_KERNEL);
> > > +}
> >
> > I was reading the thread over here:
> >
> > https://lore.kernel.org/all/20151222210435.GB20997@xxxxxxxxxxxxxxxxxx/
> >
> > And I guess this stuff should just use
> > kzalloc(sizeof(struct kho_radix_tree), GFP_KERNEL);
>
> kzalloc() uses slab, which in turn may use kfence objects, and kfence
> can allocate memory from KHO scratch area, leading to memory
> corruptions. Let's not use slab allocator for KHO preserved and
> metadata memory, it is not a good choice.
That sounds like a nasty subtle problem to have :(
Really should provide a kho allocator API to document these needs!
Jason