Re: [committed][gdb/symtab] Make per_cu->unit_type atomic

Tom de Vries via Gdb-patches
2022-07-17T13:15:58Z

On 7/16/22 18:04, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Tom> - packed<dwarf_unit_type, 1> m_unit_type = (dwarf_unit_type) 0;
> Tom> + std::atomic<packed<dwarf_unit_type, 1>> m_unit_type {(dwarf_unit_type)0};
>
> I was thinking about this patch this morning and I wonder if packed<> is
> even needed now that the member is atomic.

With packed:
...
std::atomic<packed<dwarf_unit_type, 1>> m_unit_type {(dwarf_unit_type)0};
...
we have:
...
/* size: 120, cachelines: 2, members: 22 */
...
and without:
...
std::atomic<dwarf_unit_type> m_unit_type {(dwarf_unit_type)0};
...
we have:
...
/* size: 128, cachelines: 2, members: 22 */
...

So it's necessary to keep the struct small.

Thanks,
- Tom