[Mesa-dev] [PATCH] i965: Reuse the same single-page bo for all zero sized allocations
Chris Wilson
chris at chris-wilson.co.uk
Wed Aug 15 08:48:43 UTC 2018
Quoting Michal Srb (2018-08-15 09:22:19)
> Hi,
>
> This is my first attempt to review patch for Mesa, so please take it with a
> grain of salt.
>
> On úterý 14. srpna 2018 20:21:40 CEST Chris Wilson wrote:
> > @@ -504,6 +506,24 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
> > bool busy = false;
> > bool zeroed = false;
> >
> > + /* Reuse the same bo for all zero-sized requests */
> > + if (size == 0) {
> > + if (bufmgr->bo_zero == NULL) {
> > + bo = bo_alloc_internal(bufmgr, "zero", 4096,
> > + BRW_MEMZONE_OTHER, BO_ALLOC_BUSY, 0, 0);
> > + if (!bo)
> > + return NULL;
> > +
> > + bo->size = 0;
>
> Doesn't this break something once the bo_zero is freed? Either after two
> threads raced and one has to cleanup or when the whole bufmgr is destroyed.
>
> The bucket_for_size will choose different bucket for sizes 4096 and 0:
> size 4096 -> bucket index 0 -> some bucket (I assume)
> size 0 -> bucket index 119 -> null bucket (always too big)
>
> So the get_bucket_allocator function will return some bucket when allocating
> and null bucket when freeing, so allocation goes thru bucket_vma_alloc and
> freeing thru util_vma_heap_free. I did not examine those functions closer, but
> it does sound like it would break something.
If it doesn't fit into a bucket, it will be freed immediately. The only
down side is that as it is part of a bucket_vma, it will pin that
bucket_vma forever, but that is not such a big deal as it evaporates
with the bufmgr.
To make the no-bucket more explicit, bo->reusable = false.
-Chris
More information about the mesa-dev
mailing list