From patchwork Sun Jun 18 10:16:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13283793 X-Patchwork-Delegate: paul@paul-moore.com 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 C3813EB64D7 for ; Sun, 18 Jun 2023 10:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbjFRKYT (ORCPT ); Sun, 18 Jun 2023 06:24:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbjFRKYS (ORCPT ); Sun, 18 Jun 2023 06:24:18 -0400 X-Greylist: delayed 450 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 18 Jun 2023 03:24:17 PDT Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A727F13D for ; Sun, 18 Jun 2023 03:24:17 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id ApScqyYPQhQKVApScqcNqL; Sun, 18 Jun 2023 12:16:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1687083404; bh=DSknnbdi6ETR4gXl9xkSuTonkqso7NbmO9NcHs49YUM=; h=From:To:Cc:Subject:Date; b=oUN9wnGrAcXdub/3VYK2AdRcF/0yznYc5OEJ/3kjtVQlGrOA/H1dqj7zFj7ehR5RK 5bg6ZqB62JhYgTEVsuSv4iUSpSD3znp7a3L8BAFHhfZ/Gai78XX4LklQRZ15pBmYct XLupCOx4xWMyzxqosNKnPHmZ+bDtMtOt4+wqG3k109/31LmqYoioF+d+oRZBLULoMp jD3FbBVm6WuT6zL2Mn9B1/f7rAO6vt27wMSaVc8d39w9sw4REIyiB0zFnE9UrfB2ey Dx09kEEC4DeLn9MUTX2NX1gb5+o5JYLh8xo8814zzjl8qKlMJ/IFh2PUkuCjOcl2zc nhfjEZYWhhXFg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 18 Jun 2023 12:16:44 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Paul Moore , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map' Date: Sun, 18 Jun 2023 12:16:41 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: Group some variables based on their sizes to reduce hole and avoid padding. On x86_64, this shrinks the size of 'struct netlbl_domaddr6_map' from 72 to 64 bytes. It saves a few bytes of memory and is more cache-line friendly. Signed-off-by: Christophe JAILLET Reviewed-by: Simon Horman Reviewed-by: Jiri Pirko Acked-by: Paul Moore --- Using pahole Before: ====== struct netlbl_dom_map { char * domain; /* 0 8 */ u16 family; /* 8 2 */ /* XXX 6 bytes hole, try to pack */ struct netlbl_dommap_def def; /* 16 16 */ u32 valid; /* 32 4 */ /* XXX 4 bytes hole, try to pack */ struct list_head list; /* 40 16 */ struct callback_head rcu __attribute__((__aligned__(8))); /* 56 16 */ /* size: 72, cachelines: 2, members: 6 */ /* sum members: 62, holes: 2, sum holes: 10 */ /* forced alignments: 1 */ /* last cacheline: 8 bytes */ } __attribute__((__aligned__(8))); After: ===== struct netlbl_dom_map { char * domain; /* 0 8 */ struct netlbl_dommap_def def; /* 8 16 */ u16 family; /* 24 2 */ /* XXX 2 bytes hole, try to pack */ u32 valid; /* 28 4 */ struct list_head list; /* 32 16 */ struct callback_head rcu __attribute__((__aligned__(8))); /* 48 16 */ /* size: 64, cachelines: 1, members: 6 */ /* sum members: 62, holes: 1, sum holes: 2 */ /* forced alignments: 1 */ } __attribute__((__aligned__(8))); --- net/netlabel/netlabel_domainhash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netlabel/netlabel_domainhash.h b/net/netlabel/netlabel_domainhash.h index 9f80972ae39b..7eaa35fdd9bd 100644 --- a/net/netlabel/netlabel_domainhash.h +++ b/net/netlabel/netlabel_domainhash.h @@ -57,8 +57,8 @@ struct netlbl_domaddr6_map { struct netlbl_dom_map { char *domain; - u16 family; struct netlbl_dommap_def def; + u16 family; u32 valid; struct list_head list;