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  linux-cve-announce  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]
Message-ID: <20130826114643.GJ31370@twins.programming.kicks-ass.net>
Date:	Mon, 26 Aug 2013 13:46:46 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Paul Turner <pjt@...gle.com>
Cc:	Ingo Molnar <mingo@...nel.org>,
	Joonsoo Kim <iamjoonsoo.kim@....com>,
	LKML <linux-kernel@...r.kernel.org>,
	Mike Galbraith <efault@....de>, Alex Shi <alex.shi@...el.com>,
	Preeti U Murthy <preeti@...ux.vnet.ibm.com>,
	Vincent Guittot <vincent.guittot@...aro.org>,
	Morten Rasmussen <morten.rasmussen@....com>,
	Namhyung Kim <namhyung@...nel.org>,
	Lei Wen <leiwen@...vell.com>, Rik van Riel <riel@...riel.com>,
	Joonsoo Kim <js1304@...il.com>
Subject: Re: [PATCH 04/10] sched, fair: Shrink sg_lb_stats and play memset
 games

On Sat, Aug 24, 2013 at 03:15:57AM -0700, Paul Turner wrote:
> > +static inline void init_sd_lb_stats(struct sd_lb_stats *sds)
> > +{
> > +       /*
> > +        * struct sd_lb_stats {
> > +        *         struct sched_group *       busiest;             //     0  8
> > +        *         struct sched_group *       this;                //     8  8
> > +        *         long unsigned int          total_load;          //    16  8
> > +        *         long unsigned int          total_pwr;           //    24  8
> > +        *         long unsigned int          avg_load;            //    32  8
> > +        *         struct sg_lb_stats {
> > +        *                 long unsigned int  avg_load;            //    40  8
> > +        *                 long unsigned int  group_load;          //    48  8
> > +        *                 ...
> > +        *         } busiest_stat;                                 //    40 56
> > +        *         struct sg_lb_stats         this_stat;           //    96 56
> > +        *
> > +        *         // size: 152, cachelines: 3, members: 7
> > +        *         // last cacheline: 24 bytes
> > +        * };
> > +        *
> > +        * Skimp on the clearing to avoid duplicate work. We can avoid clearing
> > +        * this_stat because update_sg_lb_stats() does a full clear/assignment.
> > +        * We must however clear busiest_stat::avg_load because
> > +        * update_sd_pick_busiest() reads this before assignment.
> > +        */
> 
> Does gcc seriously not get this right if we just write:
>   sds->busiest = NULL;
>   sds->local = NULL;
>   ....
> 
> etc.?

There's a thought ;-) How about something like this?

 sds = (struct sd_lb_stats){
 	.busiest = NULL,
	.local = NULL,

	.busiest_stat = {
		.avg_load = 0,
	},
 };

C99 named initializers should ignore all unmentioned fields, and I think
we don't actually touch any of the other fields unless something is set.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ