Message ID | 559c9a70419846e0cfc319505d3d5fffd45b3358.1682618727.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 b10csp468452vqo; Thu, 27 Apr 2023 11:56:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5LooaNJhKnA8WY4P0czG2nyv1yOMFFC7yYS+UQKr/7zUn0B+jXCJLTpDMJJ51xsf5WnNxV X-Received: by 2002:a05:6a20:9597:b0:f2:8c89:cd30 with SMTP id iu23-20020a056a20959700b000f28c89cd30mr3054021pzb.13.1682621813404; Thu, 27 Apr 2023 11:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682621813; cv=none; d=google.com; s=arc-20160816; b=jI7b+fIz2mWPsNKZtu+MQmBxgAYpdO9u4gAad7DcEvO24vhASBoWKhbeK7i06HbINl XosDhrvlmecuyO0Dyp0ZNY1/WEa+JyfxEXLp/JIZ6uOB3tPjiEXTOH2nQR7xKfYhxpET SUoDIwxvBghXO8vanItC1oWKvYK7sv9qKXjR9ItlkTJdv4li8yOkIkq9YC2s3zdfPHVl Wa644VM+HFch3WO6ck4yDz+zNarQVHrE7xsjchsKhkk+1bJoXa9nN6CzG3z7vGDkzFfD hmQFyKODVfh6hE/OR/1SVLu2BoSU1n38Cav/2ionHjk5sD9iprK0RmEcdIIrNb1p7bz9 Gi6w== 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=05s457roHVtlfYNypW2X8/+0EwbbmCegZeHOrtx9DR8=; b=ddaq3jEXF2j0cH/K6CbgCglH+P2SMBmZNUn4dKgifwCyrIPS4A+IYxBW08i0E7/UQD wMmbJWZREywx85T8A3EK4VD3Ei+3FbeqTlI6H/33OMiNMJhrnWzvm1zBUbPFQT8ogA54 wN57n/6FIZxqpL8NCSdWCEe7dtJUZD/sTO8SoZP8QN4nrysFy5Lm+BXoyuFnK8TmtL9r wIIopYOZV87QphoizJUvC5VbmIynJLia/+Lw2WIFhMfZD4OL4spLam/1c2xATIxXIePi 8jGQmYWEngdk4zrDkcJ0IO/hA4PE3QUPsL9xraTVAM5Jv6Gjcu1H+9dWLxhxI2/10j06 Ihjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=LkiPyXmL; 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 j65-20020a638b44000000b0052004f9add5si19688501pge.551.2023.04.27.11.56.38; Thu, 27 Apr 2023 11:56:53 -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=LkiPyXmL; 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 S229539AbjD0SFy (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Thu, 27 Apr 2023 14:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243708AbjD0SFw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Apr 2023 14:05:52 -0400 Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C7E43A91 for <linux-kernel@vger.kernel.org>; Thu, 27 Apr 2023 11:05:48 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id s601pK3Rr0J4ws601pkhoW; Thu, 27 Apr 2023 20:05:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682618747; bh=05s457roHVtlfYNypW2X8/+0EwbbmCegZeHOrtx9DR8=; h=From:To:Cc:Subject:Date; b=LkiPyXmL2zlMA/UwRMeBbsLQ+zg60jEPXuq+invSzYxMIqjcsOMYHSqLEZg/HQz5s orqf91Xnu06X72a3b8udo8vj3bvVArLWjlWnR+W2FLzZICQlXsqlXb9EbzTgkmncZE jiiDqb50dW2vVlp2rZmnOWaSE+N5zCdaKQ0G6xE5Sl23NAvANSDtt055JNTNg9D/5e +2jRcQ0dtVjgeW0HkqoeASQyhnpXOewv2PalEz3AIvXVeWkRorFkd1ukqRkEP1Zvyj ymDqhXVTR7pycsucL/Ka2nzBSGeOPixooayHLgwYSR5AgBVC+Wa0O81PcSQgnVJEIF T1SxDLhPlWIJw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 27 Apr 2023 20:05:46 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Xiubo Li <xiubli@redhat.com>, Ilya Dryomov <idryomov@gmail.com>, Jeff Layton <jlayton@kernel.org> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, ceph-devel@vger.kernel.org Subject: [PATCH] ceph: Reorder fields in 'struct ceph_snapid_map' Date: Thu, 27 Apr 2023 20:05:42 +0200 Message-Id: <559c9a70419846e0cfc319505d3d5fffd45b3358.1682618727.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_H2,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: <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?1764356850704637378?= X-GMAIL-MSGID: =?utf-8?q?1764356850704637378?= |
Series |
ceph: Reorder fields in 'struct ceph_snapid_map'
|
|
Commit Message
Christophe JAILLET
April 27, 2023, 6:05 p.m. UTC
Group some variables based on their sizes to reduce holes.
On x86_64, this shrinks the size of 'struct ceph_snapid_map' from 72 to 64
bytes.
When such a structure is allocated, because of the way memory allocation
works, when 72 bytes were requested, 96 bytes were allocated.
So, on x86_64, this change saves 32 bytes per allocation and has the
structure fit in a single cacheline.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Using pahole
Before:
======
struct ceph_snapid_map {
struct rb_node node __attribute__((__aligned__(8))); /* 0 24 */
struct list_head lru; /* 24 16 */
atomic_t ref; /* 40 4 */
/* XXX 4 bytes hole, try to pack */
u64 snap; /* 48 8 */
dev_t dev; /* 56 4 */
/* XXX 4 bytes hole, try to pack */
/* --- cacheline 1 boundary (64 bytes) --- */
long unsigned int last_used; /* 64 8 */
/* size: 72, cachelines: 2, members: 6 */
/* sum members: 64, holes: 2, sum holes: 8 */
/* forced alignments: 1 */
/* last cacheline: 8 bytes */
} __attribute__((__aligned__(8)));
---
fs/ceph/mds_client.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 4/28/23 02:05, Christophe JAILLET wrote: > Group some variables based on their sizes to reduce holes. > On x86_64, this shrinks the size of 'struct ceph_snapid_map' from 72 to 64 > bytes. > > When such a structure is allocated, because of the way memory allocation > works, when 72 bytes were requested, 96 bytes were allocated. > > So, on x86_64, this change saves 32 bytes per allocation and has the > structure fit in a single cacheline. > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > Using pahole > > Before: > ====== > struct ceph_snapid_map { > struct rb_node node __attribute__((__aligned__(8))); /* 0 24 */ > struct list_head lru; /* 24 16 */ > atomic_t ref; /* 40 4 */ > > /* XXX 4 bytes hole, try to pack */ > > u64 snap; /* 48 8 */ > dev_t dev; /* 56 4 */ > > /* XXX 4 bytes hole, try to pack */ > > /* --- cacheline 1 boundary (64 bytes) --- */ > long unsigned int last_used; /* 64 8 */ > > /* size: 72, cachelines: 2, members: 6 */ > /* sum members: 64, holes: 2, sum holes: 8 */ > /* forced alignments: 1 */ > /* last cacheline: 8 bytes */ > } __attribute__((__aligned__(8))); > --- > fs/ceph/mds_client.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h > index 0598faa50e2e..2328dbda5ab6 100644 > --- a/fs/ceph/mds_client.h > +++ b/fs/ceph/mds_client.h > @@ -355,8 +355,8 @@ struct ceph_snapid_map { > struct rb_node node; > struct list_head lru; > atomic_t ref; > - u64 snap; > dev_t dev; > + u64 snap; > unsigned long last_used; > }; > This looks good to me. Thanks. Will apply it to the testing branch. - Xiubo
On Fri, 2023-04-28 at 08:53 +0800, Xiubo Li wrote: > On 4/28/23 02:05, Christophe JAILLET wrote: > > Group some variables based on their sizes to reduce holes. > > On x86_64, this shrinks the size of 'struct ceph_snapid_map' from 72 to 64 > > bytes. > > > > When such a structure is allocated, because of the way memory allocation > > works, when 72 bytes were requested, 96 bytes were allocated. > > > > So, on x86_64, this change saves 32 bytes per allocation and has the > > structure fit in a single cacheline. > > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > --- > > Using pahole > > > > Before: > > ====== > > struct ceph_snapid_map { > > struct rb_node node __attribute__((__aligned__(8))); /* 0 24 */ > > struct list_head lru; /* 24 16 */ > > atomic_t ref; /* 40 4 */ > > > > /* XXX 4 bytes hole, try to pack */ > > > > u64 snap; /* 48 8 */ > > dev_t dev; /* 56 4 */ > > > > /* XXX 4 bytes hole, try to pack */ > > > > /* --- cacheline 1 boundary (64 bytes) --- */ > > long unsigned int last_used; /* 64 8 */ > > > > /* size: 72, cachelines: 2, members: 6 */ > > /* sum members: 64, holes: 2, sum holes: 8 */ > > /* forced alignments: 1 */ > > /* last cacheline: 8 bytes */ > > } __attribute__((__aligned__(8))); > > --- > > fs/ceph/mds_client.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h > > index 0598faa50e2e..2328dbda5ab6 100644 > > --- a/fs/ceph/mds_client.h > > +++ b/fs/ceph/mds_client.h > > @@ -355,8 +355,8 @@ struct ceph_snapid_map { > > struct rb_node node; > > struct list_head lru; > > atomic_t ref; > > - u64 snap; > > dev_t dev; > > + u64 snap; > > unsigned long last_used; > > }; > > > > This looks good to me. Thanks. > > Will apply it to the testing branch. > > - Xiubo > > > Reviewed-by: Jeff Layton <jlayton@kernel.org>
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 0598faa50e2e..2328dbda5ab6 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -355,8 +355,8 @@ struct ceph_snapid_map { struct rb_node node; struct list_head lru; atomic_t ref; - u64 snap; dev_t dev; + u64 snap; unsigned long last_used; };