[PATCH net-next 2/2] net: airoha: Reorganize airoha_queue struct

Lorenzo Bianconi lorenzo at kernel.org
Tue Nov 4 23:53:06 PST 2025


> On Mon, 03 Nov 2025 11:27:56 +0100 Lorenzo Bianconi wrote:
> > Do not allocate memory for rx-only fields for hw tx queues and for tx-only
> > fields for hw rx queues.
> 
> Could you share more details (pahole)
> Given that napi_struct is in the same struct, 20B is probably not going
> to make much difference?

I agree the difference is not huge, I added this patch mainly for code
readability. If you prefer I can drop the patch, I do not have a strong
opinion about it. What do you think?

net-next:

struct airoha_queue {
	struct airoha_qdma *       qdma;                 /*     0     8 */
	spinlock_t                 lock;                 /*     8     4 */

	/* XXX 4 bytes hole, try to pack */

	struct airoha_queue_entry * entry;               /*    16     8 */
	struct airoha_qdma_desc *  desc;                 /*    24     8 */
	u16                        head;                 /*    32     2 */
	u16                        tail;                 /*    34     2 */
	int                        queued;               /*    36     4 */
	int                        ndesc;                /*    40     4 */
	int                        free_thr;             /*    44     4 */
	int                        buf_size;             /*    48     4 */

	/* XXX 4 bytes hole, try to pack */

	struct napi_struct         napi __attribute__((__aligned__(8))); /*    56   496 */

	/* XXX last struct has 1 hole */

	/* --- cacheline 8 boundary (512 bytes) was 40 bytes ago --- */
	struct page_pool *         page_pool;            /*   552     8 */
	struct sk_buff *           skb;                  /*   560     8 */

	/* size: 568, cachelines: 9, members: 13 */
	/* sum members: 560, holes: 2, sum holes: 8 */
	/* member types with holes: 1, total: 1 */
	/* forced alignments: 1, forced holes: 1, sum forced holes: 4 */
	/* last cacheline: 56 bytes */
} __attribute__((__aligned__(8)));

net-next + airoha_queue reorg:

struct airoha_queue {
	struct airoha_qdma *       qdma;                 /*     0     8 */
	spinlock_t                 lock;                 /*     8     4 */

	/* XXX 4 bytes hole, try to pack */

	struct airoha_queue_entry * entry;               /*    16     8 */
	struct airoha_qdma_desc *  desc;                 /*    24     8 */
	int                        queued;               /*    32     4 */
	int                        ndesc;                /*    36     4 */
	struct napi_struct         napi __attribute__((__aligned__(8))); /*    40   496 */

	/* XXX last struct has 1 hole */

	/* --- cacheline 8 boundary (512 bytes) was 24 bytes ago --- */
	union {
		struct {
			u16        head;                 /*   536     2 */
			u16        tail;                 /*   538     2 */
			int        buf_size;             /*   540     4 */
			struct page_pool * page_pool;    /*   544     8 */
			struct sk_buff * skb;            /*   552     8 */
		};                                       /*   536    24 */
		struct {
			struct list_head tx_list;        /*   536    16 */
			int        free_thr;             /*   552     4 */
		};                                       /*   536    24 */
	};                                               /*   536    24 */

	/* size: 560, cachelines: 9, members: 8 */
	/* sum members: 556, holes: 1, sum holes: 4 */
	/* member types with holes: 1, total: 1 */
	/* forced alignments: 1 */
	/* last cacheline: 48 bytes */
} __attribute__((__aligned__(8)));

Regards,
Lorenzo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-mediatek/attachments/20251105/674c76f8/attachment.sig>


More information about the Linux-mediatek mailing list