linux-mips
[Top] [All Lists]

Re: [PATCH 1/3] MIPS: use the generic atomic64 operations for perf count

To: Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH 1/3] MIPS: use the generic atomic64 operations for perf counter support
From: David Daney <ddaney@caviumnetworks.com>
Date: Wed, 21 Apr 2010 10:45:11 -0700
Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com>, linux-mips@linux-mips.org, a.p.zijlstra@chello.nl, paulus@samba.org, mingo@elte.hu, acme@redhat.com, jamie.iles@picochip.com
In-reply-to: <20100421171915.GA29010@linux-mips.org>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1271349525.7467.420.camel@fun-lab> <4BCDD58F.7020201@caviumnetworks.com> <20100421171915.GA29010@linux-mips.org>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Thunderbird/3.0.4
On 04/21/2010 10:19 AM, Ralf Baechle wrote:
[...]

-#ifdef CONFIG_64BIT
+typedef struct {
+       long long counter;
+} atomic64_t;


How does this not conflict with the definition in linux/types.h for a 64-bit kernel?


  #define ATOMIC64_INIT(i)    { (i) }

@@ -410,14 +414,44 @@ static __inline__ int atomic_add_unless(atomic_t *v, int 
a, int u)
   * @v: pointer of type atomic64_t
   *
   */
-#define atomic64_read(v)       ((v)->counter)
+static long long __inline__ atomic64_read(const atomic64_t *v)
+{
+       unsigned long flags;
+       raw_spinlock_t *lock;
+       long long val;
+
+       if (cpu_has_64bit_gp_regs)      /* 64-bit regs imply 64-bit ld / sd  */
+               return v->counter;
+

How is this atomic for the o32 ABI? counter is now not volatile, in o32, u64 values are often split between two registers. There is nothing to guarantee that the compiler will use LD.


David Daney

<Prev in Thread] Current Thread [Next in Thread>