Skip to contentSkip to conversation

<asm/atomic.h> adjustments

PATCH Superseded Corneliu ZUZU 4 participants 22 messages Jul 13, 2016 – Jul 14, 2016

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover <asm/atomic.h> adjustments

Corneliu ZUZU (5):
asm-arm/atomic.h: fix arm32|arm64 macros duplication asm-x86/atomic.h: minor: proper atomic_inc_and_test() placement asm-arm/atomic.h: reorder macros to match x86-side asm/atomic.h: common prototyping (add xen/atomic.h)
fix: make atomic_read() param const

 xen/include/asm-arm/arm32/atomic.h |  11 ---
 xen/include/asm-arm/arm64/atomic.h |  11 ---
 xen/include/asm-arm/atomic.h       |  46 +++++++---
 xen/include/asm-x86/atomic.h       | 128 +++------------------------
 xen/include/xen/atomic.h           | 171 +++++++++++++++++++++++++++++++++++++
 5 files changed, 220 insertions(+), 147 deletions(-)
 create mode 100644 xen/include/xen/atomic.h
Signature · 7 lines
2.5.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH v2 1/5 asm-arm/atomic.h: fix arm32|arm64 macros duplication

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h to asm-arm/atomic.h.

---
 xen/include/asm-arm/arm32/atomic.h | 11 -----------
 xen/include/asm-arm/arm64/atomic.h | 11 -----------
 xen/include/asm-arm/atomic.h       | 11 +++++++++++
 3 files changed, 11 insertions(+), 22 deletions(-)
xen/include/asm-arm/arm32/atomic.h +0 -11
index 7ec712f..be08ff1 100644
@@ -149,17 +149,6 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
 
 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
 
-#define atomic_inc(v)		atomic_add(1, v)
-#define atomic_dec(v)		atomic_sub(1, v)
-
-#define atomic_inc_and_test(v)	(atomic_add_return(1, v) == 0)
-#define atomic_dec_and_test(v)	(atomic_sub_return(1, v) == 0)
-#define atomic_inc_return(v)    (atomic_add_return(1, v))
-#define atomic_dec_return(v)    (atomic_sub_return(1, v))
-#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
-
-#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
-
 #endif /* __ARCH_ARM_ARM32_ATOMIC__ */
 /*
  * Local variables:
xen/include/asm-arm/arm64/atomic.h +0 -11
index b49219e..80d07bf 100644
@@ -125,17 +125,6 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
 	return c;
 }
 
-#define atomic_inc(v)		atomic_add(1, v)
-#define atomic_dec(v)		atomic_sub(1, v)
-
-#define atomic_inc_and_test(v)	(atomic_add_return(1, v) == 0)
-#define atomic_dec_and_test(v)	(atomic_sub_return(1, v) == 0)
-#define atomic_inc_return(v)    (atomic_add_return(1, v))
-#define atomic_dec_return(v)    (atomic_sub_return(1, v))
-#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
-
-#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
-
 #endif
 /*
  * Local variables:
xen/include/asm-arm/atomic.h +11 -0
index 29ab265..41d1b6c 100644
@@ -138,6 +138,17 @@ static inline void _atomic_set(atomic_t *v, int i)
 # error "unknown ARM variant"
 #endif
 
+#define atomic_inc(v)       atomic_add(1, v)
+#define atomic_dec(v)       atomic_sub(1, v)
+
+#define atomic_inc_and_test(v)  (atomic_add_return(1, v) == 0)
+#define atomic_dec_and_test(v)  (atomic_sub_return(1, v) == 0)
+#define atomic_inc_return(v)    (atomic_add_return(1, v))
+#define atomic_dec_return(v)    (atomic_sub_return(1, v))
+#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
+
+#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
+
 #endif /* __ARCH_ARM_ATOMIC__ */
 /*
  * Local variables:
Signature · 7 lines
2.5.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 1/5
#2 lore raw

Re: [PATCH v2 1/5] asm-arm/atomic.h: fix arm32|arm64 macros duplication

Quoted 4 lines · Corneliu ZUZU

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h to asm-arm/atomic.h.

Quoted 74 lines
 xen/include/asm-arm/arm32/atomic.h | 11 -----------
 xen/include/asm-arm/arm64/atomic.h | 11 -----------
 xen/include/asm-arm/atomic.h       | 11 +++++++++++
 3 files changed, 11 insertions(+), 22 deletions(-)
xen/include/asm-arm/arm32/atomic.h +0 -11
index 7ec712f..be08ff1 100644
@@ -149,17 +149,6 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
 
 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
 
-#define atomic_inc(v)		atomic_add(1, v)
-#define atomic_dec(v)		atomic_sub(1, v)
-
-#define atomic_inc_and_test(v)	(atomic_add_return(1, v) == 0)
-#define atomic_dec_and_test(v)	(atomic_sub_return(1, v) == 0)
-#define atomic_inc_return(v)    (atomic_add_return(1, v))
-#define atomic_dec_return(v)    (atomic_sub_return(1, v))
-#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
-
-#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
-
 #endif /* __ARCH_ARM_ARM32_ATOMIC__ */
 /*
  * Local variables:
xen/include/asm-arm/arm64/atomic.h +0 -11
index b49219e..80d07bf 100644
@@ -125,17 +125,6 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
 	return c;
 }
 
-#define atomic_inc(v)		atomic_add(1, v)
-#define atomic_dec(v)		atomic_sub(1, v)
-
-#define atomic_inc_and_test(v)	(atomic_add_return(1, v) == 0)
-#define atomic_dec_and_test(v)	(atomic_sub_return(1, v) == 0)
-#define atomic_inc_return(v)    (atomic_add_return(1, v))
-#define atomic_dec_return(v)    (atomic_sub_return(1, v))
-#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
-
-#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
-
 #endif
 /*
  * Local variables:
xen/include/asm-arm/atomic.h +11 -0
index 29ab265..41d1b6c 100644
@@ -138,6 +138,17 @@ static inline void _atomic_set(atomic_t *v, int i)
 # error "unknown ARM variant"
 #endif
 
+#define atomic_inc(v)       atomic_add(1, v)
+#define atomic_dec(v)       atomic_sub(1, v)
+
+#define atomic_inc_and_test(v)  (atomic_add_return(1, v) == 0)
+#define atomic_dec_and_test(v)  (atomic_sub_return(1, v) == 0)
+#define atomic_inc_return(v)    (atomic_add_return(1, v))
+#define atomic_dec_return(v)    (atomic_sub_return(1, v))
+#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
+
+#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
+
 #endif /* __ARCH_ARM_ATOMIC__ */
 /*
  * Local variables:
Signature · 1 line
2.5.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH v2 1/5] asm-arm/atomic.h: fix arm32|arm64 macros duplication

In reply to Corneliu ZUZU

Hi Corneliu,

Quoted 2 lines · Corneliu ZUZU

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h to asm-arm/atomic.h.

asm-arm/arm*/atomic.h were a copy from Linux. I don't mind if we diverge, however the file xen/arch/arm/README.primitives needs to be update to mention the divergence with Linux.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw

Re: [PATCH v2 1/5] asm-arm/atomic.h: fix arm32|arm64 macros duplication

Hi Julien,

Quoted 10 lines · Julien Grall

Hi Corneliu,

Quoted 2 lines · Corneliu ZUZU

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h to asm-arm/atomic.h.

asm-arm/arm*/atomic.h were a copy from Linux. I don't mind if we diverge, however the file xen/arch/arm/README.primitives needs to be update to mention the divergence with Linux.

Regards,

Thanks for pointing that out, I didn't know these files were referred in such a way. What is the purpose of README.LinuxPrimitives and how must I update it to align with these patches?

Cheers,
Zuzu C.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw

Re: [PATCH v2 1/5] asm-arm/atomic.h: fix arm32|arm64 macros duplication

In reply to Julien Grall
Quoted 10 lines · Julien Grall

Hi Corneliu,

Quoted 2 lines · Corneliu ZUZU

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h to asm-arm/atomic.h.

asm-arm/arm*/atomic.h were a copy from Linux. I don't mind if we diverge, however the file xen/arch/arm/README.primitives needs to be update to mention the divergence with Linux.

Regards,

Julien,

AFAICT the README.LinuxPrimitives file specifies the Linux kernel version from which the arm{32,64}/atomic.h files were imported as well as the respective commit in the -Linux kernel- tree. I suppose that information needn't be updated. Could you be more specific on how I should modify that file?

Thanks,
Zuzu C.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH v2 1/5] asm-arm/atomic.h: fix arm32|arm64 macros duplication

Quoted 15 lines · Corneliu ZUZU
Quoted 7 lines · Julien Grall

Hi Corneliu,

Quoted 3 lines · Corneliu ZUZU

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h
to asm-arm/atomic.h.

Quoted 6 lines

asm-arm/arm*/atomic.h were a copy from Linux. I don't mind if we diverge, however the file xen/arch/arm/README.primitives needs to be update to mention the divergence with Linux.

Regards,

Quoted 7 lines

Julien,

AFAICT the README.LinuxPrimitives file specifies the Linux kernel version from which the arm{32,64}/atomic.h files were imported as well as the respective commit in the -Linux kernel- tree. I suppose that information needn't be updated.
Could you be more specific on how I should modify that file?

To specify which helpers has been taken from Linux in those files. Until now, it was quite easy to figure out that we took all atomic_* helpers.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#7 lore raw

Re: [PATCH v2 1/5] asm-arm/atomic.h: fix arm32|arm64 macros duplication

Quoted 26 lines · Julien Grall
Quoted 15 lines · Corneliu ZUZU
Quoted 7 lines · Julien Grall

Hi Corneliu,

Quoted 3 lines · Corneliu ZUZU

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h
to asm-arm/atomic.h.

Quoted 6 lines

asm-arm/arm*/atomic.h were a copy from Linux. I don't mind if we diverge, however the file xen/arch/arm/README.primitives needs to be update to mention the divergence with Linux.

Regards,

Quoted 7 lines

Julien,

AFAICT the README.LinuxPrimitives file specifies the Linux kernel version from which the arm{32,64}/atomic.h files were imported as well as the respective commit in the -Linux kernel- tree. I suppose that information needn't be updated.
Could you be more specific on how I should modify that file?

Quoted 3 lines

To specify which helpers has been taken from Linux in those files. Until now, it was quite easy to figure out that we took all atomic_* helpers.

Regards,

Ok, will look into that.

I suppose also adding:

diff -u linux/arch/arm64/include/asm/atomic.h xen/include/asm-arm/arm64/atomic.h diff -u linux/arch/arm/include/asm/atomic.h xen/include/asm-arm/arm32/atomic.h

as it's done for the others helps?

Zuzu C.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw

Re: [PATCH v2 1/5] asm-arm/atomic.h: fix arm32|arm64 macros duplication

Quoted 36 lines · Corneliu ZUZU
Quoted 26 lines · Julien Grall
Quoted 15 lines · Corneliu ZUZU
Quoted 7 lines · Julien Grall

Hi Corneliu,

Quoted 3 lines · Corneliu ZUZU

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h
to asm-arm/atomic.h.

Quoted 6 lines

asm-arm/arm*/atomic.h were a copy from Linux. I don't mind if we diverge, however the file xen/arch/arm/README.primitives needs to be update to mention the divergence with Linux.

Regards,

Quoted 7 lines

Julien,

AFAICT the README.LinuxPrimitives file specifies the Linux kernel version from which the arm{32,64}/atomic.h files were imported as well as the respective commit in the -Linux kernel- tree. I suppose that information needn't be updated.
Could you be more specific on how I should modify that file?

Quoted 5 lines

To specify which helpers has been taken from Linux in those files. Until now, it was quite easy to figure out that we took all atomic_* helpers.

Regards,

Ok, will look into that.

Quoted 8 lines

I suppose also adding:

diff -u linux/arch/arm64/include/asm/atomic.h
xen/include/asm-arm/arm64/atomic.h
diff -u linux/arch/arm/include/asm/atomic.h
xen/include/asm-arm/arm32/atomic.h

as it's done for the others helps?

No, the other files are a verbatim copy of the Linux headers. It is not the case here.

Something like:

"Only the following functions were taken from Linux:
- ...
- ...
- ...
"

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#9 lore raw

Re: [PATCH v2 1/5] asm-arm/atomic.h: fix arm32|arm64 macros duplication

Quoted 52 lines · Julien Grall
Quoted 36 lines · Corneliu ZUZU
Quoted 26 lines · Julien Grall
Quoted 15 lines · Corneliu ZUZU
Quoted 7 lines · Julien Grall

Hi Corneliu,

Quoted 3 lines · Corneliu ZUZU

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h
to asm-arm/atomic.h.

Quoted 6 lines

asm-arm/arm*/atomic.h were a copy from Linux. I don't mind if we diverge, however the file xen/arch/arm/README.primitives needs to be update to mention the divergence with Linux.

Regards,

Quoted 7 lines

Julien,

AFAICT the README.LinuxPrimitives file specifies the Linux kernel version from which the arm{32,64}/atomic.h files were imported as well as the respective commit in the -Linux kernel- tree. I suppose that information needn't be updated.
Could you be more specific on how I should modify that file?

Quoted 5 lines

To specify which helpers has been taken from Linux in those files. Until now, it was quite easy to figure out that we took all atomic_* helpers.

Regards,

Ok, will look into that.

Quoted 8 lines

I suppose also adding:

diff -u linux/arch/arm64/include/asm/atomic.h
xen/include/asm-arm/arm64/atomic.h
diff -u linux/arch/arm/include/asm/atomic.h
xen/include/asm-arm/arm32/atomic.h

as it's done for the others helps?

No, the other files are a verbatim copy of the Linux headers. It is not the case here.

Something like:

Quoted 8 lines

"Only the following functions were taken from Linux:
- ...
- ...
- ...
"

Regards,

Well, weren't they all taken from Linux?..I just turned some of the macros into inline functions and implemented some missing (no additional) ones on the X86-side.

Corneliu.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH v2 1/5] asm-arm/atomic.h: fix arm32|arm64 macros duplication

Quoted 60 lines · Corneliu ZUZU
Quoted 59 lines · Julien Grall
Quoted 36 lines · Corneliu ZUZU
Quoted 26 lines · Julien Grall
Quoted 15 lines · Corneliu ZUZU
Quoted 7 lines · Julien Grall

Hi Corneliu,

Quoted 3 lines · Corneliu ZUZU

Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h
to asm-arm/atomic.h.

Quoted 6 lines

asm-arm/arm*/atomic.h were a copy from Linux. I don't mind if we diverge, however the file xen/arch/arm/README.primitives needs to be update to mention the divergence with Linux.

Regards,

Quoted 7 lines

Julien,

AFAICT the README.LinuxPrimitives file specifies the Linux kernel version from which the arm{32,64}/atomic.h files were imported as well as the respective commit in the -Linux kernel- tree. I suppose that information needn't be updated.
Could you be more specific on how I should modify that file?

Quoted 5 lines

To specify which helpers has been taken from Linux in those files. Until now, it was quite easy to figure out that we took all atomic_* helpers.

Regards,

Ok, will look into that.

Quoted 8 lines

I suppose also adding:

diff -u linux/arch/arm64/include/asm/atomic.h
xen/include/asm-arm/arm64/atomic.h
diff -u linux/arch/arm/include/asm/atomic.h
xen/include/asm-arm/arm32/atomic.h

as it's done for the others helps?

No, the other files are a verbatim copy of the Linux headers. It is not the case here.

Something like:

"Only the following functions were taken from Linux:
- ...
- ...
- ...
"

Quoted 6 lines
Quoted 2 lines

Regards,

Well, weren't they all taken from Linux?..I just turned some of the macros into inline functions and implemented some missing (no additional) ones on the X86-side.

Yes, but you don't know why you have not taken the rest (the macros are not in atomic.h anymore...). The goal of this file is to keep track of the difference between Linux and Xen of file taken from the former.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#11 lore raw

PATCH v2 2/5 asm-x86/atomic.h: minor: proper atomic_inc_and_test() placement

In reply to Corneliu ZUZU

Place atomic_inc_and_test() implementation after atomic_inc(). Also remove unneeded empty line and add a needed one.

---
 xen/include/asm-arm/atomic.h |  1 +
 xen/include/asm-x86/atomic.h | 39 +++++++++++++++++++--------------------
 2 files changed, 20 insertions(+), 20 deletions(-)
xen/include/asm-arm/atomic.h +1 -0
index 41d1b6c..19a87a5 100644
@@ -150,6 +150,7 @@ static inline void _atomic_set(atomic_t *v, int i)
 #define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
 
 #endif /* __ARCH_ARM_ATOMIC__ */
+
 /*
  * Local variables:
  * mode: C
xen/include/asm-x86/atomic.h +19 -20
index d246b70..5f9f2dd 100644
@@ -110,7 +110,6 @@ static inline int _atomic_read(atomic_t v)
     return v.counter;
 }
 
-
 /**
  * atomic_set - set atomic variable
  * @v: pointer of type atomic_t
@@ -217,6 +216,25 @@ static inline void atomic_inc(atomic_t *v)
 }
 
 /**
+ * atomic_inc_and_test - increment and test
+ * @v: pointer of type atomic_t
+ *
+ * Atomically increments @v by 1
+ * and returns true if the result is zero, or false for all
+ * other cases.
+ */
+static inline int atomic_inc_and_test(atomic_t *v)
+{
+    unsigned char c;
+
+    asm volatile (
+        "lock; incl %0; sete %1"
+        : "=m" (*(volatile int *)&v->counter), "=qm" (c)
+        : "m" (*(volatile int *)&v->counter) : "memory" );
+    return c != 0;
+}
+
+/**
  * atomic_dec - decrement atomic variable
  * @v: pointer of type atomic_t
  * 
@@ -250,25 +268,6 @@ static inline int atomic_dec_and_test(atomic_t *v)
 }
 
 /**
- * atomic_inc_and_test - increment and test 
- * @v: pointer of type atomic_t
- * 
- * Atomically increments @v by 1
- * and returns true if the result is zero, or false for all
- * other cases.
- */ 
-static inline int atomic_inc_and_test(atomic_t *v)
-{
-    unsigned char c;
-
-    asm volatile (
-        "lock; incl %0; sete %1"
-        : "=m" (*(volatile int *)&v->counter), "=qm" (c)
-        : "m" (*(volatile int *)&v->counter) : "memory" );
-    return c != 0;
-}
-
-/**
  * atomic_add_negative - add and test if negative
  * @v: pointer of type atomic_t
  * @i: integer value to add
Signature · 7 lines
2.5.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v2 2/5
#12 lore raw

Re: [PATCH v2 2/5] asm-x86/atomic.h: minor: proper atomic_inc_and_test() placement

Quoted 4 lines · Corneliu ZUZU

Place atomic_inc_and_test() implementation after atomic_inc(). Also remove unneeded empty line and add a needed one.

For the ARM bit, even though it is a bit embarassing acking a one-liner empty line addition:

Quoted 83 lines
 xen/include/asm-arm/atomic.h |  1 +
 xen/include/asm-x86/atomic.h | 39 +++++++++++++++++++--------------------
 2 files changed, 20 insertions(+), 20 deletions(-)
xen/include/asm-arm/atomic.h +1 -0
index 41d1b6c..19a87a5 100644
@@ -150,6 +150,7 @@ static inline void _atomic_set(atomic_t *v, int i)
 #define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
 
 #endif /* __ARCH_ARM_ATOMIC__ */
+
 /*
  * Local variables:
  * mode: C
xen/include/asm-x86/atomic.h +19 -20
index d246b70..5f9f2dd 100644
@@ -110,7 +110,6 @@ static inline int _atomic_read(atomic_t v)
     return v.counter;
 }
 
-
 /**
  * atomic_set - set atomic variable
  * @v: pointer of type atomic_t
@@ -217,6 +216,25 @@ static inline void atomic_inc(atomic_t *v)
 }
 
 /**
+ * atomic_inc_and_test - increment and test
+ * @v: pointer of type atomic_t
+ *
+ * Atomically increments @v by 1
+ * and returns true if the result is zero, or false for all
+ * other cases.
+ */
+static inline int atomic_inc_and_test(atomic_t *v)
+{
+    unsigned char c;
+
+    asm volatile (
+        "lock; incl %0; sete %1"
+        : "=m" (*(volatile int *)&v->counter), "=qm" (c)
+        : "m" (*(volatile int *)&v->counter) : "memory" );
+    return c != 0;
+}
+
+/**
  * atomic_dec - decrement atomic variable
  * @v: pointer of type atomic_t
  * 
@@ -250,25 +268,6 @@ static inline int atomic_dec_and_test(atomic_t *v)
 }
 
 /**
- * atomic_inc_and_test - increment and test 
- * @v: pointer of type atomic_t
- * 
- * Atomically increments @v by 1
- * and returns true if the result is zero, or false for all
- * other cases.
- */ 
-static inline int atomic_inc_and_test(atomic_t *v)
-{
-    unsigned char c;
-
-    asm volatile (
-        "lock; incl %0; sete %1"
-        : "=m" (*(volatile int *)&v->counter), "=qm" (c)
-        : "m" (*(volatile int *)&v->counter) : "memory" );
-    return c != 0;
-}
-
-/**
  * atomic_add_negative - add and test if negative
  * @v: pointer of type atomic_t
  * @i: integer value to add
Signature · 1 line
2.5.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw

PATCH v2 3/5 asm-arm/atomic.h: reorder macros to match x86-side

In reply to Corneliu ZUZU

Reorder macro definitions to match x86-side.

---
 xen/include/asm-arm/atomic.h | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
xen/include/asm-arm/atomic.h +9 -10
index 19a87a5..e8f7340 100644
@@ -138,16 +138,15 @@ static inline void _atomic_set(atomic_t *v, int i)
 # error "unknown ARM variant"
 #endif
 
-#define atomic_inc(v)       atomic_add(1, v)
-#define atomic_dec(v)       atomic_sub(1, v)
-
-#define atomic_inc_and_test(v)  (atomic_add_return(1, v) == 0)
-#define atomic_dec_and_test(v)  (atomic_sub_return(1, v) == 0)
-#define atomic_inc_return(v)    (atomic_add_return(1, v))
-#define atomic_dec_return(v)    (atomic_sub_return(1, v))
-#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
-
-#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
+#define atomic_inc_return(v)        (atomic_add_return(1, v))
+#define atomic_dec_return(v)        (atomic_sub_return(1, v))
+
+#define atomic_sub_and_test(i, v)   (atomic_sub_return(i, v) == 0)
+#define atomic_inc(v)               atomic_add(1, v)
+#define atomic_inc_and_test(v)      (atomic_add_return(1, v) == 0)
+#define atomic_dec(v)               atomic_sub(1, v)
+#define atomic_dec_and_test(v)      (atomic_sub_return(1, v) == 0)
+#define atomic_add_negative(i,v)    (atomic_add_return(i, v) < 0)
 
 #endif /* __ARCH_ARM_ATOMIC__ */
 
Signature · 7 lines
2.5.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 3/5
#14 lore raw

Re: [PATCH v2 3/5] asm-arm/atomic.h: reorder macros to match x86-side

Quoted 3 lines · Corneliu ZUZU

Reorder macro definitions to match x86-side.

Quoted 36 lines
 xen/include/asm-arm/atomic.h | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
xen/include/asm-arm/atomic.h +9 -10
index 19a87a5..e8f7340 100644
@@ -138,16 +138,15 @@ static inline void _atomic_set(atomic_t *v, int i)
 # error "unknown ARM variant"
 #endif
 
-#define atomic_inc(v)       atomic_add(1, v)
-#define atomic_dec(v)       atomic_sub(1, v)
-
-#define atomic_inc_and_test(v)  (atomic_add_return(1, v) == 0)
-#define atomic_dec_and_test(v)  (atomic_sub_return(1, v) == 0)
-#define atomic_inc_return(v)    (atomic_add_return(1, v))
-#define atomic_dec_return(v)    (atomic_sub_return(1, v))
-#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
-
-#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
+#define atomic_inc_return(v)        (atomic_add_return(1, v))
+#define atomic_dec_return(v)        (atomic_sub_return(1, v))
+
+#define atomic_sub_and_test(i, v)   (atomic_sub_return(i, v) == 0)
+#define atomic_inc(v)               atomic_add(1, v)
+#define atomic_inc_and_test(v)      (atomic_add_return(1, v) == 0)
+#define atomic_dec(v)               atomic_sub(1, v)
+#define atomic_dec_and_test(v)      (atomic_sub_return(1, v) == 0)
+#define atomic_add_negative(i,v)    (atomic_add_return(i, v) < 0)
 
 #endif /* __ARCH_ARM_ATOMIC__ */
 
Signature · 1 line
2.5.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#15 lore raw

PATCH v2 4/5 asm/atomic.h: common prototyping (add xen/atomic.h)

In reply to Corneliu ZUZU

Create a common-side <xen/atomic.h> to establish, among others, prototypes of atomic functions called from common-code. Done to avoid introducing inconsistencies between arch-side <asm/atomic.h> headers when we make subtle changes to one of them.

Some arm-side macros had to be turned into inline functions in the process. Removed outdated comment ("NB. I've [...]").

---
Changed since v1:
* removed comments that were duplicate between asm-x86/atomic.h and xen/atomic.h
* remove outdated comment ("NB. [...]")
* add atomic_cmpxchg doc-comment
* don't use yoda condition

---
 xen/include/asm-arm/atomic.h |  45 ++++++++----
 xen/include/asm-x86/atomic.h | 103 +-------------------------
 xen/include/xen/atomic.h     | 171 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 202 insertions(+), 117 deletions(-)
 create mode 100644 xen/include/xen/atomic.h
xen/include/asm-arm/atomic.h +30 -15
index e8f7340..01af43b 100644
@@ -2,6 +2,7 @@
 #define __ARCH_ARM_ATOMIC__
 
 #include <xen/config.h>
+#include <xen/atomic.h>
 #include <xen/prefetch.h>
 #include <asm/system.h>
 
@@ -95,15 +96,6 @@ void __bad_atomic_size(void);
     default: __bad_atomic_size(); break;                                \
     }                                                                   \
 })
-    
-/*
- * NB. I've pushed the volatile qualifier into the operations. This allows
- * fast accessors such as _atomic_read() and _atomic_set() which don't give
- * the compiler a fit.
- */
-typedef struct { int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
 
 /*
  * On ARM, ordinary assignment (str instruction) doesn't clear the local
@@ -141,12 +133,35 @@ static inline void _atomic_set(atomic_t *v, int i)
 #define atomic_inc_return(v)        (atomic_add_return(1, v))
 #define atomic_dec_return(v)        (atomic_sub_return(1, v))
 
-#define atomic_sub_and_test(i, v)   (atomic_sub_return(i, v) == 0)
-#define atomic_inc(v)               atomic_add(1, v)
-#define atomic_inc_and_test(v)      (atomic_add_return(1, v) == 0)
-#define atomic_dec(v)               atomic_sub(1, v)
-#define atomic_dec_and_test(v)      (atomic_sub_return(1, v) == 0)
-#define atomic_add_negative(i,v)    (atomic_add_return(i, v) < 0)
+static inline int atomic_sub_and_test(int i, atomic_t *v)
+{
+    return atomic_sub_return(i, v) == 0;
+}
+
+static inline void atomic_inc(atomic_t *v)
+{
+    atomic_add(1, v);
+}
+
+static inline int atomic_inc_and_test(atomic_t *v)
+{
+    return atomic_add_return(1, v) == 0;
+}
+
+static inline void atomic_dec(atomic_t *v)
+{
+    atomic_sub(1, v);
+}
+
+static inline int atomic_dec_and_test(atomic_t *v)
+{
+    return atomic_sub_return(1, v) == 0;
+}
+
+static inline int atomic_add_negative(int i, atomic_t *v)
+{
+    return atomic_add_return(i, v) < 0;
+}
 
 #endif /* __ARCH_ARM_ATOMIC__ */
 
xen/include/asm-x86/atomic.h +1 -102

183 lines not on this page · raw message

xen/include/xen/atomic.h new file +171 -0

171 lines not on this page · raw message

Signature · 7 lines
2.5.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#16 lore raw

Re: [PATCH v2 4/5] asm/atomic.h: common prototyping (add xen/atomic.h)

Quoted 54 lines · Corneliu ZUZU

Create a common-side <xen/atomic.h> to establish, among others, prototypes of atomic functions called from common-code. Done to avoid introducing inconsistencies between arch-side <asm/atomic.h> headers when we make subtle changes to one of them.

Some arm-side macros had to be turned into inline functions in the process. Removed outdated comment ("NB. I've [...]").

---
Changed since v1:
* removed comments that were duplicate between asm-x86/atomic.h and xen/atomic.h
* remove outdated comment ("NB. [...]")
* add atomic_cmpxchg doc-comment
* don't use yoda condition

---
 xen/include/asm-arm/atomic.h |  45 ++++++++----
 xen/include/asm-x86/atomic.h | 103 +-------------------------
 xen/include/xen/atomic.h     | 171 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 202 insertions(+), 117 deletions(-)
 create mode 100644 xen/include/xen/atomic.h
xen/include/asm-arm/atomic.h +1 -9
index e8f7340..01af43b 100644
@@ -2,6 +2,7 @@
 #define __ARCH_ARM_ATOMIC__
 
 #include <xen/config.h>
+#include <xen/atomic.h>
 #include <xen/prefetch.h>
 #include <asm/system.h>
 
@@ -95,15 +96,6 @@ void __bad_atomic_size(void);
     default: __bad_atomic_size(); break;                                \
     }                                                                   \
 })
-    
-/*
- * NB. I've pushed the volatile qualifier into the operations. This allows
- * fast accessors such as _atomic_read() and _atomic_set() which don't give
- * the compiler a fit.
- */
-typedef struct { int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
 
 /*
  * On ARM, ordinary assignment (str instruction) doesn't clear the local

xen/include/asm-arm/atomic.h static inline void _atomic_set(atomic_t *v, int i) · line 134

Quoted 2 lines
xen/include/asm-arm/atomic.h +0 -0
@@ -141,12 +133,35 @@ static inline void _atomic_set(atomic_t *v, int i)
 #define atomic_inc_return(v)        (atomic_add_return(1, v))
 #define atomic_dec_return(v)        (atomic_sub_return(1, v))

What about atomic_inc_return and atomic_dec_return? Doesn't it make sense to do this for all of them, since we are at it? I believe there are also a couple more which are #define'd.

Quoted 27 lines
xen/include/asm-arm/atomic.h +21 -6
-#define atomic_sub_and_test(i, v)   (atomic_sub_return(i, v) == 0)
-#define atomic_inc(v)               atomic_add(1, v)
-#define atomic_inc_and_test(v)      (atomic_add_return(1, v) == 0)
-#define atomic_dec(v)               atomic_sub(1, v)
-#define atomic_dec_and_test(v)      (atomic_sub_return(1, v) == 0)
-#define atomic_add_negative(i,v)    (atomic_add_return(i, v) < 0)
+static inline int atomic_sub_and_test(int i, atomic_t *v)
+{
+    return atomic_sub_return(i, v) == 0;
+}
+
+static inline void atomic_inc(atomic_t *v)
+{
+    atomic_add(1, v);
+}
+
+static inline int atomic_inc_and_test(atomic_t *v)
+{
+    return atomic_add_return(1, v) == 0;
+}
+
+static inline void atomic_dec(atomic_t *v)
+{
+    atomic_sub(1, v);
+}
+
+static inline int atomic_dec_and_test(atomic_t *v)

xen/include/asm-arm/atomic.h static inline void _atomic_set(atomic_t *v, int i) · line 166

Quoted 10 lines
xen/include/asm-arm/atomic.h +8 -0
+{
+    return atomic_sub_return(1, v) == 0;
+}
+
+static inline int atomic_add_negative(int i, atomic_t *v)
+{
+    return atomic_add_return(i, v) < 0;
+}
 
 #endif /* __ARCH_ARM_ATOMIC__ */

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#17 lore raw

Re: [PATCH v2 4/5] asm/atomic.h: common prototyping (add xen/atomic.h)

Quoted 52 lines · Stefano Stabellini
Quoted 51 lines · Corneliu ZUZU

Create a common-side <xen/atomic.h> to establish, among others, prototypes of atomic functions called from common-code. Done to avoid introducing inconsistencies between arch-side <asm/atomic.h> headers when we make subtle changes to one of them.

Some arm-side macros had to be turned into inline functions in the process. Removed outdated comment ("NB. I've [...]").

---
Changed since v1:
* removed comments that were duplicate between asm-x86/atomic.h and xen/atomic.h
* remove outdated comment ("NB. [...]")
* add atomic_cmpxchg doc-comment
* don't use yoda condition

---
  xen/include/asm-arm/atomic.h |  45 ++++++++----
  xen/include/asm-x86/atomic.h | 103 +-------------------------
  xen/include/xen/atomic.h     | 171 +++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 202 insertions(+), 117 deletions(-)

create mode 100644 xen/include/xen/atomic.h

xen/include/asm-arm/atomic.h +1 -9
index e8f7340..01af43b 100644
@@ -2,6 +2,7 @@
  #define __ARCH_ARM_ATOMIC__
 
  #include <xen/config.h>
+#include <xen/atomic.h>
  #include <xen/prefetch.h>
  #include <asm/system.h>
 
@@ -95,15 +96,6 @@ void __bad_atomic_size(void);
      default: __bad_atomic_size(); break;                                \
      }                                                                   \
  })
-
-/*
- * NB. I've pushed the volatile qualifier into the operations. This allows
- * fast accessors such as _atomic_read() and _atomic_set() which don't give
- * the compiler a fit.
- */
-typedef struct { int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
 
Quoted 8 lines

xen/include/asm-arm/atomic.h static inline void _atomic_set(atomic_t *v, int i) · line 134

Quoted 5 lines
xen/include/asm-arm/atomic.h +0 -0
  /*
   * On ARM, ordinary assignment (str instruction) doesn't clear the local
@@ -141,12 +133,35 @@ static inline void _atomic_set(atomic_t *v, int i)
  #define atomic_inc_return(v)        (atomic_add_return(1, v))
  #define atomic_dec_return(v)        (atomic_sub_return(1, v))

What about atomic_inc_return and atomic_dec_return? Doesn't it make sense to do this for all of them, since we are at it? I believe there are also a couple more which are #define'd.

Those don't seem to be implemented for X86 and neither are they referred from common code (probably because they really aren't defined for X86).

Quoted 36 lines
Quoted 36 lines
xen/include/asm-arm/atomic.h +29 -6
-#define atomic_sub_and_test(i, v)   (atomic_sub_return(i, v) == 0)
-#define atomic_inc(v)               atomic_add(1, v)
-#define atomic_inc_and_test(v)      (atomic_add_return(1, v) == 0)
-#define atomic_dec(v)               atomic_sub(1, v)
-#define atomic_dec_and_test(v)      (atomic_sub_return(1, v) == 0)
-#define atomic_add_negative(i,v)    (atomic_add_return(i, v) < 0)
+static inline int atomic_sub_and_test(int i, atomic_t *v)
+{
+    return atomic_sub_return(i, v) == 0;
+}
+
+static inline void atomic_inc(atomic_t *v)
+{
+    atomic_add(1, v);
+}
+
+static inline int atomic_inc_and_test(atomic_t *v)
+{
+    return atomic_add_return(1, v) == 0;
+}
+
+static inline void atomic_dec(atomic_t *v)
+{
+    atomic_sub(1, v);
+}
+
+static inline int atomic_dec_and_test(atomic_t *v)
+{
+    return atomic_sub_return(1, v) == 0;
+}
+
+static inline int atomic_add_negative(int i, atomic_t *v)
+{
+    return atomic_add_return(i, v) < 0;
+}
 
Quoted 1 line

xen/include/asm-arm/atomic.h static inline void _atomic_set(atomic_t *v, int i) · line 166

Quoted 1 line
xen/include/asm-arm/atomic.h +0 -0
  #endif /* __ARCH_ARM_ATOMIC__ */

Thanks,
Zuzu C.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#18 lore raw

Re: [PATCH v2 4/5] asm/atomic.h: common prototyping (add xen/atomic.h)

Quoted 70 lines · Corneliu ZUZU
Quoted 60 lines · Stefano Stabellini
Quoted 59 lines · Corneliu ZUZU

Create a common-side <xen/atomic.h> to establish, among others, prototypes of
atomic functions called from common-code. Done to avoid introducing inconsistencies between arch-side <asm/atomic.h> headers when we make subtle
changes to one of them.

Some arm-side macros had to be turned into inline functions in the process.
Removed outdated comment ("NB. I've [...]").

---
Changed since v1:
* removed comments that were duplicate between asm-x86/atomic.h and xen/atomic.h
* remove outdated comment ("NB. [...]")
* add atomic_cmpxchg doc-comment
* don't use yoda condition

---
  xen/include/asm-arm/atomic.h |  45 ++++++++----
  xen/include/asm-x86/atomic.h | 103 +-------------------------
  xen/include/xen/atomic.h     | 171
+++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 202 insertions(+), 117 deletions(-)

create mode 100644 xen/include/xen/atomic.h

xen/include/asm-arm/atomic.h +1 -0
index e8f7340..01af43b 100644
@@ -2,6 +2,7 @@
  #define __ARCH_ARM_ATOMIC__
    #include <xen/config.h>
+#include <xen/atomic.h>
  #include <xen/prefetch.h>
  #include <asm/system.h>
  @@ -95,15 +96,6 @@ void __bad_atomic_size(void);
      default: __bad_atomic_size();

break; \

} \
})

xen/include/asm-arm/atomic.h +0 -3
-
-/*
- * NB. I've pushed the volatile qualifier into the operations. This

allows
- * fast accessors such as _atomic_read() and _atomic_set() which don't give
- * the compiler a fit.
- */

xen/include/asm-arm/atomic.h +0 -3
-typedef struct { int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
    /*
   * On ARM, ordinary assignment (str instruction) doesn't clear the
Quoted 8 lines

xen/include/asm-arm/atomic.h static inline void _atomic_set(atomic_t *v, · line 135

Quoted 5 lines

local

xen/include/asm-arm/atomic.h +0 -0
@@ -141,12 +133,35 @@ static inline void _atomic_set(atomic_t *v,
 int i)
  #define atomic_inc_return(v)        (atomic_add_return(1, v))
  #define atomic_dec_return(v)        (atomic_sub_return(1, v))

What about atomic_inc_return and atomic_dec_return? Doesn't it make sense to do this for all of them, since we are at it? I believe there are also a couple more which are #define'd.

Quoted 3 lines

Those don't seem to be implemented for X86 and neither are they referred from common code (probably because they really aren't defined for X86).

Apologies - this is definitely turning into the rats nest I warned you it might.

As far as I am concerned, I only think it is important to have the static inline prototypes for the versions which are actually common between architectures. Those are the ones we don't want to break accidentally.

However, for the helpers which are not common, having them consistently static inline would be a distinct improvement over mixed inline/defines. (static inline functions are superior to macros in many ways.)

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#19 lore raw

Re: [PATCH v2 4/5] asm/atomic.h: common prototyping (add xen/atomic.h)

Quoted 81 lines · Andrew Cooper
Quoted 69 lines · Corneliu ZUZU
Quoted 60 lines · Stefano Stabellini
Quoted 59 lines · Corneliu ZUZU

Create a common-side <xen/atomic.h> to establish, among others, prototypes of
atomic functions called from common-code. Done to avoid introducing inconsistencies between arch-side <asm/atomic.h> headers when we make subtle
changes to one of them.

Some arm-side macros had to be turned into inline functions in the process.
Removed outdated comment ("NB. I've [...]").

---
Changed since v1:
* removed comments that were duplicate between asm-x86/atomic.h and xen/atomic.h
* remove outdated comment ("NB. [...]")
* add atomic_cmpxchg doc-comment
* don't use yoda condition

---
   xen/include/asm-arm/atomic.h |  45 ++++++++----
   xen/include/asm-x86/atomic.h | 103 +-------------------------
   xen/include/xen/atomic.h     | 171
+++++++++++++++++++++++++++++++++++++++++++
   3 files changed, 202 insertions(+), 117 deletions(-)

create mode 100644 xen/include/xen/atomic.h

xen/include/asm-arm/atomic.h +1 -0
index e8f7340..01af43b 100644
@@ -2,6 +2,7 @@
   #define __ARCH_ARM_ATOMIC__
     #include <xen/config.h>
+#include <xen/atomic.h>
   #include <xen/prefetch.h>
   #include <asm/system.h>
   @@ -95,15 +96,6 @@ void __bad_atomic_size(void);
       default: __bad_atomic_size();

break; \

}                                                                   \
   })
xen/include/asm-arm/atomic.h +0 -3
-
-/*
- * NB. I've pushed the volatile qualifier into the operations. This

allows
- * fast accessors such as _atomic_read() and _atomic_set() which don't give
- * the compiler a fit.
- */

xen/include/asm-arm/atomic.h +0 -3
-typedef struct { int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
     /*
    * On ARM, ordinary assignment (str instruction) doesn't clear the
Quoted 8 lines

xen/include/asm-arm/atomic.h static inline void _atomic_set(atomic_t *v, · line 135

Quoted 5 lines

local

xen/include/asm-arm/atomic.h +0 -0
@@ -141,12 +133,35 @@ static inline void _atomic_set(atomic_t *v,
 int i)
   #define atomic_inc_return(v)        (atomic_add_return(1, v))
   #define atomic_dec_return(v)        (atomic_sub_return(1, v))

What about atomic_inc_return and atomic_dec_return? Doesn't it make sense to do this for all of them, since we are at it? I believe there are also a couple more which are #define'd.

Quoted 3 lines

Those don't seem to be implemented for X86 and neither are they referred from common code (probably because they really aren't defined for X86).

Apologies - this is definitely turning into the rats nest I warned you it might.

As far as I am concerned, I only think it is important to have the static inline prototypes for the versions which are actually common between architectures. Those are the ones we don't want to break accidentally.

Quoted 7 lines

However, for the helpers which are not common, having them consistently static inline would be a distinct improvement over mixed inline/defines. (static inline functions are superior to macros in many ways.)

~Andrew

Absolutely no problem! The rats nest you imagined before this series was a different one :P . This really doesn't seem like it would require much effort. What I could also try to do is to actually implement them on X86 as well. Would that be preferable?
I think the complete functions that are missing there are: atomic_sub_return, atomic_{inc,dec}_return, atomic_xchg, __atomic_add_unless. Please confirm this list.

As for how I'd implement them:

    atomic_sub_return() - would "return arch_fetch_and_add(&v->counter, 

-i) - i;" - similarly to what atomic_add_return() does - do?

atomic_{inc,dec}_return() - would "return
atomic_{add,sub}_return(1, v)" respectively as on ARM do?

atomic_xchg() - since xchg() is also available on X86, would
"return xchg(&((v)->counter), new);" as on ARM do?
Stefano, Julien: note that I'd have to
implement this for ARM64, so, since xchg is -also- available on ARM64, would the above implementation also do in that case?

__atomic_add_unless() - again, everything this depends on in the
ARM64 version is already available on X86 too; would it also be advised to rename it to atomic_add_unless()?
Why the built-in leading
underscores '__'? Is this function used anywhere?

Thanks,
Zuzu C.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#20 lore raw

PATCH v2 5/5 fix: make atomic_read() param const

In reply to Corneliu ZUZU

This wouldn't let me make a param of a function that used atomic_read() const.

---
Changed since v1: <nothing>

---
 xen/include/asm-arm/atomic.h | 2 +-
 xen/include/asm-x86/atomic.h | 2 +-
 xen/include/xen/atomic.h     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
xen/include/asm-arm/atomic.h +1 -1
index 01af43b..25a33cb 100644
@@ -102,7 +102,7 @@ void __bad_atomic_size(void);
  * strex/ldrex monitor on some implementations. The reason we can use it for
  * atomic_set() is the clrex or dummy strex done on every exception return.
  */
-static inline int atomic_read(atomic_t *v)
+static inline int atomic_read(const atomic_t *v)
 {
     return *(volatile int *)&v->counter;
 }
xen/include/asm-x86/atomic.h +1 -1
index 3e99b03..1729e29 100644
@@ -80,7 +80,7 @@ void __bad_atomic_size(void);
     }                                                     \
 })
 
-static inline int atomic_read(atomic_t *v)
+static inline int atomic_read(const atomic_t *v)
 {
     return read_atomic(&v->counter);
 }
xen/include/xen/atomic.h +1 -1
index 3517bc9..d97f91d 100644
@@ -32,7 +32,7 @@ typedef struct { int counter; } atomic_t;
  *
  * Atomically reads the value of @v.
  */
-static inline int atomic_read(atomic_t *v);
+static inline int atomic_read(const atomic_t *v);
 
 /**
  * _atomic_read - read atomic variable non-atomically
Signature · 7 lines
2.5.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 5/5
#21 lore raw

Re: [PATCH v2 5/5] fix: make atomic_read() param const

Quoted 4 lines · Corneliu ZUZU

This wouldn't let me make a param of a function that used atomic_read() const.

Quoted 50 lines

---
Changed since v1: <nothing>

---
 xen/include/asm-arm/atomic.h | 2 +-
 xen/include/asm-x86/atomic.h | 2 +-
 xen/include/xen/atomic.h     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
xen/include/asm-arm/atomic.h +1 -1
index 01af43b..25a33cb 100644
@@ -102,7 +102,7 @@ void __bad_atomic_size(void);
  * strex/ldrex monitor on some implementations. The reason we can use it for
  * atomic_set() is the clrex or dummy strex done on every exception return.
  */
-static inline int atomic_read(atomic_t *v)
+static inline int atomic_read(const atomic_t *v)
 {
     return *(volatile int *)&v->counter;
 }
xen/include/asm-x86/atomic.h +1 -1
index 3e99b03..1729e29 100644
@@ -80,7 +80,7 @@ void __bad_atomic_size(void);
     }                                                     \
 })
 
-static inline int atomic_read(atomic_t *v)
+static inline int atomic_read(const atomic_t *v)
 {
     return read_atomic(&v->counter);
 }
xen/include/xen/atomic.h +1 -1
index 3517bc9..d97f91d 100644
@@ -32,7 +32,7 @@ typedef struct { int counter; } atomic_t;
  *
  * Atomically reads the value of @v.
  */
-static inline int atomic_read(atomic_t *v);
+static inline int atomic_read(const atomic_t *v);
 
 /**
  * _atomic_read - read atomic variable non-atomically
Signature · 1 line
2.5.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel