public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] mfd: core: Reorder fields in 'struct mfd_cell' to save some memory
Date: Fri, 3 Mar 2023 10:10:29 +0000	[thread overview]
Message-ID: <20230303101029.GM2303077@google.com> (raw)
In-Reply-To: <bb631974888dfe1af593b6280cf30fb913d2d1a4.1676365116.git.christophe.jaillet@wanadoo.fr>

On Tue, 14 Feb 2023, Christophe JAILLET wrote:

> Group some variables based on their sizes to reduce hole and avoid padding.
> On x86_64, this shrinks the size from 144 to 128 bytes.
> 
> As an example:
> 
> $ size drivers/mfd/as3722.o (Before)
>    text	   data	    bss	    dec	    hex	filename
>    9441	    680	     16	  10137	   2799	drivers/mfd/as3722.o
> 
> $ size drivers/mfd/as3722.o (After)
>    text	   data	    bss	    dec	    hex	filename
>    9345	    680	     16	  10041	   2739	drivers/mfd/as3722.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Using pahole
> 
> Before:
> ======
> struct mfd_cell {
> 	const char  *              name;                 /*     0     8 */
> 	int                        id;                   /*     8     4 */
> 	int                        level;                /*    12     4 */
> 	int                        (*enable)(struct platform_device *); /*    16     8 */
> 	int                        (*disable)(struct platform_device *); /*    24     8 */
> 	int                        (*suspend)(struct platform_device *); /*    32     8 */
> 	int                        (*resume)(struct platform_device *); /*    40     8 */
> 	void *                     platform_data;        /*    48     8 */
> 	size_t                     pdata_size;           /*    56     8 */
> 	/* --- cacheline 1 boundary (64 bytes) --- */
> 	const struct software_node  * swnode;            /*    64     8 */
> 	const char  *              of_compatible;        /*    72     8 */
> 	const u64                  of_reg;               /*    80     8 */
> 	bool                       use_of_reg;           /*    88     1 */
> 
> 	/* XXX 7 bytes hole, try to pack */
> 
> 	const struct mfd_cell_acpi_match  * acpi_match;  /*    96     8 */
> 	int                        num_resources;        /*   104     4 */
> 
> 	/* XXX 4 bytes hole, try to pack */
> 
> 	const struct resource  *   resources;            /*   112     8 */
> 	bool                       ignore_resource_conflicts; /*   120     1 */
> 	bool                       pm_runtime_no_callbacks; /*   121     1 */
> 
> 	/* XXX 6 bytes hole, try to pack */
> 
> 	/* --- cacheline 2 boundary (128 bytes) --- */
> 	const char  * const *      parent_supplies;      /*   128     8 */
> 	int                        num_parent_supplies;  /*   136     4 */
> 
> 	/* size: 144, cachelines: 3, members: 20 */
> 	/* sum members: 123, holes: 3, sum holes: 17 */
> 	/* padding: 4 */
> 	/* last cacheline: 16 bytes */
> };
> 
> 
> After:
> =====
> struct mfd_cell {
> 	const char  *              name;                 /*     0     8 */
> 	int                        id;                   /*     8     4 */
> 	int                        level;                /*    12     4 */
> 	int                        (*enable)(struct platform_device *); /*    16     8 */
> 	int                        (*disable)(struct platform_device *); /*    24     8 */
> 	int                        (*suspend)(struct platform_device *); /*    32     8 */
> 	int                        (*resume)(struct platform_device *); /*    40     8 */
> 	void *                     platform_data;        /*    48     8 */
> 	size_t                     pdata_size;           /*    56     8 */
> 	/* --- cacheline 1 boundary (64 bytes) --- */
> 	const struct mfd_cell_acpi_match  * acpi_match;  /*    64     8 */
> 	const struct software_node  * swnode;            /*    72     8 */
> 	const char  *              of_compatible;        /*    80     8 */
> 	const u64                  of_reg;               /*    88     8 */
> 	bool                       use_of_reg;           /*    96     1 */
> 
> 	/* XXX 3 bytes hole, try to pack */
> 
> 	int                        num_resources;        /*   100     4 */
> 	const struct resource  *   resources;            /*   104     8 */
> 	bool                       ignore_resource_conflicts; /*   112     1 */
> 	bool                       pm_runtime_no_callbacks; /*   113     1 */
> 
> 	/* XXX 2 bytes hole, try to pack */
> 
> 	int                        num_parent_supplies;  /*   116     4 */
> 	const char  * const *      parent_supplies;      /*   120     8 */
> 
> 	/* size: 128, cachelines: 2, members: 20 */
> 	/* sum members: 123, holes: 2, sum holes: 5 */
> };
> ---
>  include/linux/mfd/core.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks

-- 
Lee Jones [李琼斯]

      reply	other threads:[~2023-03-03 10:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14  8:58 [PATCH] mfd: core: Reorder fields in 'struct mfd_cell' to save some memory Christophe JAILLET
2023-03-03 10:10 ` Lee Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230303101029.GM2303077@google.com \
    --to=lee@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox