Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Apr 2013 01:45:36 +0400
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        Brooks Davis <brooks@FreeBSD.org>
Cc:        arch@FreeBSD.org
Subject:   Re: [CFR][CFT] counter(9): new API for faster and raceless counters
Message-ID:  <20130403214536.GJ76816@glebius.int.ru>
In-Reply-To: <20130403190533.GA97453@lor.one-eyed-alien.net>
References:  <20130401115128.GZ76816@FreeBSD.org> <20130403190533.GA97453@lor.one-eyed-alien.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130403214536.GJ76816>