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 9BD716B007B for ; Tue, 31 Aug 2010 16:31:10 -0400 (EDT) Received: by gwj16 with SMTP id 16so3582928gwj.14 for ; Tue, 31 Aug 2010 13:31:09 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1281374816-904-1-git-send-email-ngupta@vflare.org> <1281374816-904-4-git-send-email-ngupta@vflare.org> Date: Tue, 31 Aug 2010 16:31:08 -0400 Message-ID: Subject: Re: [PATCH 03/10] Use percpu stats From: Nitin Gupta Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org To: Christoph Lameter Cc: Pekka Enberg , Minchan Kim , Andrew Morton , Greg KH , Linux Driver Project , linux-mm , linux-kernel List-ID: On Mon, Aug 30, 2010 at 12:20 PM, Christoph Lameter wrote: > On Mon, 9 Aug 2010, Nitin Gupta wrote: > >> -static void zram_stat_inc(u32 *v) >> +static void zram_add_stat(struct zram *zram, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 enum zram_stats_index idx, s64= val) >> =A0{ >> - =A0 =A0 *v =3D *v + 1; >> + =A0 =A0 struct zram_stats_cpu *stats; >> + >> + =A0 =A0 preempt_disable(); >> + =A0 =A0 stats =3D __this_cpu_ptr(zram->stats); >> + =A0 =A0 u64_stats_update_begin(&stats->syncp); >> + =A0 =A0 stats->count[idx] +=3D val; >> + =A0 =A0 u64_stats_update_end(&stats->syncp); >> + =A0 =A0 preempt_enable(); > > Maybe do > > #define zram_add_stat(zram, index, val) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0this_cpu_add(zram->stats->count[index], va= l) > > 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. > > Yes, this_cpu_add() seems sufficient. I can't recall why I used u64_stats_* but if it's not required for atomic access to 64-bit then why was it added = to the mainline in the first place? Thanks, Nitin -- 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