Re: [PATCH v2 1/2] vfio/pci: Fix racy bitfields and tighten struct layout
From: Jason Gunthorpe
Date: Tue May 12 2026 - 09:43:46 EST
On Mon, May 11, 2026 at 04:16:02PM -0600, Alex Williamson wrote:
> Bitfield operations are not atomic, they use a read-modify-write
> pattern, therefore we should be careful not to pack bitfields that
> can be concurrently updated into the same storage unit.
>
> The split fields (virq_disabled, bardirty, pm_intx_masked,
> pm_runtime_engaged, sriov_pwr_active) are mutated post-init from
> contexts that don't serialize against the other writers in the same
> storage unit, so a bitfield RMW could drop an adjacent field's
> update. The remaining bitfields are touched only during probe or
> close where no concurrent writer exists, so they stay packed.
>
> While reordering, place virq_disabled and bardirty earlier to fill
> an existing alignment hole.
I feel like a comment is needed here for the various bool groupings
'write locked by XX' or something?
Jason