[PATCH 4/5] nvmet: Reorder fields in 'struct nvme_dhchap_queue_context'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Group some variables based on their sizes to reduce holes.
On x86_64, this shrinks the size of 'struct nvme_dhchap_queue_context' from
416 to 400 bytes.

This structure is kvcalloc()'ed in nvme_auth_init_ctrl(), so it is likely
that the allocation can be relatively big. Saving 16 bytes per structure
may might a slight difference.

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
Using pahole

Before:
======
struct nvme_dhchap_queue_context {
	struct list_head           entry;                /*     0    16 */
	struct work_struct         auth_work;            /*    16    80 */
	/* --- cacheline 1 boundary (64 bytes) was 32 bytes ago --- */
	struct nvme_ctrl *         ctrl;                 /*    96     8 */
	struct crypto_shash *      shash_tfm;            /*   104     8 */
	struct crypto_kpp *        dh_tfm;               /*   112     8 */
	void *                     buf;                  /*   120     8 */
	/* --- cacheline 2 boundary (128 bytes) --- */
	int                        qid;                  /*   128     4 */
	int                        error;                /*   132     4 */
	u32                        s1;                   /*   136     4 */
	u32                        s2;                   /*   140     4 */
	u16                        transaction;          /*   144     2 */
	u8                         status;               /*   146     1 */
	u8                         hash_id;              /*   147     1 */

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

	size_t                     hash_len;             /*   152     8 */
	u8                         dhgroup_id;           /*   160     1 */
	u8                         c1[64];               /*   161    64 */
	/* --- cacheline 3 boundary (192 bytes) was 33 bytes ago --- */
	u8                         c2[64];               /*   225    64 */
	/* --- cacheline 4 boundary (256 bytes) was 33 bytes ago --- */
	u8                         response[64];         /*   289    64 */

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

	/* --- cacheline 5 boundary (320 bytes) was 40 bytes ago --- */
	u8 *                       host_response;        /*   360     8 */
	u8 *                       ctrl_key;             /*   368     8 */
	int                        ctrl_key_len;         /*   376     4 */

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

	/* --- cacheline 6 boundary (384 bytes) --- */
	u8 *                       host_key;             /*   384     8 */
	int                        host_key_len;         /*   392     4 */

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

	u8 *                       sess_key;             /*   400     8 */
	int                        sess_key_len;         /*   408     4 */

	/* size: 416, cachelines: 7, members: 25 */
	/* sum members: 393, holes: 4, sum holes: 19 */
	/* padding: 4 */
	/* last cacheline: 32 bytes */
};


After:
=====
struct nvme_dhchap_queue_context {
	struct list_head           entry;                /*     0    16 */
	struct work_struct         auth_work;            /*    16    80 */
	/* --- cacheline 1 boundary (64 bytes) was 32 bytes ago --- */
	struct nvme_ctrl *         ctrl;                 /*    96     8 */
	struct crypto_shash *      shash_tfm;            /*   104     8 */
	struct crypto_kpp *        dh_tfm;               /*   112     8 */
	void *                     buf;                  /*   120     8 */
	/* --- cacheline 2 boundary (128 bytes) --- */
	int                        qid;                  /*   128     4 */
	int                        error;                /*   132     4 */
	u32                        s1;                   /*   136     4 */
	u32                        s2;                   /*   140     4 */
	u16                        transaction;          /*   144     2 */
	u8                         status;               /*   146     1 */
	u8                         dhgroup_id;           /*   147     1 */
	u8                         hash_id;              /*   148     1 */

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

	size_t                     hash_len;             /*   152     8 */
	u8                         c1[64];               /*   160    64 */
	/* --- cacheline 3 boundary (192 bytes) was 32 bytes ago --- */
	u8                         c2[64];               /*   224    64 */
	/* --- cacheline 4 boundary (256 bytes) was 32 bytes ago --- */
	u8                         response[64];         /*   288    64 */
	/* --- cacheline 5 boundary (320 bytes) was 32 bytes ago --- */
	u8 *                       host_response;        /*   352     8 */
	u8 *                       ctrl_key;             /*   360     8 */
	u8 *                       host_key;             /*   368     8 */
	u8 *                       sess_key;             /*   376     8 */
	/* --- cacheline 6 boundary (384 bytes) --- */
	int                        ctrl_key_len;         /*   384     4 */
	int                        host_key_len;         /*   388     4 */
	int                        sess_key_len;         /*   392     4 */

	/* size: 400, cachelines: 7, members: 25 */
	/* sum members: 393, holes: 1, sum holes: 3 */
	/* padding: 4 */
	/* last cacheline: 16 bytes */
};
---
 drivers/nvme/host/auth.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index ea16a0aba679..daf5d144a8ea 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -30,18 +30,18 @@ struct nvme_dhchap_queue_context {
 	u32 s2;
 	u16 transaction;
 	u8 status;
+	u8 dhgroup_id;
 	u8 hash_id;
 	size_t hash_len;
-	u8 dhgroup_id;
 	u8 c1[64];
 	u8 c2[64];
 	u8 response[64];
 	u8 *host_response;
 	u8 *ctrl_key;
-	int ctrl_key_len;
 	u8 *host_key;
-	int host_key_len;
 	u8 *sess_key;
+	int ctrl_key_len;
+	int host_key_len;
 	int sess_key_len;
 };
 
-- 
2.34.1




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux