[PATCH 00/16] memory tagging improvements

Szabolcs Nagy Szabolcs.Nagy@arm.com
Mon Mar 8 09:34:01 GMT 2021


The 03/05/2021 21:36, Wilco Dijkstra wrote:
> > - request2size and checked_request2size are not consistent which looks
> >   wrong (likely works in practice other than some sizes don't end up in
> >   fastbin or tcache that one might expected to, but i think this can
> >   break easily). Fixing it is not obvious because of assumptions about
> >   the chunk layout that is no longer true with mtag enabled.
> 
> It's better to change request2size to round up differently if tagging is
> required. That avoids dynamically changing how chunks are rounded up.
...

> > - unconditional top byte zero
> >   internal data is tagged 0, only user allocation is tagged non-zero
> 
> That's a great idea! Many chunk2mem can be changed into chunk2rawmem
> approximately halving the overhead. And mem2chunk can unconditionally mask
> out the tag (note all this could be made target-dependent if needed).

i will look into this, i expected it to need bigger changes.

> > - unconditional layout
> >   padding up to tag granule can be done unconditionally
> >   good: no runtime check, same layout with and without heap tagging.
> >   bad: wasting space with small allocations, design change.
> 
> This is unconditionally good for performance and avoids the request2size oddities.
> If we're worried about memory usage, we need to talk about modern malloc
> implementations that don't add a 16-byte header to every block.

i think it is not enough to change request2size, one would
have to audit the code for hidden assumptions about the
layout, so even if we are happy to waste another word per
small allocations, it is not an obvious change.

(right now the logic is a bit ugly, but the ugliness only
affects behaviour in the tagging case)


More information about the Libc-alpha mailing list