From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>,
Paul Mackerras <paulus@au1.ibm.com>,
Ingo Molnar <mingo@kernel.org>,
James Hogan <james.hogan@imgtec.com>,
"James E.J. Bottomley" <jejb@parisc-linux.org>,
Helge Deller <deller@gmx.de>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
"David S. Miller" <davem@davemloft.net>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC GIT PULL] softirq: Consolidation and stack overrun fix
Date: Mon, 23 Sep 2013 07:56:40 +1000 [thread overview]
Message-ID: <1379887000.24090.19.camel@pasglop> (raw)
In-Reply-To: <20130922162410.GA10649@laptop.programming.kicks-ass.net>
On Sun, 2013-09-22 at 18:24 +0200, Peter Zijlstra wrote:
> On Sun, Sep 22, 2013 at 02:41:01PM +1000, Benjamin Herrenschmidt wrote:
> > On Sun, 2013-09-22 at 14:39 +1000, Benjamin Herrenschmidt wrote:
> > > How do you do your per-cpu on x86 ?
>
> We use a segment offset. Something like:
>
> inc %gs:var;
>
> would be a per-cpu increment. The actual memory location used for the
> memop is the variable address + GS offset.
>
> And our GS offset is per cpu and points to the base of the per cpu
> segment for that cpu.
>
> > Also, do you have a half-decent way of getting to per-cpu from asm ?
>
> Yes, see above :-)
And gcc makes no stupid assumptions that this gs doesn't change ? That's
the main problem we have with using r13 for PACA.
> Assuming we repurpose r13 as per-cpu base, you could do the whole
> this_cpu_* stuff which is locally atomic -- ie. safe against IRQs and
> preemption as:
>
> loop:
> lwarx rt, var, r13
> inc rt
> stwcx rt, var, r13
> bne- loop
>
> Except, I think your ll/sc pair is actually slower than doing:
>
> local_irq_save(flags)
> var++;
> local_irq_restore(flags)
>
> Esp. with the lazy irq disable you have.
Right, for local atomics we really don't want to use reservations, they
have to go to the L2 (and flush the corresponding L1 line along the
way).
> And I'm fairly sure using them as generic per cpu accessors isn't sane,
> but I'm not sure PPC64 has other memops with implicit addition like
> that.
We have no memop with implicit addition today, so for generic counters
we do need reservation. For other per-cpus such as thread info etc...
the problem is more how quick it is to get to the per-cpu.
> As to the problem of GCC moving r13 about, some archs have some
> exceptions in the register allocator and leave some registers alone.
> IIRC MIPS has this and uses one of those (istr there's 2) for the
> per cpu base address.
Right, not sure if there's anything we can do short of getting gcc
modified and relying on that new change (which would be problematic).
I've been trying to get straight answers from gcc folks about what we
can or cannot rely upon and never got any.
r13 is actually the TLS, but we can't use it as such in the kernel as
gcc *will* assume it doesn't change (though we could use it for current
and have our per-cpu offset hanging off that, one level of indirection
is better than nothing as suppose).
The problem boils down to gcc not having a concept that a global
register variable can be volatile.
Cheers,
Ben.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2013-09-22 21:58 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-19 19:51 [RFC GIT PULL] softirq: Consolidation and stack overrun fix Frederic Weisbecker
2013-09-19 19:51 ` [PATCH 1/3] irq: Consolidate do_softirq() arch overriden implementations Frederic Weisbecker
2013-09-19 19:51 ` [PATCH 2/3] irq: Execute softirq on its own stack on irq exit Frederic Weisbecker
2013-09-19 19:51 ` [PATCH 3/3] irq: Comment on the use of inline stack for ksoftirqd Frederic Weisbecker
2013-09-20 0:02 ` [RFC GIT PULL] softirq: Consolidation and stack overrun fix Linus Torvalds
2013-09-20 1:53 ` Benjamin Herrenschmidt
2013-09-20 11:03 ` Thomas Gleixner
2013-09-20 11:11 ` Peter Zijlstra
2013-09-21 0:55 ` Benjamin Herrenschmidt
2013-09-20 16:26 ` Frederic Weisbecker
2013-09-20 17:30 ` Thomas Gleixner
2013-09-20 18:37 ` Frederic Weisbecker
2013-09-20 22:14 ` Linus Torvalds
2013-09-21 7:47 ` Ingo Molnar
2013-09-21 18:58 ` Frederic Weisbecker
2013-09-21 21:45 ` Benjamin Herrenschmidt
2013-09-21 23:27 ` Frederic Weisbecker
2013-09-22 2:01 ` H. Peter Anvin
2013-09-22 4:39 ` Benjamin Herrenschmidt
2013-09-22 4:41 ` Benjamin Herrenschmidt
2013-09-22 16:24 ` Peter Zijlstra
2013-09-22 17:47 ` H. Peter Anvin
2013-09-22 22:00 ` Benjamin Herrenschmidt
2013-09-22 21:56 ` Benjamin Herrenschmidt [this message]
2013-09-22 22:22 ` Linus Torvalds
2013-09-22 22:38 ` Benjamin Herrenschmidt
2013-09-23 4:35 ` [PATCH] powerpc/irq: Run softirqs off the top of the irq stack Benjamin Herrenschmidt
2013-09-23 7:56 ` Stephen Rothwell
2013-09-23 10:13 ` Benjamin Herrenschmidt
2013-09-23 16:47 ` Linus Torvalds
2013-09-23 20:51 ` Benjamin Herrenschmidt
2013-09-24 5:42 ` [PATCH v2] " Benjamin Herrenschmidt
2013-09-23 17:59 ` [RFC GIT PULL] softirq: Consolidation and stack overrun fix Chris Metcalf
2013-09-23 20:57 ` Benjamin Herrenschmidt
2013-09-24 19:27 ` Chris Metcalf
2013-09-24 20:58 ` Benjamin Herrenschmidt
2013-09-24 0:10 ` Benjamin Herrenschmidt
2013-09-24 1:19 ` Linus Torvalds
2013-09-24 1:52 ` Benjamin Herrenschmidt
2013-09-24 8:04 ` Peter Zijlstra
2013-09-24 8:16 ` Benjamin Herrenschmidt
2013-09-24 8:21 ` Peter Zijlstra
2013-09-24 9:31 ` Benjamin Herrenschmidt
2013-09-23 4:40 ` Benjamin Herrenschmidt
2013-09-23 5:01 ` David Miller
2013-09-24 2:44 ` Frederic Weisbecker
2013-09-24 4:42 ` Benjamin Herrenschmidt
2013-09-24 13:56 ` Frederic Weisbecker
2013-09-24 20:55 ` Benjamin Herrenschmidt
2013-09-25 8:46 ` Frederic Weisbecker
2013-09-21 0:52 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379887000.24090.19.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=deller@gmx.de \
--cc=fweisbec@gmail.com \
--cc=heiko.carstens@de.ibm.com \
--cc=hpa@zytor.com \
--cc=james.hogan@imgtec.com \
--cc=jejb@parisc-linux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulus@au1.ibm.com \
--cc=peterz@infradead.org \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).