Message ID | aea924d31f2bd2f740b1ccc6f462905bd6cab763.1682624855.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp499641vqo; Thu, 27 Apr 2023 12:59:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4TLHUMwobBpAqELMObzO0YddulCMlDU4K2QiZmzWZYGZeqC18AMB54ZC67evQTjVhAXahm X-Received: by 2002:a05:6a20:7fa5:b0:f8:ac26:b899 with SMTP id d37-20020a056a207fa500b000f8ac26b899mr3536591pzj.0.1682625550226; Thu, 27 Apr 2023 12:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682625550; cv=none; d=google.com; s=arc-20160816; b=Wbqf2JORkLFYO9NLE8sk3MqpxztXsrxALMafpq518XzwHnW5BWxcJ3tmelZNOWXLGa amU5dQOPa9ZUOADvIL0v3/TMUX0X0NgQfTFtSjLoR7tMsHwj9jhxeLBMvF1iuKg0oVHS hszsMCfDfFO3hlJmW80aK99DRP++EvHkvWQ8ylqHO6HFsbT0C2fRDl2po/h3g4SBMrrb CoTypjn5uZkqlInaG0KpYaBS5HcZq3npn7+A/rVMTMqDMhoy0EVwbMU/a6oX7WyJToim 1an/ND/4ROYpi04pqdUw4duwWON/CmKx83S2uJuG0nXhxMMyESmCHXbBWfPjW1t7Ocr0 DkWQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=uWyb1m5f2X+6JFDK/HL+2kWjKi4n1QTlW4WSNRqI008=; b=hbCJ8828DmYLpbDT1Xlu2xbC81rQrVc6pSdsH+Dfxc/RgHMbxuufFDGI6JxcwEb12+ iYquf1RkMJDL6biw4aaozVc4M6OJ8M2dY4RvMVUClDW8UtytnFWonlbgJtmKubKJ3x53 8f1OVPI4q5z8tXzmxhCw48C/9jSE7T3MKsjLrQICFVu8U7xqpp0ShaI1mWnSImdCXjei zv6EXTsTNYx+YyQI5sstvCqygtO34i/e1nzmR78QAwLSAKcIMuazp5m3qIDK+gGF7H6n V10NcddmvBi58C01E4EkTRFeCRD2loTfhkZjZ1xa1aYgsJ8sHDkq40H8wf5euYEnztz3 yaZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=qmgSftFa; 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 y1-20020a633201000000b00524fe1e6a48si12945256pgy.440.2023.04.27.12.58.51; Thu, 27 Apr 2023 12:59:10 -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=qmgSftFa; 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 S231563AbjD0Tr4 (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Thu, 27 Apr 2023 15:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343617AbjD0Trz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Apr 2023 15:47:55 -0400 Received: from smtp.smtpout.orange.fr (smtp-29.smtpout.orange.fr [80.12.242.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29D912712 for <linux-kernel@vger.kernel.org>; Thu, 27 Apr 2023 12:47:51 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id s7akpPtNdcXjrs7akpwwwP; Thu, 27 Apr 2023 21:47:49 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682624869; bh=uWyb1m5f2X+6JFDK/HL+2kWjKi4n1QTlW4WSNRqI008=; h=From:To:Cc:Subject:Date; b=qmgSftFaXDoIy7rJcvHk/NEwLPV7x7AwfqnZ4JDXCWvDFcI22zViC8G4u9voe2XMC DmrhpMpkwIMvZcqbj+VAdoGWSgG13yFpXKrVrIS14WHb2441bwb02mOodFEqX8cGWc TOtKBD3dzDN+X376TuGZhEV4bZCpkXruag3avFeyR4gOkQO2xfv1+xlFePN6HyKJwU g5FGI5/rFQC7aNnZFU+LUaG8jp21KDjWm4HlxaBemF1f/hndmMLRkQoX/kxwqUK+IF FhBLn9/Ahkn/0NAVTUeKRoaa2jCBbgRrPnA+6nIM4VZ8IuepiSTOjO617jyHPvPSGU kTgZrEc9glp7Q== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 27 Apr 2023 21:47:49 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>, Chaitanya Kulkarni <kch@nvidia.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-nvme@lists.infradead.org Subject: [PATCH] nvmet: Reorder fields in 'struct nvmet_ns' Date: Thu, 27 Apr 2023 21:47:45 +0200 Message-Id: <aea924d31f2bd2f740b1ccc6f462905bd6cab763.1682624855.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764360768951321475?= X-GMAIL-MSGID: =?utf-8?q?1764360768951321475?= |
Series |
nvmet: Reorder fields in 'struct nvmet_ns'
|
|
Commit Message
Christophe JAILLET
April 27, 2023, 7:47 p.m. UTC
Group some variables based on their sizes to reduce holes.
On x86_64, this shrinks the size of 'struct nvmet_ns' from 520 to 512
bytes.
When such a structure is allocated in nvmet_ns_alloc(), because of the way
memory allocation works, when 520 bytes were requested, 1024 bytes were
allocated.
So, on x86_64, this change saves 512 bytes per allocation.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
More aggressive grouping could be done to be more future proof, but the
way the struct nvmet_ns is written suggest that some fields should be
kept together. So keep grouping as-is.
Using pahole
Before:
======
struct nvmet_ns {
struct percpu_ref ref; /* 0 16 */
struct block_device * bdev; /* 16 8 */
struct file * file; /* 24 8 */
bool readonly; /* 32 1 */
/* XXX 3 bytes hole, try to pack */
u32 nsid; /* 36 4 */
u32 blksize_shift; /* 40 4 */
/* XXX 4 bytes hole, try to pack */
loff_t size; /* 48 8 */
u8 nguid[16]; /* 56 16 */
/* --- cacheline 1 boundary (64 bytes) was 8 bytes ago --- */
uuid_t uuid; /* 72 16 */
u32 anagrpid; /* 88 4 */
bool buffered_io; /* 92 1 */
bool enabled; /* 93 1 */
/* XXX 2 bytes hole, try to pack */
struct nvmet_subsys * subsys; /* 96 8 */
const char * device_path; /* 104 8 */
struct config_group device_group; /* 112 136 */
/* --- cacheline 3 boundary (192 bytes) was 56 bytes ago --- */
struct config_group group; /* 248 136 */
/* --- cacheline 6 boundary (384 bytes) --- */
struct completion disable_done; /* 384 96 */
/* --- cacheline 7 boundary (448 bytes) was 32 bytes ago --- */
mempool_t * bvec_pool; /* 480 8 */
int use_p2pmem; /* 488 4 */
/* XXX 4 bytes hole, try to pack */
struct pci_dev * p2p_dev; /* 496 8 */
int pi_type; /* 504 4 */
int metadata_size; /* 508 4 */
/* --- cacheline 8 boundary (512 bytes) --- */
u8 csi; /* 512 1 */
/* size: 520, cachelines: 9, members: 23 */
/* sum members: 500, holes: 4, sum holes: 13 */
/* padding: 7 */
/* last cacheline: 8 bytes */
};
After:
=====
struct nvmet_ns {
struct percpu_ref ref; /* 0 16 */
struct block_device * bdev; /* 16 8 */
struct file * file; /* 24 8 */
bool readonly; /* 32 1 */
/* XXX 3 bytes hole, try to pack */
u32 nsid; /* 36 4 */
u32 blksize_shift; /* 40 4 */
/* XXX 4 bytes hole, try to pack */
loff_t size; /* 48 8 */
u8 nguid[16]; /* 56 16 */
/* --- cacheline 1 boundary (64 bytes) was 8 bytes ago --- */
uuid_t uuid; /* 72 16 */
u32 anagrpid; /* 88 4 */
bool buffered_io; /* 92 1 */
bool enabled; /* 93 1 */
/* XXX 2 bytes hole, try to pack */
struct nvmet_subsys * subsys; /* 96 8 */
const char * device_path; /* 104 8 */
struct config_group device_group; /* 112 136 */
/* --- cacheline 3 boundary (192 bytes) was 56 bytes ago --- */
struct config_group group; /* 248 136 */
/* --- cacheline 6 boundary (384 bytes) --- */
struct completion disable_done; /* 384 96 */
/* --- cacheline 7 boundary (448 bytes) was 32 bytes ago --- */
mempool_t * bvec_pool; /* 480 8 */
struct pci_dev * p2p_dev; /* 488 8 */
int use_p2pmem; /* 496 4 */
int pi_type; /* 500 4 */
int metadata_size; /* 504 4 */
u8 csi; /* 508 1 */
/* size: 512, cachelines: 8, members: 23 */
/* sum members: 500, holes: 3, sum holes: 9 */
/* padding: 3 */
};
---
drivers/nvme/target/nvmet.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 4/27/23 1:47 PM, Christophe JAILLET wrote: > Group some variables based on their sizes to reduce holes. > On x86_64, this shrinks the size of 'struct nvmet_ns' from 520 to 512 > bytes. > > When such a structure is allocated in nvmet_ns_alloc(), because of the way > memory allocation works, when 520 bytes were requested, 1024 bytes were > allocated. > > So, on x86_64, this change saves 512 bytes per allocation. > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > More aggressive grouping could be done to be more future proof, but the > way the struct nvmet_ns is written suggest that some fields should be > kept together. So keep grouping as-is. I think you did the right thing, that move doesn't matter and it brings it to pow-of-2 or less and that is really what matters. So looks fine to me: Reviewed-by: Jens Axboe <axboe@kernel.dk>
On 4/27/23 12:47, Christophe JAILLET wrote: > Group some variables based on their sizes to reduce holes. > On x86_64, this shrinks the size of 'struct nvmet_ns' from 520 to 512 > bytes. > Although this looks good, we at least need to document what happens on other arch(s) which are not mentioned in the commit log ? is there a possibility that someone might come up with the contradictory data in future for the arch(s) which arch that are not mentioned here ? -ck
On 4/27/23 4:59?PM, Chaitanya Kulkarni wrote: > On 4/27/23 12:47, Christophe JAILLET wrote: >> Group some variables based on their sizes to reduce holes. >> On x86_64, this shrinks the size of 'struct nvmet_ns' from 520 to 512 >> bytes. >> > > Although this looks good, we at least need to document what > happens on other arch(s) which are not mentioned in the > commit log ? is there a possibility that someone might come > up with the contradictory data in future for the arch(s) which > arch that are not mentioned here ? The change is certainly not going to make things _worse_ for any arch, so I think that's somewhat of a pointless exercise and an unreasonable ask for something that makes sense on 64-bit arm/x86 and saves half the space.
On 4/27/23 16:01, Jens Axboe wrote: > On 4/27/23 4:59?PM, Chaitanya Kulkarni wrote: >> On 4/27/23 12:47, Christophe JAILLET wrote: >>> Group some variables based on their sizes to reduce holes. >>> On x86_64, this shrinks the size of 'struct nvmet_ns' from 520 to 512 >>> bytes. >>> >> Although this looks good, we at least need to document what >> happens on other arch(s) which are not mentioned in the >> commit log ? is there a possibility that someone might come >> up with the contradictory data in future for the arch(s) which >> arch that are not mentioned here ? > The change is certainly not going to make things _worse_ for any arch, > so I think that's somewhat of a pointless exercise and an unreasonable > ask for something that makes sense on 64-bit arm/x86 and saves half the > space. > disregard my comment, looks good... Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck
(+Keith, for host side) > --- > More aggressive grouping could be done to be more future proof, but the > way the struct nvmet_ns is written suggest that some fields should be > kept together. So keep grouping as-is. > > you can send RFC and I'll be happy to take a look if it's going have any benefit, it will take some time though.. for host side :- while you are at it, it might be useful to take a look at the structures that are accessed in the fast path on the host side ? unless there is some reason for not doing that ... -ck
Le 28/04/2023 à 01:12, Chaitanya Kulkarni a écrit : > (+Keith, for host side) >> --- >> More aggressive grouping could be done to be more future proof, but the >> way the struct nvmet_ns is written suggest that some fields should be >> kept together. So keep grouping as-is. >> >> > > you can send RFC and I'll be happy to take a look if it's going > have any benefit, it will take some time though.. > > for host side :- > > while you are at it, it might be useful to take a look at the structures > that are accessed in the fast path on the host side ? Ok, why not, but can you help identifying these structures or places considered as fast path? CJ > > unless there is some reason for not doing that ... > > -ck > >
On 4/28/23 00:33, Christophe JAILLET wrote: > Le 28/04/2023 à 01:12, Chaitanya Kulkarni a écrit : >> (+Keith, for host side) >>> --- >>> More aggressive grouping could be done to be more future proof, but the >>> way the struct nvmet_ns is written suggest that some fields should be >>> kept together. So keep grouping as-is. >>> >>> >> >> you can send RFC and I'll be happy to take a look if it's going >> have any benefit, it will take some time though.. >> >> for host side :- >> >> while you are at it, it might be useful to take a look at the structures >> that are accessed in the fast path on the host side ? > > Ok, why not, but can you help identifying these structures or places > considered as fast path? > > CJ you can start with nvme_ns/nvme_ctrl as I remember nvme_ns is used in nvme_setup_rw_cmd() on host and nvme_ctrl is used in nvmet_passthru_execute_cmd(). In general nvme_queue_rq()/nvme_rdma_queue_rq()/ nvmet_bdev_execute_rw()/nvmet_file_execute_rw()/ nvmet_passthru_execute_cmd() are functions to start with, then you can see structs starting with nvme_ prefix (mainly related to ns and ctrl) which are worth taking a look and their benefits, but be careful what you are moving ... Ohh and nvmet_req that is also ... -ck
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Le 28/04/2023 à 01:07, Chaitanya Kulkarni a écrit : > On 4/27/23 16:01, Jens Axboe wrote: >> On 4/27/23 4:59?PM, Chaitanya Kulkarni wrote: >>> On 4/27/23 12:47, Christophe JAILLET wrote: >>>> Group some variables based on their sizes to reduce holes. >>>> On x86_64, this shrinks the size of 'struct nvmet_ns' from 520 to 512 >>>> bytes. >>>> >>> Although this looks good, we at least need to document what >>> happens on other arch(s) which are not mentioned in the >>> commit log ? is there a possibility that someone might come >>> up with the contradictory data in future for the arch(s) which >>> arch that are not mentioned here ? >> The change is certainly not going to make things _worse_ for any arch, >> so I think that's somewhat of a pointless exercise and an unreasonable >> ask for something that makes sense on 64-bit arm/x86 and saves half the >> space. >> > > disregard my comment, looks good... > > Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> > > -ck > > Hi, All my other nvmet patches have reached -next today, but this one seems to be missing. So this is a gentle reminder, in case it got lost somewhere. CJ
On 6/19/2023 11:08 AM, Christophe JAILLET wrote: > Le 28/04/2023 à 01:07, Chaitanya Kulkarni a écrit : >> On 4/27/23 16:01, Jens Axboe wrote: >>> On 4/27/23 4:59?PM, Chaitanya Kulkarni wrote: >>>> On 4/27/23 12:47, Christophe JAILLET wrote: >>>>> Group some variables based on their sizes to reduce holes. >>>>> On x86_64, this shrinks the size of 'struct nvmet_ns' from 520 to 512 >>>>> bytes. >>>>> >>>> Although this looks good, we at least need to document what >>>> happens on other arch(s) which are not mentioned in the >>>> commit log ? is there a possibility that someone might come >>>> up with the contradictory data in future for the arch(s) which >>>> arch that are not mentioned here ? >>> The change is certainly not going to make things _worse_ for any arch, >>> so I think that's somewhat of a pointless exercise and an unreasonable >>> ask for something that makes sense on 64-bit arm/x86 and saves half the >>> space. >>> >> >> disregard my comment, looks good... >> >> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> >> >> -ck >> >> > > Hi, > > > All my other nvmet patches have reached -next today, but this one seems > to be missing. > > So this is a gentle reminder, in case it got lost somewhere. > > CJ I believe this patch can still be applied as is on the top of nvme-6.5.. -ck
On Mon, Jun 19, 2023 at 08:08:38PM +0200, Christophe JAILLET wrote: > All my other nvmet patches have reached -next today, but this one seems to > be missing. > > So this is a gentle reminder, in case it got lost somewhere. Oops, thanks for the catch. I'll queue this up for the next 6.5 pull request.
Queued up now for nvme-6.5.
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index dc60a22646f7..c50146085fb5 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -79,8 +79,8 @@ struct nvmet_ns { struct completion disable_done; mempool_t *bvec_pool; - int use_p2pmem; struct pci_dev *p2p_dev; + int use_p2pmem; int pi_type; int metadata_size; u8 csi;