[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1279442671.2476.34.camel@edumazet-laptop>
Date: Sun, 18 Jul 2010 10:44:31 +0200
From: Eric Dumazet <eric.dumazet@...il.com>
To: Nitin Gupta <ngupta@...are.org>
Cc: Pekka Enberg <penberg@...helsinki.fi>,
Hugh Dickins <hugh.dickins@...cali.co.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Greg KH <greg@...ah.com>,
Dan Magenheimer <dan.magenheimer@...cle.com>,
Rik van Riel <riel@...hat.com>, Avi Kivity <avi@...hat.com>,
Christoph Hellwig <hch@...radead.org>,
Minchan Kim <minchan.kim@...il.com>,
Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
linux-mm <linux-mm@...ck.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/8] Basic zcache functionality
Le vendredi 16 juillet 2010 à 18:07 +0530, Nitin Gupta a écrit :
> This particular patch implemets basic functionality only:
> +static u64 zcache_get_stat(struct zcache_pool *zpool,
> + enum zcache_pool_stats_index idx)
> +{
> + int cpu;
> + s64 val = 0;
> +
> + for_each_possible_cpu(cpu) {
> + unsigned int start;
> + struct zcache_pool_stats_cpu *stats;
> +
> + stats = per_cpu_ptr(zpool->stats, cpu);
> + do {
> + start = u64_stats_fetch_begin(&stats->syncp);
> + val += stats->count[idx];
> + } while (u64_stats_fetch_retry(&stats->syncp, start));
> + }
> +
> + BUG_ON(val < 0);
> + return val;
> +}
Sorry this is wrong.
Inside the fetch/retry block you should not do the addition to val, only
a read of value to a temporary variable, since this might be done
several times.
You want something like :
static u64 zcache_get_stat(struct zcache_pool *zpool,
enum zcache_pool_stats_index idx)
{
int cpu;
s64 temp, val = 0;
for_each_possible_cpu(cpu) {
unsigned int start;
struct zcache_pool_stats_cpu *stats;
stats = per_cpu_ptr(zpool->stats, cpu);
do {
start = u64_stats_fetch_begin(&stats->syncp);
temp = stats->count[idx];
} while (u64_stats_fetch_retry(&stats->syncp, start));
val += temp;
}
...
}
--
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