[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1337291805.4281.97.camel@twins>
Date: Thu, 17 May 2012 23:56:45 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Jan Kara <jack@...e.cz>
Cc: Wu Fengguang <fengguang.wu@...el.com>,
LKML <linux-kernel@...r.kernel.org>, linux-mm@...ck.org
Subject: Re: [PATCH 1/2] lib: Proportions with flexible period
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..
--
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