linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* power and percpu: Could we move the paca into the percpu area?
@ 2014-06-11 19:37 Christoph Lameter
  2014-06-11 20:22 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Lameter @ 2014-06-11 19:37 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Tejun Heo


Looking at arch/powerpc/include/asm/percpu.h I see that the per cpu offset
comes from a local_paca field and local_paca is in r13. That means that
for all percpu operations we first have to determine the address through a
memory access.

Would it be possible to put the paca at the beginning of the percpu data
area and then have r31 point to the percpu area?

power has these nice instructions that fetch from an offset relative to a
base register which could be used throughout for percpu operations in the
kernel (similar to x86 segment registers).

With that we may also be able to use the atomic ops for fast percpu access
so that we can avoid the irq enable/disable sequence that is now required
for percpu atomics. Would result in fast and reliable percpu
counters for powerpc.

I.e. powerpc atomic inc
static __inline__ void atomic_inc(atomic_t *v)
{
        int t;

        __asm__ __volatile__(
"1:     lwarx   %0,0,%2         # atomic_inc\n\
        addic   %0,%0,1\n"
        PPC405_ERR77(0,%2)
"       stwcx.  %0,0,%2 \n\
        bne-    1b"
        : "=&r" (t), "+m" (v->counter)
        : "r" (&v->counter)
        : "cc", "xer");
}

Could be used as a template to get:

static __inline__ void raw_cpu_inc_4(__percpu void *v)
{
        int t;

        __asm__ __volatile__(
"1:     lwarx   %0,r31,%2         # percpu_inc\n\
        addic   %0,%0,1\n"
        PPC405_ERR77(0,%2)
"       stwcx.  %0,r31,%2 \n\
        bne-    1b"
        : "=&r" (t), "+m" (v)
        : "r" (&v->counter)
        : "cc", "xer");
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-13 14:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-11 19:37 power and percpu: Could we move the paca into the percpu area? Christoph Lameter
2014-06-11 20:22 ` Benjamin Herrenschmidt
2014-06-11 21:03   ` Gabriel Paubert
2014-06-12 12:26     ` Segher Boessenkool
2014-06-12 21:57       ` Benjamin Herrenschmidt
2014-06-12 22:15         ` Segher Boessenkool
2014-06-13 11:55       ` Gabriel Paubert
2014-06-13 14:16         ` Segher Boessenkool

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).