From patchwork Mon May 1 12:40:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 89040 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2671777vqo; Mon, 1 May 2023 05:55:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4b1ZGiXQSCPn5Kic32hdHmOEBqgeZes8sGT7dnC1dBQM+PoU+xrG/dys2mf8StHMOmzrqV X-Received: by 2002:a17:902:ceca:b0:1a9:581d:3efb with SMTP id d10-20020a170902ceca00b001a9581d3efbmr16934543plg.6.1682945745561; Mon, 01 May 2023 05:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682945745; cv=none; d=google.com; s=arc-20160816; b=S/D2qs4QaritGvNpmBc3VyxuP87Zg8KodxlcVKq1MzZ6AjMC/7NJU8MPd4T9GOWAzm Jf/oBSgX3/5OkD3ImpOnI5j7Xdhfvu0b7WdLlyH9RCcmERxk4HFySXV4iQcrNd8gpUVh aGYXvSyfewlYa6OSWl1vCzlBuT4MI4PKBXFohy+QRu1GUTl7w4xeIyFaFfSGdhpr5Qlr q45IigR0iU/HxBcd5VMxi4XYkVyZGwfxsX/Y+i8nd0579GVkSHZ7JE5bwWVpYfULSdLR g+XW2kpg66iSi1KU/XDPvR4bgER3tL8g21cGgOHoCaosOQakDdaFq4/EsjHira2lZK04 Sl8g== 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=C43rYffzeLeuYm1ltXsP0tciLDt8iNhANcYULlPeETQ=; b=UQpyBVaj6qcIF+Y70T+XC3x+pf/j+kQtRdfaGkipfduB0W+zysLIIYN4LqZdshbDbF xjJiZT/Sf/DCJtTrgAP49eDOytzyXObxtWG/HqtPd6kyjoSLkYA/KC/L6qoxhjaDL5+R xM1QC0f1YcMHOJcswHmuXLXJ6k166lJXsLMcf1HHCdv8G0kuEY+NCCHDo060MxTeTVZ2 5y0aCdUBTPFt+LqK8JJPhmU14rqHmedpFnw06lpLzyx4+Ozp5gydUuQ6mpT4hflJ5SeX emQ8xMxmYVW/buHi5X93V/g96wQ36iSau2l6JZhwBfVfT2Evu9WPJIKeefAgsgRirDd0 seVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=HQrssG6w; 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 t10-20020a170902e84a00b0019a826d3054si29286722plg.640.2023.05.01.05.55.30; Mon, 01 May 2023 05:55:45 -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=HQrssG6w; 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 S232540AbjEAMlq (ORCPT + 99 others); Mon, 1 May 2023 08:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232573AbjEAMlp (ORCPT ); Mon, 1 May 2023 08:41:45 -0400 Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 751CC1716 for ; Mon, 1 May 2023 05:41:10 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id tSpZpM6hwpwRItSpkpInb8; Mon, 01 May 2023 14:40:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682944848; bh=C43rYffzeLeuYm1ltXsP0tciLDt8iNhANcYULlPeETQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HQrssG6wByiAUvHE7mEaJaHjVvUhQyZjXSRSr4ruDx1SRpgEeS8XnMp4o3mQtwDFB KBfkH5y4ndSsmdjLjCbZsmYtbNSo92JROIcT3t1JDN/lzbvQC8E5vKYIDcVFWWY8Iw PoVzohoIiYtWqWty3vNTklmwKjjQ8az2XcWOko1YmtnGhnm1DK9MpkZNY03oeSOcxw EXEDzNN6NLRG1TPmP7dgPyi+IepdqHula80oVmG46HUajJ9HxmWhicjgBE84/UfgI0 87Lp0fqqmz1Jg+vL1H3Ro9U+9Oxr/51Xi1nBJu0mDvC4fT3RnDIDETcmx9R+i+PoK6 IWRKvy1z4HYzw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 01 May 2023 14:40:48 +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 3/5] nvmet: Reorder fields in 'struct nvmf_ctrl_options' Date: Mon, 1 May 2023 14:40:27 +0200 Message-Id: <78d06714ee7db7d977c390514b3bcfc71a07916f.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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1764696517962430994?= X-GMAIL-MSGID: =?utf-8?q?1764696517962430994?= Group some variables based on their sizes to reduce holes. On x86_64, this shrinks the size of 'struct nvmf_ctrl_options' from 136 to 128 bytes. When such a structure is allocated in nvmf_create_ctrl(), because of the way memory allocation works, when 136 bytes were requested, 192 bytes were allocated. So this saves 64 bytes per allocation, 1 cache line to hold the whole structure and a few cycles when zeroing the memory in nvmf_create_ctrl(). Signed-off-by: Christophe JAILLET --- Using pahole Before: ====== struct nvmf_ctrl_options { unsigned int mask; /* 0 4 */ /* XXX 4 bytes hole, try to pack */ char * transport; /* 8 8 */ char * subsysnqn; /* 16 8 */ char * traddr; /* 24 8 */ char * trsvcid; /* 32 8 */ char * host_traddr; /* 40 8 */ char * host_iface; /* 48 8 */ size_t queue_size; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ unsigned int nr_io_queues; /* 64 4 */ unsigned int reconnect_delay; /* 68 4 */ bool discovery_nqn; /* 72 1 */ bool duplicate_connect; /* 73 1 */ /* XXX 2 bytes hole, try to pack */ unsigned int kato; /* 76 4 */ struct nvmf_host * host; /* 80 8 */ int max_reconnects; /* 88 4 */ /* XXX 4 bytes hole, try to pack */ char * dhchap_secret; /* 96 8 */ char * dhchap_ctrl_secret; /* 104 8 */ bool disable_sqflow; /* 112 1 */ bool hdr_digest; /* 113 1 */ bool data_digest; /* 114 1 */ /* XXX 1 byte hole, try to pack */ unsigned int nr_write_queues; /* 116 4 */ unsigned int nr_poll_queues; /* 120 4 */ int tos; /* 124 4 */ /* --- cacheline 2 boundary (128 bytes) --- */ int fast_io_fail_tmo; /* 128 4 */ /* size: 136, cachelines: 3, members: 24 */ /* sum members: 121, holes: 4, sum holes: 11 */ /* padding: 4 */ /* last cacheline: 8 bytes */ }; After: ===== struct nvmf_ctrl_options { unsigned int mask; /* 0 4 */ int max_reconnects; /* 4 4 */ char * transport; /* 8 8 */ char * subsysnqn; /* 16 8 */ char * traddr; /* 24 8 */ char * trsvcid; /* 32 8 */ char * host_traddr; /* 40 8 */ char * host_iface; /* 48 8 */ size_t queue_size; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ unsigned int nr_io_queues; /* 64 4 */ unsigned int reconnect_delay; /* 68 4 */ bool discovery_nqn; /* 72 1 */ bool duplicate_connect; /* 73 1 */ /* XXX 2 bytes hole, try to pack */ unsigned int kato; /* 76 4 */ struct nvmf_host * host; /* 80 8 */ char * dhchap_secret; /* 88 8 */ char * dhchap_ctrl_secret; /* 96 8 */ bool disable_sqflow; /* 104 1 */ bool hdr_digest; /* 105 1 */ bool data_digest; /* 106 1 */ /* XXX 1 byte hole, try to pack */ unsigned int nr_write_queues; /* 108 4 */ unsigned int nr_poll_queues; /* 112 4 */ int tos; /* 116 4 */ int fast_io_fail_tmo; /* 120 4 */ /* size: 128, cachelines: 2, members: 24 */ /* sum members: 121, holes: 2, sum holes: 3 */ /* padding: 4 */ }; --- drivers/nvme/host/fabrics.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index dcac3df8a5f7..1bc57fb75825 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -77,6 +77,9 @@ enum { * with the parsing opts enum. * @mask: Used by the fabrics library to parse through sysfs options * on adding a NVMe controller. + * @max_reconnects: maximum number of allowed reconnect attempts before removing + * the controller, (-1) means reconnect forever, zero means remove + * immediately; * @transport: Holds the fabric transport "technology name" (for a lack of * better description) that will be used by an NVMe controller * being added. @@ -96,9 +99,6 @@ enum { * @discovery_nqn: indicates if the subsysnqn is the well-known discovery NQN. * @kato: Keep-alive timeout. * @host: Virtual NVMe host, contains the NQN and Host ID. - * @max_reconnects: maximum number of allowed reconnect attempts before removing - * the controller, (-1) means reconnect forever, zero means remove - * immediately; * @dhchap_secret: DH-HMAC-CHAP secret * @dhchap_ctrl_secret: DH-HMAC-CHAP controller secret for bi-directional * authentication @@ -112,6 +112,7 @@ enum { */ struct nvmf_ctrl_options { unsigned mask; + int max_reconnects; char *transport; char *subsysnqn; char *traddr; @@ -125,7 +126,6 @@ struct nvmf_ctrl_options { bool duplicate_connect; unsigned int kato; struct nvmf_host *host; - int max_reconnects; char *dhchap_secret; char *dhchap_ctrl_secret; bool disable_sqflow;