Re: [PATCH v8 4/6] serial: 8250: drain canceled TX DMA before reusing its buffer

From
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date
2026-10-30 09:33:31
Also in
imx, linux-serial, linuxppc-dev, lkml
Reply to
James Hilliard, 2026-10-29
On Thu, Oct 29, 2026 at 11:15:23AM -0600, James Hilliard wrote:
On Thu, Oct 29, 2026 at 8:19 AM Andy Shevchenko
[off-list ref] wrote:
quoted
On Thu, Oct 29, 2026 at 01:37:00AM -0600, James Hilliard wrote:
...
quoted
quoted
-     bool                    shutting_down;
+     bool                    shutting_down:1;
+     bool                    tx_terminating:1;
+     bool                    tx_flushed:1;
What is the meaning of bool XXX:1? Have you checked with `pahole` the result?
These are one-bit boolean fields, intended to pack the state flags
into one byte.

I've now compared layout probes using the kernel type definitions and
saved build flags, changing only those bitfields to ordinary bools.
For the complete v8 structure, including the RX flags, pahole reports:

                            Bitfields   Plain bool
    ARM32 / Clang               212         220
    ARM64 / GCC                 368         376
    ARM64 / GCC / PREEMPT_RT     368         376

The sizes are in bytes. All six flags share one byte in the packed
version. This saves eight bytes in each checked configuration.
Thanks for checking!
The packing is a layout choice, not an atomicity mechanism; updates
still require the UART port lock. Given the measured saving, I'd keep
it unless there is another concern with using bool bitfields here.
I'm just worrying that bool bitfields are implementation defined and
might have some side-effects. But I see elsewhere in the kernel similar
approach, so I guess so far it didn't trigger any suspicious behaviour.

-- 
With Best Regards,
Andy Shevchenko


Thread (29 messages) 29 messages, 3 authors, last reply 2d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help