From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail203.messagelabs.com (mail203.messagelabs.com [216.82.254.243]) by kanga.kvack.org (Postfix) with SMTP id A83DA6B01F1 for ; Mon, 30 Aug 2010 12:20:28 -0400 (EDT) Date: Mon, 30 Aug 2010 11:20:10 -0500 (CDT) From: Christoph Lameter Subject: Re: [PATCH 03/10] Use percpu stats In-Reply-To: <1281374816-904-4-git-send-email-ngupta@vflare.org> Message-ID: References: <1281374816-904-1-git-send-email-ngupta@vflare.org> <1281374816-904-4-git-send-email-ngupta@vflare.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org To: Nitin Gupta Cc: Pekka Enberg , Minchan Kim , Andrew Morton , Greg KH , Linux Driver Project , linux-mm , linux-kernel List-ID: 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, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org