From owner-freebsd-arch@FreeBSD.ORG Wed Apr 3 21:45:39 2013 Return-Path: Delivered-To: arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1FCBAC9F; Wed, 3 Apr 2013 21:45:39 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) by mx1.freebsd.org (Postfix) with ESMTP id A300616C; Wed, 3 Apr 2013 21:45:38 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.6/8.14.6) with ESMTP id r33Ljapv094400; Thu, 4 Apr 2013 01:45:36 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.6/8.14.6/Submit) id r33Lja5l094399; Thu, 4 Apr 2013 01:45:36 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 4 Apr 2013 01:45:36 +0400 From: Gleb Smirnoff To: Brooks Davis Subject: Re: [CFR][CFT] counter(9): new API for faster and raceless counters Message-ID: <20130403214536.GJ76816@glebius.int.ru> References: <20130401115128.GZ76816@FreeBSD.org> <20130403190533.GA97453@lor.one-eyed-alien.net> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20130403190533.GA97453@lor.one-eyed-alien.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: arch@FreeBSD.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2013 21:45:39 -0000 On Wed, Apr 03, 2013 at 02:05:33PM -0500, Brooks Davis wrote: B> > o Tiny API for counter(9): B> > B> > counter_u64_t B> > counter_u64_alloc(int wait); B> > B> > void B> > counter_u64_free(counter_u64_t cnt); B> > B> > void B> > counter_u64_add(counter_u64_t cnt, uint64_t inc); B> > B> > uint64_t B> > counter_u64_fetch(counter_u64_t cnt); B> B> I wonder if there might be value in an interface to retrieve the per-cpu B> values individually. The use case I have in mind is interrupt counters B> on our BERI CPU. Similar to the Sibyte MIPS SoCs, our PIC always routes B> each interrupt to a specific hardware thread. I'd ideally like to be able B> to look at at hardware interrupts on a per-thread basis and avoid the B> cache trashing behavior we'd get if we allocated current interrupt B> counters to each one, but we probably want to be able to preserve B> something like the current behavior. You can just utilize directly the per-CPU UMA zones, that will come together with counter(9). So, the code will look like: critical_enter(); foo = (foo *)zpcpu_get(base); /* get private to CPU data */ do smth with foo critical_exit(); -- Totus tuus, Glebius.