linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Better local_t implementation needed
@ 2007-04-20 10:56 Andi Kleen
  2007-04-20 16:10 ` Christoph Lameter
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Andi Kleen @ 2007-04-20 10:56 UTC (permalink / raw)
  To: linux-arch; +Cc: Christoph Lameter


Right now local_t falls back to atomic.h on a lot of architectures:

% grep generic include/asm*/local.h
include/asm-arm/local.h:#include <asm-generic/local.h>
include/asm-arm26/local.h:#include <asm-generic/local.h>
include/asm-avr32/local.h:#include <asm-generic/local.h>
include/asm-cris/local.h:#include <asm-generic/local.h>
include/asm-frv/local.h:#include <asm-generic/local.h>
include/asm-h8300/local.h:#include <asm-generic/local.h>
include/asm-m32r/local.h:#include <asm-generic/local.h>
include/asm-m68k/local.h:#include <asm-generic/local.h>
include/asm-m68knommu/local.h:#include <asm-generic/local.h>
include/asm-powerpc/local.h:#include <asm-generic/local.h>
include/asm-s390/local.h:#include <asm-generic/local.h>
include/asm-sh/local.h:#include <asm-generic/local.h>
include/asm-sh64/local.h:#include <asm-generic/local.h>
include/asm-sparc/local.h:#include <asm-generic/local.h>
include/asm-v850/local.h:#include <asm-generic/local.h>
include/asm-xtensa/local.h:#include <asm-generic/local.h>

and asm-generic.h/local.h falls back to atomic_t

This is unfortunate because if one wants to use local_t for 
per CPU counters it will be a full atomic operation which is probably
slow at least on all architectures that support MP.
Using local_t for per cpu counters is nice because then
one can use cpu_local_add() etc. and that generates very good 
code at least on x86 and a few other architectures. That would
then allow very cheap per CPU statistics, which are useful
in a number of subsystems (like networking or MM code)

e.g. on x86 with some of the pending per cpu patches we could
in the end implement cpu_local_add as a single non atomic instruction.
This would compare very favourably to the complicated
code sequences that right now are generated for some of the
statistics counters.

There used to be a portable implementation of local.h 
that instead defines local_t as a two value array 
indexed by in_interrupt(). I'm considering to add that back.

Drawback will be larger code. 

Architectures that have cheap atomic_t can just use the atomic_t 
fallback. That should be all architectures that are not MP capable?

If you have cheap save_flags/cli/restore_flags that could be also used.

Or some other architecture specific implementation. For example x86
which has atomic on a CPU read/modify/write instructions can just use those.

I would urge you that if it's  easy to do a better local_t to implement it.

Comments?

-Andi

^ permalink raw reply	[flat|nested] 12+ messages in thread
[parent not found: <617E1C2C70743745A92448908E030B2A015F2392@scsmsx411.amr.corp.intel.com>]

end of thread, other threads:[~2007-04-21  4:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-20 10:56 Better local_t implementation needed Andi Kleen
2007-04-20 16:10 ` Christoph Lameter
2007-04-20 17:01   ` Andi Kleen
2007-04-20 17:05     ` Christoph Lameter
2007-04-20 18:31 ` Luck, Tony
2007-04-20 20:14   ` Andi Kleen
2007-04-20 20:27     ` Christoph Lameter
2007-04-20 21:25 ` Roman Zippel
2007-04-20 22:39   ` David Miller
2007-04-21  0:25     ` Christoph Lameter
2007-04-21  4:45       ` David Miller
     [not found] <617E1C2C70743745A92448908E030B2A015F2392@scsmsx411.amr.corp.intel.com>
2007-04-20 20:38 ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).