lkml.org 
[lkml]   [2013]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.



\
 
 \ /
  Last update: 2013-08-26 14:01    [W:0.151 / U:0.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site