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: Christophe JAILLET X-Patchwork-Id: 58765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp52369wrn; Fri, 17 Feb 2023 12:25:32 -0800 (PST) X-Google-Smtp-Source: AK7set8vMtml2OcTKgxs9PTNtUf3XzKfp5Vzgzs5YYDgHd2oFqiPkpGZoAoisbL79BdP3nHgGE4Q X-Received: by 2002:a05:6402:68d:b0:4aa:a4e6:249b with SMTP id f13-20020a056402068d00b004aaa4e6249bmr2124785edy.7.1676665532067; Fri, 17 Feb 2023 12:25:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676665532; cv=none; d=google.com; s=arc-20160816; b=Ot5jcAbD1Ozo6sysvcsor8aj0He7yHeXjxGzQEw64/3TPw8xWmljRCWitD6FIJ9zSG eM/uvJQytUnKvj78u0np04RKHMpVSLyprHQBxp0nhPfLUwdwvG/wyB+jTVVxkmKPBaqE 3DsOfidyR0JuXgOO1zi4hHR0Z/iQ8gm+sg4j66JcDBeMoTOqZLZhXjgta0htiUFT6G7t 0QA8qCEKh0J9dlwu+gBPnS3LoXIqLhR2Q/Ly4tmJ/UoQZiJGbpN6BPUYj5wLrGkvcgMC G+NGQQhzGkeSX072M4YSuDRehmkFoCo2G6Kgn4Jy6USUPVNlsF6Fridq+HyIL9Xa6vh7 oJxQ== 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; bh=nBd0+4dG73CtpVA1ZD7C96yy1VtHau/gZJH8mRv8LNg=; b=HM9eK8U8NuRm03AlEeUIv+9Ww9AByVR05kk1Q5aVd7N9GJBXoj7NVxcNxS8U1KjYh4 9+PtQq9t+OzDMebOg6bsZgTZ49bKI1o7GXdSFPIEotJ9gjXS+JDntzNYJyEhZzPuAviU dWXH3iC/itkUzSkGob1mr5+7YeHlYsUSi6QU9KLv/lmL8M3IoEimmnUEQ0YKuAImfF/F jt6hmUna/rrQZ+mTAwpysHzNymmvC5MwNS8l7uKl13exDkdAs1b08CBeE9QWohWEAwzU lH9S4DaPeVpgxjQ2imPMCyvNn0OPYpUd85t3TIHUSq1Na/YBXWJD6U/Ce5RNkUC6gmW6 4V+Q== ARC-Authentication-Results: i=1; mx.google.com; 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 m25-20020aa7c499000000b004ad7203a2c6si5069706edq.230.2023.02.17.12.25.09; Fri, 17 Feb 2023 12:25:32 -0800 (PST) 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; 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 S229722AbjBQUXI (ORCPT + 99 others); Fri, 17 Feb 2023 15:23:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjBQUXH (ORCPT ); Fri, 17 Feb 2023 15:23:07 -0500 Received: from smtp.smtpout.orange.fr (smtp-11.smtpout.orange.fr [80.12.242.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE6012A147 for ; Fri, 17 Feb 2023 12:23:04 -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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758111236903526709?= X-GMAIL-MSGID: =?utf-8?q?1758111236903526709?= 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 *,