lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 18 Oct 2020 11:26:53 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Andrew Lunn <andrew@...n.ch>
Cc:     Vladimir Oltean <vladimir.oltean@....com>, netdev@...r.kernel.org,
        f.fainelli@...il.com, vivien.didelot@...il.com,
        Christian Eggers <ceggers@...i.de>,
        Kurt Kanzenbach <kurt@...utronix.de>
Subject: Re: [RFC PATCH 01/13] net: dsa: add plumbing for custom netdev
 statistics

On Sun, 18 Oct 2020 19:36:49 +0200 Andrew Lunn wrote:
> On Sun, Oct 18, 2020 at 09:49:51AM -0700, Jakub Kicinski wrote:
> > > +	struct u64_stats_sync	syncp;
> > > +} __aligned(1 * sizeof(u64));  
> > 
> > Why aligned to u64? Compiler should pick a reasonable alignment here 
> > by itself.  
> 
> Hi Jakub
> 
> I wondered that as well. But:
> 
> struct gnet_stats_basic_cpu {
>         struct gnet_stats_basic_packed bstats;
>         struct u64_stats_sync syncp;
> } __aligned(2 * sizeof(u64));
> 
> /* often modified stats are per-CPU, other are shared (netdev->stats) */
> struct pcpu_sw_netstats {
>         u64     rx_packets;
>         u64     rx_bytes;
>         u64     tx_packets;
>         u64     tx_bytes;
>         struct u64_stats_sync   syncp;
> } __aligned(4 * sizeof(u64));
> 
> struct pcpu_lstats {
>         u64_stats_t packets;
>         u64_stats_t bytes;
>         struct u64_stats_sync syncp;
> } __aligned(2 * sizeof(u64));
> 
> Cargo cult or is there a real need?

Hm, looks like the intent is to enforce power of two alignment 
to prevent the structure from spanning cache lines. Doesn't make 
any difference for 1 counter, but I guess we can keep the style 
for consistency.

Powered by blists - more mailing lists