From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH 16/17] fs: Convert nr_inodes to a per-cpu counter Date: Sat, 16 Oct 2010 11:31:15 +0200 Message-ID: <1287221475.2799.123.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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Nick Piggin , Dave Chinner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Andrew Morton Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:41168 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751628Ab0JPJb1 (ORCPT ); Sat, 16 Oct 2010 05:31:27 -0400 In-Reply-To: <20101016020744.366bd9c6.akpm@linux-foundation.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Le samedi 16 octobre 2010 =C3=A0 02:07 -0700, Andrew Morton a =C3=A9cri= t : > On Sat, 16 Oct 2010 10:29:08 +0200 Eric Dumazet wrote: > > Some people believe percpu_counter object is the right answer to su= ch > > distributed counters, because the loop is done on 'online' cpus ins= tead > > of 'possible' cpus. "It must be better if number of possible cpus i= s > > 4096 and only one or two cpus are online"... > >=20 > > But if we do this loop only on rare events, like > > "cat /proc/sys/fs/inode-nr", then the percpu_counter() is more > > expensive, because percpu_add() _is_ more expensive : > >=20 > > - Its a function call and lot of instructions/cycles per call, whil= e > > this_cpu_inc(nr_inodes) is a single instruction, using no register = on > > x86. >=20 > You want an inlined percpu_counter_inc() then write one! Bonus point= s > for writing this_cpu_add_return() and doing it without a > preempt_disable(). It collapses to just a few instructions. >=20 A few instructions, but no guarantee of false sharing eviction. Each time one cpu dirties the percpu_counter object, it slow down other cpus because they need to fetch the cache line again. Btw, I believe my previous patch against include/linux/percpu_counter.h was lost. Are you sure I am the right guy to work on percpu_counter infra ? If yes I can implement your inlined idea. Thanks -- 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