[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20100809213431.d7699d46.akpm@linux-foundation.org>
Date: Mon, 9 Aug 2010 21:34:31 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Nitin Gupta <ngupta@...are.org>
Cc: Pekka Enberg <penberg@...helsinki.fi>,
Minchan Kim <minchan.kim@...il.com>, Greg KH <greg@...ah.com>,
Linux Driver Project <devel@...verdev.osuosl.org>,
linux-mm <linux-mm@...ck.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 03/10] Use percpu stats
On Mon, 9 Aug 2010 22:56:49 +0530 Nitin Gupta <ngupta@...are.org> wrote:
> +/*
> + * Individual percpu values can go negative but the sum across all CPUs
> + * must always be positive (we store various counts). So, return sum as
> + * unsigned value.
> + */
> +static u64 zram_get_stat(struct zram *zram, enum zram_stats_index idx)
> {
> - u64 val;
> -
> - spin_lock(&zram->stat64_lock);
> - val = *v;
> - spin_unlock(&zram->stat64_lock);
> + int cpu;
> + s64 val = 0;
> +
> + for_each_possible_cpu(cpu) {
> + s64 temp;
> + unsigned int start;
> + struct zram_stats_cpu *stats;
> +
> + stats = per_cpu_ptr(zram->stats, cpu);
> + do {
> + start = u64_stats_fetch_begin(&stats->syncp);
> + temp = stats->count[idx];
> + } while (u64_stats_fetch_retry(&stats->syncp, start));
> + val += temp;
> + }
>
> + WARN_ON(val < 0);
> return val;
> }
That reimplements include/linux/percpu_counter.h, poorly.
Please see the June discussion "[PATCH v2 1/2] tmpfs: Quick token
library to allow scalable retrieval of tokens from token jar" for some
discussion.
--
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