From patchwork Fri Feb 17 20:22:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marion & Christophe JAILLET X-Patchwork-Id: 654752 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 39574C05027 for ; Fri, 17 Feb 2023 20:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbjBQUah (ORCPT ); Fri, 17 Feb 2023 15:30:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbjBQUag (ORCPT ); Fri, 17 Feb 2023 15:30:36 -0500 X-Greylist: delayed 450 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 17 Feb 2023 12:30:35 PST Received: from smtp.smtpout.orange.fr (smtp-12.smtpout.orange.fr [80.12.242.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0CA0142BE5 for ; Fri, 17 Feb 2023 12:30:34 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id T7G2pKIElTHu0T7G2pfheb; Fri, 17 Feb 2023 21:23:03 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 17 Feb 2023 21:23:03 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-serial@vger.kernel.org Subject: [PATCH] serial: 8250: Reorder fields in 'struct plat_serial8250_port' Date: Fri, 17 Feb 2023 21:22:57 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Group some variables based on their sizes to reduce hole and avoid padding. On x86_64, this shrinks the size of 'struct plat_serial8250_port' from 144 to 128 bytes. It saves a few bytes of memory. Signed-off-by: Christophe JAILLET --- Using pahole Before: ====== struct plat_serial8250_port { long unsigned int iobase; /* 0 8 */ void * membase; /* 8 8 */ resource_size_t mapbase; /* 16 8 */ unsigned int irq; /* 24 4 */ /* XXX 4 bytes hole, try to pack */ long unsigned int irqflags; /* 32 8 */ unsigned int uartclk; /* 40 4 */ /* XXX 4 bytes hole, try to pack */ void * private_data; /* 48 8 */ unsigned char regshift; /* 56 1 */ unsigned char iotype; /* 57 1 */ unsigned char hub6; /* 58 1 */ unsigned char has_sysrq; /* 59 1 */ /* XXX 4 bytes hole, try to pack */ /* --- cacheline 1 boundary (64 bytes) --- */ upf_t flags; /* 64 8 */ unsigned int type; /* 72 4 */ /* XXX 4 bytes hole, try to pack */ unsigned int (*serial_in)(struct uart_port *, int); /* 80 8 */ void (*serial_out)(struct uart_port *, int, int); /* 88 8 */ void (*set_termios)(struct uart_port *, struct ktermios *, const struct ktermios *); /* 96 8 */ void (*set_ldisc)(struct uart_port *, struct ktermios *); /* 104 8 */ unsigned int (*get_mctrl)(struct uart_port *); /* 112 8 */ int (*handle_irq)(struct uart_port *); /* 120 8 */ /* --- cacheline 2 boundary (128 bytes) --- */ void (*pm)(struct uart_port *, unsigned int, unsigned int); /* 128 8 */ void (*handle_break)(struct uart_port *); /* 136 8 */ /* size: 144, cachelines: 3, members: 21 */ /* sum members: 128, holes: 4, sum holes: 16 */ /* last cacheline: 16 bytes */ }; After: ===== struct plat_serial8250_port { long unsigned int iobase; /* 0 8 */ void * membase; /* 8 8 */ resource_size_t mapbase; /* 16 8 */ unsigned int uartclk; /* 24 4 */ unsigned int irq; /* 28 4 */ long unsigned int irqflags; /* 32 8 */ void * private_data; /* 40 8 */ unsigned char regshift; /* 48 1 */ unsigned char iotype; /* 49 1 */ unsigned char hub6; /* 50 1 */ unsigned char has_sysrq; /* 51 1 */ unsigned int type; /* 52 4 */ upf_t flags; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ unsigned int (*serial_in)(struct uart_port *, int); /* 64 8 */ void (*serial_out)(struct uart_port *, int, int); /* 72 8 */ void (*set_termios)(struct uart_port *, struct ktermios *, const struct ktermios *); /* 80 8 */ void (*set_ldisc)(struct uart_port *, struct ktermios *); /* 88 8 */ unsigned int (*get_mctrl)(struct uart_port *); /* 96 8 */ int (*handle_irq)(struct uart_port *); /* 104 8 */ void (*pm)(struct uart_port *, unsigned int, unsigned int); /* 112 8 */ void (*handle_break)(struct uart_port *); /* 120 8 */ /* size: 128, cachelines: 2, members: 21 */ }; --- include/linux/serial_8250.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index 19376bee9667..741ed4807a9c 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -18,16 +18,16 @@ struct plat_serial8250_port { unsigned long iobase; /* io base address */ void __iomem *membase; /* ioremap cookie or NULL */ resource_size_t mapbase; /* resource base */ + unsigned int uartclk; /* UART clock rate */ unsigned int irq; /* interrupt number */ unsigned long irqflags; /* request_irq flags */ - unsigned int uartclk; /* UART clock rate */ void *private_data; unsigned char regshift; /* register shift */ unsigned char iotype; /* UPIO_* */ unsigned char hub6; unsigned char has_sysrq; /* supports magic SysRq */ - upf_t flags; /* UPF_* flags */ unsigned int type; /* If UPF_FIXED_TYPE */ + upf_t flags; /* UPF_* flags */ unsigned int (*serial_in)(struct uart_port *, int); void (*serial_out)(struct uart_port *, int, int); void (*set_termios)(struct uart_port *,