linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: Christoph Lameter <cl@linux.com>
Cc: Tejun Heo <tj@kernel.org>,
	"akpm@linuxfoundation.org" <akpm@linuxfoundation.org>,
	Russell King <linux@arm.linux.org.uk>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	Steven Rostedt <srostedt@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [gcv v3 27/35] arm: Replace __get_cpu_var uses
Date: Wed, 4 Sep 2013 15:23:24 +0100	[thread overview]
Message-ID: <20130904142324.GD3643@mudshark.cambridge.arm.com> (raw)
In-Reply-To: <00000140e9557be9-1523eeab-c0f6-45a0-881c-9336a8a6cf85-000000@email.amazonses.com>

On Wed, Sep 04, 2013 at 03:17:09PM +0100, Christoph Lameter wrote:
> On Wed, 4 Sep 2013, Will Deacon wrote:
> > God knows! You're completely right, and we simply disable interrupts which I
> > somehow misread as taking a lock. However, is it guaranteed that mixing
> > an atomic64_* access with a this_cpu_inc_return will retain atomicity
> > between the two? E.g. if you get interrupted during an atomic64_xchg
> > operation, the interrupt handler issues this_cpu_inc_return, then on return
> > to the xchg operation it must reissue any reads that had been executed
> > prior to the interrupt. This should work on ARM/ARM64 (returning from the
> > interrupt will clear the exclusive monitor) but I don't know about other
> > architectures.
> 
> You cannot get interrupted during an atomic64_xchg operation. atomic and
> this_cpu operations are stricly serialzed since both should be behaving
> like single instructions. __this_cpu ops relax that requirement in case
> the arch code incurs significant overhead to make that happen. In cases
> where we know that preemption/interrupt disable etc takes care of things
> __this_cpu ops come into play.

Hmm, why can't you get interrupted during atomic64_xchg? On ARM, we have the
following sequence:

  static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
  {
  	u64 result;
  	unsigned long tmp;
  
  	smp_mb();
  
  	__asm__ __volatile__("@ atomic64_xchg\n"
  "1:	ldrexd	%0, %H0, [%3]\n"
  "	strexd	%1, %4, %H4, [%3]\n"
  "	teq	%1, #0\n"
  "	bne	1b"
  	: "=&r" (result), "=&r" (tmp), "+Qo" (ptr->counter)
  	: "r" (&ptr->counter), "r" (new)
  	: "cc");
  
  	smp_mb();
  
  	return result;
  }

which relies on interrupts clearing the exclusive monitor to force us back
around the loop in the inline asm. I could imagine other architectures doing
similar, but only detecting the other writer if it used the same
instructions.

Will

  reply	other threads:[~2013-09-04 14:24 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20130828193457.140443630@linux.com>
2013-08-28 19:34 ` [gcv v3 01/35] x86: Use this_cpu_inc/dec for debug registers Christoph Lameter
2013-08-28 19:34 ` [gcv v3 02/35] percpu: Make __verify_pcu_ptr handle per cpu pointers to arrays Christoph Lameter
2013-08-28 19:46 ` [gcv v3 20/35] zcache/zsmalloc: Replace __get_cpu_var uses Christoph Lameter
2013-08-28 19:46   ` Christoph Lameter
2013-08-28 19:46 ` [gcv v3 23/35] s390: " Christoph Lameter
2013-08-28 19:46   ` Christoph Lameter
2013-08-28 19:46 ` [gcv v3 34/35] metag: " Christoph Lameter
2013-08-28 19:46   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 09/35] block: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 18/35] drivers/leds: " Christoph Lameter
2013-09-03 20:40   ` Bryan Wu
2013-08-28 19:48 ` [gcv v3 03/35] Coccinelle script for __get_cpu_var conversion Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 06/35] scheduler: Replace __get_cpu_var uses Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-29  7:58   ` Peter Zijlstra
2013-08-29 10:01     ` Ingo Molnar
2013-08-29 16:57       ` Christoph Lameter
2013-08-29 17:32         ` Steven Rostedt
2013-08-29 18:15           ` Christoph Lameter
2013-08-29 18:30             ` Steven Rostedt
2013-08-29 18:30               ` Steven Rostedt
2013-09-03 14:26               ` Christoph Lameter
2013-09-03 14:45                 ` Frederic Weisbecker
2013-09-03 15:44                   ` Steven Rostedt
2013-09-03 17:09                     ` Christoph Lameter
2013-08-30  6:54             ` Ingo Molnar
2013-08-28 19:48 ` [gcv v3 04/35] net: " Christoph Lameter
2013-08-28 19:48 ` [gcv v3 22/35] mips: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 12/35] watchdog: " Christoph Lameter
2013-08-28 19:48 ` [gcv v3 32/35] arc: " Christoph Lameter
2013-08-29  6:33   ` Vineet Gupta
2013-08-29 16:43     ` Christoph Lameter
2013-09-04  7:46       ` Vineet Gupta
2013-09-04 14:14         ` Christoph Lameter
2013-09-05  5:01           ` Vineet Gupta
2013-09-05 14:19             ` Christoph Lameter
2013-09-05 14:29               ` Vineet Gupta
2013-09-05 14:29                 ` Vineet Gupta
2013-08-28 19:48 ` [gcv v3 28/35] blackfin: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 16/35] drivers/oprofile: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 25/35] powerpc: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 21:18   ` Geert Uytterhoeven
2013-08-29 16:41     ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 05/35] time: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 17/35] drivers/net/ethernet/tile: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 08/35] tracing: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-29 21:26   ` Steven Rostedt
2013-09-03 14:34     ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 07/35] mm: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 19/35] drivers: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-29 10:30   ` James Hogan
2013-08-28 19:48 ` [gcv v3 35/35] Remove __get_cpu_var and __raw_get_cpu_var macros [only in 3.13] Christoph Lameter
2013-08-28 19:48 ` [gcv v3 13/35] kernel misc: Replace __get_cpu_var uses Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 10/35] rcu: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-31 20:36   ` Paul E. McKenney
2013-09-04 14:19     ` Christoph Lameter
2013-09-04 14:19       ` Christoph Lameter
2013-09-04 19:41       ` Paul E. McKenney
2013-09-04 19:51         ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 11/35] percpu: " Christoph Lameter
2013-08-28 19:48 ` [gcv v3 14/35] drivers/char: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 29/35] avr32: " Christoph Lameter
2013-08-28 19:48 ` [gcv v3 26/35] sparc: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 21/35] x86: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 24/35] ia64: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 27/35] arm: " Christoph Lameter
2013-08-28 19:54   ` Russell King - ARM Linux
2013-08-28 20:42     ` Christoph Lameter
2013-08-28 20:42       ` Christoph Lameter
2013-08-30 10:01   ` Will Deacon
2013-09-03 14:39     ` Christoph Lameter
2013-09-04  9:33       ` Will Deacon
2013-09-04  9:33         ` Will Deacon
2013-09-04 14:17         ` Christoph Lameter
2013-09-04 14:23           ` Will Deacon [this message]
2013-09-04 14:54             ` Christoph Lameter
2013-09-04 17:46               ` Will Deacon
2013-09-04 18:09                 ` Christoph Lameter
2013-09-04 18:21                   ` Will Deacon
2013-09-04 18:21                     ` Will Deacon
2013-09-04 18:31                     ` Christoph Lameter
     [not found]                     ` <alpine.DEB.2.02.1309041324530.26497@gentwo.org>
2013-09-04 20:58                       ` Christoph Lameter
2013-09-05 13:03                         ` Will Deacon
2013-09-05 13:03                           ` Will Deacon
2013-09-05 14:24                           ` Christoph Lameter
2013-09-05 17:28                             ` Will Deacon
2013-09-05 17:52                               ` Christoph Lameter
2013-09-06 11:04                                 ` Will Deacon
2013-09-06 15:39                                   ` Christoph Lameter
2013-08-28 20:06 ` [gcv v3 33/35] parisc: " Christoph Lameter
2013-08-28 20:06   ` Christoph Lameter
2013-08-28 20:06 ` [gcv v3 15/35] drivers/cpuidle: " Christoph Lameter
2013-08-28 20:06   ` Christoph Lameter
2013-08-28 20:06 ` [gcv v3 30/35] alpha: Replace __get_cpu_var Christoph Lameter
2013-08-28 20:46 ` [gcv v3 31/35] sh: Replace __get_cpu_var uses Christoph Lameter
2013-08-28 20:46   ` Christoph Lameter

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=20130904142324.GD3643@mudshark.cambridge.arm.com \
    --to=will.deacon@arm.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=akpm@linuxfoundation.org \
    --cc=cl@linux.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=srostedt@redhat.com \
    --cc=tj@kernel.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).