Re: [PATCH 1/2] lib: Proportions with flexible period

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu 17-05-12 23:56:45, Peter Zijlstra wrote:
> On Tue, 2012-05-15 at 17:43 +0200, Jan Kara wrote:
> > +void fprop_fraction_percpu(struct fprop_global *p,
> > +                          struct fprop_local_percpu *pl,
> > +                          unsigned long *numerator, unsigned long *denominator)
> > +{
> > +       unsigned int seq;
> > +       s64 den;
> > +
> > +       do {
> > +               seq = read_seqcount_begin(&p->sequence);
> > +               fprop_reflect_period_percpu(p, pl);
> > +               *numerator = percpu_counter_read_positive(&pl->events);
> > +               den = percpu_counter_read(&p->events);
> > +               if (den <= 0)
> > +                       den = percpu_counter_sum(&p->events);
> > +               *denominator = den;
> > +       } while (read_seqcount_retry(&p->sequence, seq));
> > +} 
> 
> 
> why not use percpu_counter_read_positive(&p->events) and ditch
> percpu_counter_sum()? That sum can be terribly expensive..
  Yes. I'm actually not sure why I used the _sum here... Thanks for
spotting this.

								Honza
-- 
Jan Kara <jack@xxxxxxx>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]