Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755473Ab0HaUbL (ORCPT ); Tue, 31 Aug 2010 16:31:11 -0400 Received: from mail-yw0-f46.google.com ([209.85.213.46]:52286 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753443Ab0HaUbK convert rfc822-to-8bit (ORCPT ); Tue, 31 Aug 2010 16:31:10 -0400 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 To: Christoph Lameter Cc: Pekka Enberg , Minchan Kim , Andrew Morton , Greg KH , Linux Driver Project , linux-mm , linux-kernel Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1299 Lines: 39 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, >> + ? ? ? ? ? ? ? ? ? ? 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. > > 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/