Skip to content

Commit 0a323da

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: optimize sdw_bus structure
The sdw_bus structure has seen multiple additions over the years. It's one of the most used structures in this subsystem, so there's merit in reshuffling the members a bit with 'pahole' to reduce holes and structures across cache lines. before: struct sdw_bus { struct device * dev; /* 0 8 */ struct sdw_master_device * md; /* 8 8 */ int controller_id; /* 16 4 */ unsigned int link_id; /* 20 4 */ int id; /* 24 4 */ /* XXX 4 bytes hole, try to pack */ struct list_head slaves; /* 32 16 */ long unsigned int assigned[1]; /* 48 8 */ struct mutex bus_lock; /* 56 160 */ /* --- cacheline 3 boundary (192 bytes) was 24 bytes ago --- */ struct lock_class_key bus_lock_key; /* 216 16 */ struct mutex msg_lock; /* 232 160 */ /* --- cacheline 6 boundary (384 bytes) was 8 bytes ago --- */ struct lock_class_key msg_lock_key; /* 392 16 */ int (*compute_params)(struct sdw_bus *); /* 408 8 */ const struct sdw_master_ops * ops; /* 416 8 */ const struct sdw_master_port_ops * port_ops; /* 424 8 */ struct sdw_bus_params params; /* 432 36 */ /* XXX 4 bytes hole, try to pack */ /* --- cacheline 7 boundary (448 bytes) was 24 bytes ago --- */ struct sdw_master_prop prop; /* 472 72 */ /* XXX last struct has 6 bytes of padding */ /* --- cacheline 8 boundary (512 bytes) was 32 bytes ago --- */ void * vendor_specific_prop; /* 544 8 */ struct list_head m_rt_list; /* 552 16 */ struct dentry * debugfs; /* 568 8 */ /* --- cacheline 9 boundary (576 bytes) --- */ struct irq_chip irq_chip; /* 576 264 */ /* --- cacheline 13 boundary (832 bytes) was 8 bytes ago --- */ struct irq_domain * domain; /* 840 8 */ struct sdw_defer defer_msg; /* 848 112 */ /* --- cacheline 15 boundary (960 bytes) --- */ unsigned int clk_stop_timeout; /* 960 4 */ u32 bank_switch_timeout; /* 964 4 */ bool multi_link; /* 968 1 */ /* XXX 3 bytes hole, try to pack */ int hw_sync_min_links; /* 972 4 */ int stream_refcount; /* 976 4 */ /* size: 984, cachelines: 16, members: 27 */ /* sum members: 969, holes: 3, sum holes: 11 */ /* padding: 4 */ /* paddings: 1, sum paddings: 6 */ /* last cacheline: 24 bytes */ }; after: struct sdw_bus { struct device * dev; /* 0 8 */ struct sdw_master_device * md; /* 8 8 */ struct lock_class_key bus_lock_key; /* 16 16 */ struct mutex bus_lock; /* 32 160 */ /* --- cacheline 3 boundary (192 bytes) --- */ struct list_head slaves; /* 192 16 */ struct lock_class_key msg_lock_key; /* 208 16 */ struct mutex msg_lock; /* 224 160 */ /* --- cacheline 6 boundary (384 bytes) --- */ struct list_head m_rt_list; /* 384 16 */ struct sdw_defer defer_msg; /* 400 112 */ /* --- cacheline 8 boundary (512 bytes) --- */ struct sdw_bus_params params; /* 512 36 */ int stream_refcount; /* 548 4 */ const struct sdw_master_ops * ops; /* 552 8 */ const struct sdw_master_port_ops * port_ops; /* 560 8 */ struct sdw_master_prop prop; /* 568 72 */ /* XXX last struct has 6 bytes of padding */ /* --- cacheline 10 boundary (640 bytes) --- */ void * vendor_specific_prop; /* 640 8 */ int hw_sync_min_links; /* 648 4 */ int controller_id; /* 652 4 */ unsigned int link_id; /* 656 4 */ int id; /* 660 4 */ int (*compute_params)(struct sdw_bus *); /* 664 8 */ long unsigned int assigned[1]; /* 672 8 */ unsigned int clk_stop_timeout; /* 680 4 */ u32 bank_switch_timeout; /* 684 4 */ struct irq_chip irq_chip; /* 688 264 */ /* --- cacheline 14 boundary (896 bytes) was 56 bytes ago --- */ struct irq_domain * domain; /* 952 8 */ /* --- cacheline 15 boundary (960 bytes) --- */ struct dentry * debugfs; /* 960 8 */ bool multi_link; /* 968 1 */ /* size: 976, cachelines: 16, members: 27 */ /* padding: 7 */ /* paddings: 1, sum paddings: 6 */ /* last cacheline: 16 bytes */ }; Signed-off-by: Pierre-Louis Bossart <[email protected]> Signed-off-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 6cb2c15 commit 0a323da

File tree

1 file changed

+40
-37
lines changed
  • include/linux/soundwire

1 file changed

+40
-37
lines changed

include/linux/soundwire/sdw.h

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -871,68 +871,71 @@ struct sdw_master_ops {
871871
* struct sdw_bus - SoundWire bus
872872
* @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
873873
* @md: Master device
874-
* @controller_id: system-unique controller ID. If set to -1, the bus @id will be used.
875-
* @link_id: Link id number, can be 0 to N, unique for each Controller
876-
* @id: bus system-wide unique id
877-
* @slaves: list of Slaves on this bus
878-
* @assigned: Bitmap for Slave device numbers.
879-
* Bit set implies used number, bit clear implies unused number.
874+
* @bus_lock_key: bus lock key associated to @bus_lock
880875
* @bus_lock: bus lock
876+
* @slaves: list of Slaves on this bus
877+
* @msg_lock_key: message lock key associated to @msg_lock
881878
* @msg_lock: message lock
882-
* @compute_params: points to Bus resource management implementation
883-
* @ops: Master callback ops
884-
* @port_ops: Master port callback ops
885-
* @params: Current bus parameters
886-
* @prop: Master properties
887-
* @vendor_specific_prop: pointer to non-standard properties
888879
* @m_rt_list: List of Master instance of all stream(s) running on Bus. This
889880
* is used to compute and program bus bandwidth, clock, frame shape,
890881
* transport and port parameters
891-
* @debugfs: Bus debugfs
892-
* @domain: IRQ domain
893882
* @defer_msg: Defer message
894-
* @clk_stop_timeout: Clock stop timeout computed
895-
* @bank_switch_timeout: Bank switch timeout computed
896-
* @multi_link: Store bus property that indicates if multi links
897-
* are supported. This flag is populated by drivers after reading
898-
* appropriate firmware (ACPI/DT).
883+
* @params: Current bus parameters
884+
* @stream_refcount: number of streams currently using this bus
885+
* @ops: Master callback ops
886+
* @port_ops: Master port callback ops
887+
* @prop: Master properties
888+
* @vendor_specific_prop: pointer to non-standard properties
899889
* @hw_sync_min_links: Number of links used by a stream above which
900890
* hardware-based synchronization is required. This value is only
901891
* meaningful if multi_link is set. If set to 1, hardware-based
902892
* synchronization will be used even if a stream only uses a single
903893
* SoundWire segment.
904-
* @stream_refcount: number of streams currently using this bus
894+
* @controller_id: system-unique controller ID. If set to -1, the bus @id will be used.
895+
* @link_id: Link id number, can be 0 to N, unique for each Controller
896+
* @id: bus system-wide unique id
897+
* @compute_params: points to Bus resource management implementation
898+
* @assigned: Bitmap for Slave device numbers.
899+
* Bit set implies used number, bit clear implies unused number.
900+
* @clk_stop_timeout: Clock stop timeout computed
901+
* @bank_switch_timeout: Bank switch timeout computed
902+
* @domain: IRQ domain
903+
* @irq_chip: IRQ chip
904+
* @debugfs: Bus debugfs (optional)
905+
* @multi_link: Store bus property that indicates if multi links
906+
* are supported. This flag is populated by drivers after reading
907+
* appropriate firmware (ACPI/DT).
905908
*/
906909
struct sdw_bus {
907910
struct device *dev;
908911
struct sdw_master_device *md;
909-
int controller_id;
910-
unsigned int link_id;
911-
int id;
912-
struct list_head slaves;
913-
DECLARE_BITMAP(assigned, SDW_MAX_DEVICES);
914-
struct mutex bus_lock;
915912
struct lock_class_key bus_lock_key;
916-
struct mutex msg_lock;
913+
struct mutex bus_lock;
914+
struct list_head slaves;
917915
struct lock_class_key msg_lock_key;
918-
int (*compute_params)(struct sdw_bus *bus);
916+
struct mutex msg_lock;
917+
struct list_head m_rt_list;
918+
struct sdw_defer defer_msg;
919+
struct sdw_bus_params params;
920+
int stream_refcount;
919921
const struct sdw_master_ops *ops;
920922
const struct sdw_master_port_ops *port_ops;
921-
struct sdw_bus_params params;
922923
struct sdw_master_prop prop;
923924
void *vendor_specific_prop;
924-
struct list_head m_rt_list;
925+
int hw_sync_min_links;
926+
int controller_id;
927+
unsigned int link_id;
928+
int id;
929+
int (*compute_params)(struct sdw_bus *bus);
930+
DECLARE_BITMAP(assigned, SDW_MAX_DEVICES);
931+
unsigned int clk_stop_timeout;
932+
u32 bank_switch_timeout;
933+
struct irq_chip irq_chip;
934+
struct irq_domain *domain;
925935
#ifdef CONFIG_DEBUG_FS
926936
struct dentry *debugfs;
927937
#endif
928-
struct irq_chip irq_chip;
929-
struct irq_domain *domain;
930-
struct sdw_defer defer_msg;
931-
unsigned int clk_stop_timeout;
932-
u32 bank_switch_timeout;
933938
bool multi_link;
934-
int hw_sync_min_links;
935-
int stream_refcount;
936939
};
937940

938941
int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,

0 commit comments

Comments
 (0)