From patchwork Mon May 1 12:40:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 89044 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2683986vqo; Mon, 1 May 2023 06:12:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MT1UrupKe+IljvYwLBYb7WrB+qiouhrUiMMgxdrUJkqYu2dYgd/uUwY7j/IU9fOPkJVnp X-Received: by 2002:a17:90b:209:b0:24e:cb3:f7f8 with SMTP id fy9-20020a17090b020900b0024e0cb3f7f8mr2150137pjb.46.1682946737489; Mon, 01 May 2023 06:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682946737; cv=none; d=google.com; s=arc-20160816; b=NPds74z/HPDPkuNCVMCts0K05m+b/FLwabWBp6zyJhVRAxRG7gM7MuI2EyglWoorYH SoqHc+AWQ/44u46Pg6tMpqxPV3QoL8ANPR6Ktoc/4IRBkKLdKoaUhfJpi5NdqYVqw0YO ctJP29tAEzvdUFbmtcavTjniaqSduajlvINwTCqFkv+/oUlmipm9fkrZ6CKZjY6qXwOy F3ktwiER5P9/qGIS7GvPIz126L/fEy1NaiTz29W56mHFoXhIYkjqp3+Q2mx0dqh68z1B j8RYF5+yepJQv4vdRnlXErURmCU/Gj47XQ+WZ0tqQ8jOL/XyqfyHz72BuvCMOlA/hYai uKJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QDh3dDPZUR9lwcq90WRl6vCV6llx9SiFdI20B6fyPHs=; b=AHe+OoksBIIJMFB+t6EKTAMrNLSkZdXSEtwoNjOSwz2Y/Og41Ah4Bvb4ZyDOwFG96p TIO5xMuJS0QGoPnWUrMH7DK+UihLoLQcFWIZ6c4AnqH4lrts8byxmj/cUskEaAMtZtm9 dPZo9fRuq2fNlcs49o1jC4LznbvyknbYaII6tqg3kSMr/DdwYZZNBACRy4XXerXNdAAL pYAiOioietsedtHYLUJqiKjRYKGXZwBf09iyDYPQGZ2n4P5s4Bh2EUMLa/GGF9VTVdf4 DrO51wURw0Tmwo+op+FHHTUHd3+iZ4fpBF8IphnZSUeD3DzQNNu7HPBoVnT52kestCXl YqPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=LMXMGduj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kx18-20020a17090b229200b00242bface51csi8537675pjb.108.2023.05.01.06.11.48; Mon, 01 May 2023 06:12:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=LMXMGduj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232487AbjEAMli (ORCPT + 99 others); Mon, 1 May 2023 08:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbjEAMlf (ORCPT ); Mon, 1 May 2023 08:41:35 -0400 Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA8C619A2 for ; Mon, 1 May 2023 05:41:06 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id tSpZpM6hwpwRItSphpInat; Mon, 01 May 2023 14:40:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682944846; bh=QDh3dDPZUR9lwcq90WRl6vCV6llx9SiFdI20B6fyPHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LMXMGdujWEzj0tnyZphahhdqBGzQr/fbX/JBdsW+3+ua2l3IopaC+8U7k4vgBcdMM XDVMlwba+gB+JVSj4TbiqF4Opi8TxRaMhRu/iE7Z1wP1/aSiQmdZ6AT9i9KkbWhHJX Z5kPhJJDiW78EMgrMhj1DWsvWk1paOG73+NUMV4nPbB49S7kTjlBTO/ZckEShOWt/D aJTnvwIbsNP+P00fCznQxoqzLk4qG9CrCU1XQL63pnGH3qZ2wer5vAYK6cCMwLJeRY SaJF071jLecexhzYRQmZTXHO9AbAmXBDy4o3Xh+Hxks8XNcx2UxMdRspphrAz54xRo YEI/gUH9xvO6g== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 01 May 2023 14:40:46 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: hch@lst.de, sagi@grimberg.me, kch@nvidia.com Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 1/5] nvmet: Reorder fields in 'struct nvmet_sq' Date: Mon, 1 May 2023 14:40:25 +0200 Message-Id: <2b87bc1e2168a79be02706411e874e9fce26d1e9.1682941568.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764697558193838779?= X-GMAIL-MSGID: =?utf-8?q?1764697558193838779?= 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 --- 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;