Skip to content

Commit 9cd0f6d

Browse files
rchatreawilliam
authored andcommitted
vfio/pci: Use bitfield for struct vfio_pci_core_device flags
struct vfio_pci_core_device contains eleven boolean flags. Boolean flags clearly indicate their usage but space usage starts to be a concern when there are many. An upcoming change adds another boolean flag to struct vfio_pci_core_device, thereby increasing the concern that the boolean flags are consuming unnecessary space. Transition the boolean flags to use bitfields. On a system that uses one byte per boolean this reduces the space consumed by existing flags from 11 bytes to 2 bytes with room for a few more flags without increasing the structure's size. Suggested-by: Jason Gunthorpe <[email protected]> Signed-off-by: Reinette Chatre <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/cf34bf0499c889554a8105eeb18cc0ab673005be.1683740667.git.reinette.chatre@intel.com Signed-off-by: Alex Williamson <[email protected]>
1 parent 9387cf5 commit 9cd0f6d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

include/linux/vfio_pci_core.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ struct vfio_pci_core_device {
6868
u16 msix_size;
6969
u32 msix_offset;
7070
u32 rbar[7];
71-
bool pci_2_3;
72-
bool virq_disabled;
73-
bool reset_works;
74-
bool extended_caps;
75-
bool bardirty;
76-
bool has_vga;
77-
bool needs_reset;
78-
bool nointx;
79-
bool needs_pm_restore;
80-
bool pm_intx_masked;
81-
bool pm_runtime_engaged;
71+
bool pci_2_3:1;
72+
bool virq_disabled:1;
73+
bool reset_works:1;
74+
bool extended_caps:1;
75+
bool bardirty:1;
76+
bool has_vga:1;
77+
bool needs_reset:1;
78+
bool nointx:1;
79+
bool needs_pm_restore:1;
80+
bool pm_intx_masked:1;
81+
bool pm_runtime_engaged:1;
8282
struct pci_saved_state *pci_saved_state;
8383
struct pci_saved_state *pm_save;
8484
int ioeventfds_nr;

0 commit comments

Comments
 (0)