Re: [PATCH net v4 01/12] net: core: limit nested device depth

From
Taehee Yoo <ap420073@gmail.com>
Date
2019-10-01 18:24:10
Also in
linux-wireless
Reply to
Johannes Berg, 2019-10-01
On Tue, 1 Oct 2019 at 22:57, Johannes Berg [off-list ref] wrote:
Hi,
Hi!
(jumping out now, forgive me for being so brief)
quoted
If I understand correctly, you said about the alignment of
"lower_level" and "upper_level".
I thought this place is a fine position for variables as regards the
alignment and I didn't try to put each variable in different places.

If I misunderstood your mention, please let me know.
Not sure what you mean, alignment doesn't matter for them (they're u8).

I was thinking of the packing for the overall struct, we have:

        unsigned int            max_mtu;
        unsigned short          type;
        unsigned short          hard_header_len;
        unsigned char           min_header_len;

+       unsigned char           upper_level, lower_level;

        unsigned short          needed_headroom;
        unsigned short          needed_tailroom;


Previously, there was a one byte hole at that spot due to a single
"unsigned char" (after something aligned at least 4 bytes) followed by
"unsigned short" - now you push that out a bit.

If you place the variables a bit lower, below "name_assign_type", you
probably fill a hole instead.

Check out the 'pahole' tool.
Thank you for the detailed explanation.
I tested the pahole and found holes.

$ pahole ./vmlinux.o -C net_device
        unsigned char              addr_assign_type;     /*   598     1 */
        unsigned char              addr_len;             /*   599     1 */
        short unsigned int         neigh_priv_len;       /*   600     2 */
        short unsigned int         dev_id;               /*   602     2 */
        short unsigned int         dev_port;             /*   604     2 */

        /* XXX 2 bytes hole, try to pack */

I will place the variables here.
johannes
Thank you so much!
Taehee
Thread (37 messages) 37 messages, 4 authors, last reply 2019-10-21
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