lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <2b87bc1e2168a79be02706411e874e9fce26d1e9.1682941568.git.christophe.jaillet@wanadoo.fr>
Date:   Mon,  1 May 2023 14:40:25 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     hch@....de, sagi@...mberg.me, kch@...dia.com
Cc:     linux-nvme@...ts.infradead.org, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>
Subject: [PATCH 1/5] nvmet: Reorder fields in 'struct nvmet_sq'

Group some variables based on their sizes to reduce holes.
On x86_64, this shrinks the size of 'struct nvmet_sq' from 472 to 464
bytes when CONFIG_NVME_TARGET_AUTH is defined.

This structure is embedded into some other structures, so it helps reducing
their sizes as well.

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

Before:
======
struct nvmet_sq {
	struct nvmet_ctrl *        ctrl;                 /*     0     8 */
	struct percpu_ref          ref;                  /*     8    16 */
	u16                        qid;                  /*    24     2 */
	u16                        size;                 /*    26     2 */
	u32                        sqhd;                 /*    28     4 */
	bool                       sqhd_disabled;        /*    32     1 */

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

	struct delayed_work        auth_expired_work;    /*    40   184 */

	/* XXX last struct has 4 bytes of padding */

	/* --- cacheline 3 boundary (192 bytes) was 32 bytes ago --- */
	bool                       authenticated;        /*   224     1 */

	/* XXX 1 byte hole, try to pack */

	u16                        dhchap_tid;           /*   226     2 */
	u16                        dhchap_status;        /*   228     2 */

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

	int                        dhchap_step;          /*   232     4 */

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

	u8 *                       dhchap_c1;            /*   240     8 */
	u8 *                       dhchap_c2;            /*   248     8 */
	/* --- cacheline 4 boundary (256 bytes) --- */
	u32                        dhchap_s1;            /*   256     4 */
	u32                        dhchap_s2;            /*   260     4 */
	u8 *                       dhchap_skey;          /*   264     8 */
	int                        dhchap_skey_len;      /*   272     4 */

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

	struct completion          free_done;            /*   280    96 */
	/* --- cacheline 5 boundary (320 bytes) was 56 bytes ago --- */
	struct completion          confirm_done;         /*   376    96 */

	/* size: 472, cachelines: 8, members: 19 */
	/* sum members: 454, holes: 5, sum holes: 18 */
	/* paddings: 1, sum paddings: 4 */
	/* last cacheline: 24 bytes */
};

After:
=====
struct nvmet_sq {
	struct nvmet_ctrl *        ctrl;                 /*     0     8 */
	struct percpu_ref          ref;                  /*     8    16 */
	u16                        qid;                  /*    24     2 */
	u16                        size;                 /*    26     2 */
	u32                        sqhd;                 /*    28     4 */
	bool                       sqhd_disabled;        /*    32     1 */
	bool                       authenticated;        /*    33     1 */

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

	struct delayed_work        auth_expired_work;    /*    40   184 */

	/* XXX last struct has 4 bytes of padding */

	/* --- cacheline 3 boundary (192 bytes) was 32 bytes ago --- */
	u16                        dhchap_tid;           /*   224     2 */
	u16                        dhchap_status;        /*   226     2 */
	int                        dhchap_step;          /*   228     4 */
	u8 *                       dhchap_c1;            /*   232     8 */
	u8 *                       dhchap_c2;            /*   240     8 */
	u32                        dhchap_s1;            /*   248     4 */
	u32                        dhchap_s2;            /*   252     4 */
	/* --- cacheline 4 boundary (256 bytes) --- */
	u8 *                       dhchap_skey;          /*   256     8 */
	int                        dhchap_skey_len;      /*   264     4 */

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

	struct completion          free_done;            /*   272    96 */
	/* --- cacheline 5 boundary (320 bytes) was 48 bytes ago --- */
	struct completion          confirm_done;         /*   368    96 */

	/* size: 464, cachelines: 8, members: 19 */
	/* sum members: 454, holes: 2, sum holes: 10 */
	/* paddings: 1, sum paddings: 4 */
	/* last cacheline: 16 bytes */
};
---
 drivers/nvme/target/nvmet.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index c50146085fb5..8cfd60f3b564 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -109,8 +109,8 @@ struct nvmet_sq {
 	u32			sqhd;
 	bool			sqhd_disabled;
 #ifdef CONFIG_NVME_TARGET_AUTH
-	struct delayed_work	auth_expired_work;
 	bool			authenticated;
+	struct delayed_work	auth_expired_work;
 	u16			dhchap_tid;
 	u16			dhchap_status;
 	int			dhchap_step;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ