From patchwork Mon May 1 12:40:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 89039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2669834vqo; Mon, 1 May 2023 05:51:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6i7Si9PZlKYPnJtzT9i3W66nsuHhPVcRyNTdFAPzcmCVE3ay/zmfSts4s6CGxzGtKoKJQt X-Received: by 2002:a05:6a00:168b:b0:63b:5496:7afa with SMTP id k11-20020a056a00168b00b0063b54967afamr19963238pfc.11.1682945497279; Mon, 01 May 2023 05:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682945497; cv=none; d=google.com; s=arc-20160816; b=I0+c83g2sENmVQca68vJlAXbL6BtYTnX5Cr9gA0FV2jRm/AZoHx8cuOtFFHHDnDAET kj3VTEWtzX0UjPwWmygqHwLCOG83vUWS0mdpmruKIGKWZ8Zy3wcC+XuwCsj5STXZqaZG aCjHnKnuQZJAM2+zy5womWDmsaRMVueGk0hNI1bCYD+yKIajXXFyaEvhIdGQzdb2Url/ OuSyQoaCHa0Ey7tNlI3bPFme5ivYJvMpb7MC2B/Zll0zZENaaF31404mV9CI4x+EFS2f 9Jc4wM8l8yATU8Jpmkw+Twb8ScwF9e37KQy1/C6euZ8lvJMR80IZYkZRPpCN8K33e8Yi fbeQ== 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=EHhwOOQJhYG1zhAhvZ6TNtxRY+Z65siR69ZTkVbLHsk=; b=UqEW0FBVzSh2e5luNoKPM3WMm7zCQpg9X79uxdfK8fwiVoYHzPli0yu5UzEliCSvef AhM963f2hp+ZGYi1NsqDBsYRjdfkcw00DyHZJrRbZQwXYLW0/vMSRFcwRn2jR6/7V9Y0 RmhBXiL1kTJQPcJ3+e1FcqYl27gi9YxDxNyzx5r/rne3ycl6hyKz9n9mU4AanGVefeWa KqVQlEeODte//gkPC1e3mkdBazmjyymSOftPaLrJrXo5Ayi3H6rj/CtrrW78h8D8PFFQ jbgvd1jithTI+WAFHonJfHX4OE2ooSuVKpY2yFvMqsAXGuSX9E6918pzZ8WhdzpBvp99 KdNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=I8VtBR0K; 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 b2-20020a656682000000b0051367d909efsi24308019pgw.106.2023.05.01.05.51.22; Mon, 01 May 2023 05:51:37 -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=I8VtBR0K; 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 S232613AbjEAMlz (ORCPT + 99 others); Mon, 1 May 2023 08:41:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232602AbjEAMls (ORCPT ); Mon, 1 May 2023 08:41:48 -0400 Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE92A10FF for ; Mon, 1 May 2023 05:41:13 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id tSpZpM6hwpwRItSplpInbJ; Mon, 01 May 2023 14:40:49 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682944849; bh=EHhwOOQJhYG1zhAhvZ6TNtxRY+Z65siR69ZTkVbLHsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I8VtBR0KIkrJ450/GNdjOJGydw0hy4+xO//IkaI1yGpXbnf3Tovs0FaycrPclQVBI Mcj/QX4e2oQwrnLtNZmgRtP2IfUpq4SZukQvd1zR8+uqWaRmy9ktr/n02SaBnf9VIO WAqCN8Kpm97D/BtiSkfSdDbnwb/6GwquDKI7oREPAUSFkSKUT7VEcom3dB2LMvTl3K R2xRIO+dBG8xlk6G/KW1YoBKABK2sQBVxl/xJZPdEh1allWpmA4y7OglEMcGP0bKjw Cgi027/7+vx6zKr9fR/yhImPxy4nbRJ7JoXMaLpNtMQtDa8rOTho5LFg+CdDLk9bqH EbpX3PWvO7PQQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 01 May 2023 14:40:49 +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 4/5] nvmet: Reorder fields in 'struct nvme_dhchap_queue_context' Date: Mon, 1 May 2023 14:40:28 +0200 Message-Id: <829091a6a1d5e20112f8e6b0b3d44b384dc7ae98.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?1764696258034385429?= X-GMAIL-MSGID: =?utf-8?q?1764696258034385429?= 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 --- 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; };