[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1008301114460.10316@router.home>
Date: Mon, 30 Aug 2010 11:20:10 -0500 (CDT)
From: Christoph Lameter <cl@...ux.com>
To: Nitin Gupta <ngupta@...are.org>
cc: Pekka Enberg <penberg@...helsinki.fi>,
Minchan Kim <minchan.kim@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
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, Nitin Gupta wrote:
> -static void zram_stat_inc(u32 *v)
> +static void zram_add_stat(struct zram *zram,
> + enum zram_stats_index idx, s64 val)
> {
> - *v = *v + 1;
> + struct zram_stats_cpu *stats;
> +
> + preempt_disable();
> + stats = __this_cpu_ptr(zram->stats);
> + u64_stats_update_begin(&stats->syncp);
> + stats->count[idx] += val;
> + u64_stats_update_end(&stats->syncp);
> + preempt_enable();
Maybe do
#define zram_add_stat(zram, index, val)
this_cpu_add(zram->stats->count[index], val)
instead? It creates an add in a single "atomic" per cpu instruction and
deals with the fallback scenarios for processors that cannot handle 64
bit adds.
--
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