From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH] percpu_counter : add percpu_counter_add_fast() Date: Mon, 18 Oct 2010 17:39:40 +0200 Message-ID: <1287416380.2409.13.camel@edumazet-laptop> References: <1285762729-17928-1-git-send-email-david@fromorbit.com> <1285762729-17928-17-git-send-email-david@fromorbit.com> <20100929215322.ff635d3e.akpm@linux-foundation.org> <20100930061039.GX5665@dastard> <20101016075510.GH19147@amd> <1287217748.2799.68.camel@edumazet-laptop> <20101016020744.366bd9c6.akpm@linux-foundation.org> <1287221475.2799.123.camel@edumazet-laptop> <1287238754.2799.376.camel@edumazet-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Andrew Morton , Nick Piggin , Dave Chinner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Christoph Lameter Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:59080 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932167Ab0JRPjs (ORCPT ); Mon, 18 Oct 2010 11:39:48 -0400 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Le lundi 18 octobre 2010 =C3=A0 10:24 -0500, Christoph Lameter a =C3=A9= crit : > On Sat, 16 Oct 2010, Eric Dumazet wrote: >=20 > > I based following patch against linux-2.6, I dont know if previous > > Christoph patch is in a git tree. I'll respin it eventually. >=20 > The prior patch was accepted by Andrew. >=20 > > + * - It is preempt safe, but not IRQ safe (on UP) >=20 > The IRQ safeness depends on the arch. this_cpu_add() in general only > guarantees safety against preemption. It so happens that the x86 > implementation is irq safe as well. >=20 > The IRQ safety for UP is therefore not an issue if you use this_cpu_a= dd(). >=20 Nope, on UP, we dont use a per_cpu field, just a "s64 count". struct percpu_counter { s64 count; }; > If you want to guarantee irqsafeness then use irqsafe_cpu_add() inste= ad. > It generates the same code on x86 for SMP but takes care of the UP is= sues. >=20 > > +static inline void percpu_counter_add_fast(struct percpu_counter *= fbc, long amount) > > +{ > > + this_cpu_add(*fbc->counters, amount); > > +} >=20 > What happens in case of counter overflow? >=20 Nothing special, as I stated the usuable width of such counters would b= e restricted to a long, not an s64. It should be enough to count "number of inodes, of sockets, ..." -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html