From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-doc@vger.kernel.org,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
LKML <linux-kernel@vger.kernel.org>,
Fabio Estevam <festevam@gmail.com>,
linux-stm32@st-md-mailman.stormreply.com,
Jonathan Corbet <corbet@lwn.net>,
Jiri Slaby <jirislaby@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Lino Sanfilippo <LinoSanfilippo@gmx.de>,
NXP Linux Team <linux-imx@nxp.com>,
linux-serial <linux-serial@vger.kernel.org>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Sascha Hauer <s.hauer@pengutronix.de>,
Vladimir Zapolskiy <vz@mleia.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-arm-kernel@lists.infradead.org,
Richard Genoud <richard.genoud@gmail.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Shawn Guo <shawnguo@kernel.org>,
Claudiu Beznea <claudiu.beznea@microchip.com>
Subject: Re: [PATCH v2 4/4] serial: Add kserial_rs485 to avoid wasted space due to .padding
Date: Tue, 30 Aug 2022 12:34:00 +0300 (EEST) [thread overview]
Message-ID: <31865b7-22f3-c07b-c934-83b44269eb3@linux.intel.com> (raw)
In-Reply-To: <Yw3PHg0imhJyb9sf@kroah.com>
[-- Attachment #1: Type: text/plain, Size: 2057 bytes --]
On Tue, 30 Aug 2022, Greg Kroah-Hartman wrote:
> On Tue, Aug 30, 2022 at 10:29:56AM +0300, Ilpo Järvinen wrote:
> > The struct serial_rs485 has a .padding field to make uapi updates
> > easier. It wastes space, however. Create struct kserial_rs485 which is
> > a kerner counterpart w/o padding.
>
> "kernel"?
>
> And what is the size difference now?
Roughly 16B of padding is eliminated. That saving is then multiplied by
the times it appears in in-kernel structs (2x per uart_port, 1x per rs485
supporting driver). As said in my other reply, if you feel it's too
little gained by eliminating the padding, I can drop this patch, just let
me know.
> > +/**
> > + * struct kserial_rs485 - kernel-side struct for controlling RS485 settings.
> > + * @flags: RS485 feature flags
> > + * @delay_rts_before_send: Delay before send (milliseconds)
> > + * @delay_rts_after_send: Delay after send (milliseconds)
> > + * @addr_recv: Receive filter for RS485 addressing mode
> > + * (used only when %SER_RS485_ADDR_RECV is set).
> > + * @addr_dest: Destination address for RS485 addressing mode
> > + * (used only when %SER_RS485_ADDR_DEST is set).
> > + *
> > + * Must match with struct serial_rs485 in include/uapi/linux/serial.h excluding
> > + * the padding.
>
> Why must this match?
Because serial_rs485_from_user() and serial_rs485_to_user() just copy
things over from one struct type to another w/o considering the fields
individually. If that's not acceptable, I could make it copy field by
field but it didn't feel necessary to allow "real" fields to differ to
achieve padding elimination...
> And how is that going to be enforced?
With static_assert()s in serial_core.c. I'll add a note about that into
the comment.
> > + */
> > +struct kserial_rs485 {
> > + __u32 flags;
> > + __u32 delay_rts_before_send;
> > + __u32 delay_rts_after_send;
> > + struct {
> > + __u8 addr_recv;
> > + __u8 addr_dest;
> > + };
>
> As this is an in-kernel structure, this should be "u32" and "u8" now.
Right, I'll change those.
--
i.
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-08-30 9:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220830072956.3630-1-ilpo.jarvinen@linux.intel.com>
2022-08-30 7:29 ` [PATCH v2 4/4] serial: Add kserial_rs485 to avoid wasted space due to .padding Ilpo Järvinen
2022-08-30 8:01 ` Jiri Slaby
2022-08-30 8:44 ` Ilpo Järvinen
2022-08-30 8:49 ` Greg Kroah-Hartman
2022-08-30 9:34 ` Ilpo Järvinen [this message]
2022-08-30 8:52 ` Greg Kroah-Hartman
2022-08-30 9:26 ` Ilpo Järvinen
2022-08-30 9:33 ` Greg Kroah-Hartman
2022-08-30 10:14 ` Ilpo Järvinen
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=31865b7-22f3-c07b-c934-83b44269eb3@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=LinoSanfilippo@gmx.de \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=claudiu.beznea@microchip.com \
--cc=corbet@lwn.net \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=mcoquelin.stm32@gmail.com \
--cc=richard.genoud@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=vz@mleia.com \
/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;
as well as URLs for NNTP newsgroup(s).