Re: [PATCH] mm/slab: improve kmem_cache_alloc_bulk
From: Vlastimil Babka (SUSE)
Date: Wed Jun 03 2026 - 12:57:00 EST
On 6/3/26 13:13, Rob Clark wrote:
> On Wed, Jun 3, 2026 at 2:17 AM Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx> wrote:
>>
>> We know p->pages is NULL in this case, right? Because it was allocated by
>> vm_bind_job_create() using kzalloc().
>> And the job can't be reused with a leftover value?
>> (msm_iommu_pagetable_prealloc_cleanup doesn't set p->pages to zero).
>> Or should we set p->pages to NULL here.
>
> Correct, the job is not reused. But I suppose setting p->pages to
> NULL would make things more obvious, so no objection to that.
OK, did that, just in case. Thanks.
> BR,
> -R
>
>> > +
>> > p->pages = kvmalloc_objs(*p->pages, p->count);
>> > if (!p->pages)
>> > return -ENOMEM;
>> >
>> > ret = kmem_cache_alloc_bulk(pt_cache, GFP_KERNEL, p->count, p->pages);
>> > if (ret != p->count) {
>> > - kfree(p->pages);
>> > + kvfree(p->pages);
>> > p->pages = NULL;
>> > p->count = ret;
>> > return -ENOMEM;
>>