public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn•ch>
To: Jakub Kicinski <kuba@kernel•org>
Cc: davem@davemloft•net, netdev@vger•kernel.org, edumazet@google•com,
	pabeni@redhat•com, keescook@chromium•org, nbd@nbd•name,
	john@phrozen•org, sean.wang@mediatek•com,
	Mark-MC.Lee@mediatek•com, matthias.bgg@gmail•com
Subject: Re: [PATCH net-next] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning
Date: Fri, 20 May 2022 15:06:52 +0200	[thread overview]
Message-ID: <YoeSbH0d3qlAtwo6@lunn.ch> (raw)
In-Reply-To: <20220520055940.2309280-1-kuba@kernel.org>

On Thu, May 19, 2022 at 10:59:40PM -0700, Jakub Kicinski wrote:
> GCC 12 gets upset because in mtk_foe_entry_commit_subflow()
> this driver allocates a partial structure. The writes are
> within bounds.

I'm wondering if the partial structure is worth it:

struct mtk_flow_entry {
        union {
                struct hlist_node list;
                struct {
                        struct rhash_head l2_node;
                        struct hlist_head l2_flows;
                };
        };
        u8 type;
        s8 wed_index;
        u16 hash;
        union {
                struct mtk_foe_entry data;
                struct {
                        struct mtk_flow_entry *base_flow;
                        struct hlist_node list;
                        struct {} end;
                } l2_data;
        };
        struct rhash_head node;
        unsigned long cookie;
};


It allocates upto l2_data.end

struct rhash contains a single pointer

So this is saving 8 or 16 bytes depending on architecture.

I estimate the structure as a whole is at least 100 bytes on 32bit
systems.

I suppose it might make sense if this makes the allocation go from 129
bytes to <= 128, and the allocater is rounding up to the nearest power
of 2?

	Andrew

  reply	other threads:[~2022-05-20 13:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20  5:59 [PATCH net-next] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning Jakub Kicinski
2022-05-20 13:06 ` Andrew Lunn [this message]
2022-05-20 16:43   ` Jakub Kicinski

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=YoeSbH0d3qlAtwo6@lunn.ch \
    --to=andrew@lunn$(echo .)ch \
    --cc=Mark-MC.Lee@mediatek$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=john@phrozen$(echo .)org \
    --cc=keescook@chromium$(echo .)org \
    --cc=kuba@kernel$(echo .)org \
    --cc=matthias.bgg@gmail$(echo .)com \
    --cc=nbd@nbd$(echo .)name \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=sean.wang@mediatek$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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