From patchwork Thu Apr 27 18:05:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13225687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FE07C77B61 for ; Thu, 27 Apr 2023 18:13:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243708AbjD0SNV (ORCPT ); Thu, 27 Apr 2023 14:13:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbjD0SNU (ORCPT ); Thu, 27 Apr 2023 14:13:20 -0400 X-Greylist: delayed 451 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 27 Apr 2023 11:13:19 PDT Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C8EBD3C29 for ; Thu, 27 Apr 2023 11:13:19 -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 To: Xiubo Li , Ilya Dryomov , Jeff Layton Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , 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 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 Reviewed-by: Jeff Layton --- 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; };