* [kvm-unit-tests PATCH v2 0/3] provide asm-generic spinlock
@ 2017-05-15 11:03 ` David Hildenbrand
0 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2017-05-15 11:03 UTC (permalink / raw)
To: kvm
Cc: Paolo Bonzini, Radim Krčmář, Thomas Huth, david,
Laurent Vivier, kvm-ppc
Let's introduce a simple generic version that should be sufficient for
our purposes.
v1 -> v2:
- use __sync_lock_test_and_set() and __sync_lock_release()
-- dropped Thomas' R-b due to the change
- move includes into #define section
David Hildenbrand (3):
lib: provide generic spinlock
ppc64: use asm-generic spinlock
x86: use asm-generic spinlock
lib/asm-generic/spinlock.h | 16 +++++++++++++++-
lib/ppc64/asm/spinlock.h | 7 +------
lib/ppc64/spinlock.c | 18 ------------------
lib/x86/asm/spinlock.h | 7 +------
lib/x86/smp.c | 16 ----------------
powerpc/Makefile.ppc64 | 1 -
6 files changed, 17 insertions(+), 48 deletions(-)
delete mode 100644 lib/ppc64/spinlock.c
--
2.9.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [kvm-unit-tests PATCH v2 0/3] provide asm-generic spinlock
@ 2017-05-15 11:03 ` David Hildenbrand
0 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2017-05-15 11:03 UTC (permalink / raw)
To: kvm
Cc: Paolo Bonzini, Radim Krčmář, Thomas Huth, david,
Laurent Vivier, kvm-ppc
Let's introduce a simple generic version that should be sufficient for
our purposes.
v1 -> v2:
- use __sync_lock_test_and_set() and __sync_lock_release()
-- dropped Thomas' R-b due to the change
- move includes into #define section
David Hildenbrand (3):
lib: provide generic spinlock
ppc64: use asm-generic spinlock
x86: use asm-generic spinlock
lib/asm-generic/spinlock.h | 16 +++++++++++++++-
lib/ppc64/asm/spinlock.h | 7 +------
lib/ppc64/spinlock.c | 18 ------------------
lib/x86/asm/spinlock.h | 7 +------
lib/x86/smp.c | 16 ----------------
powerpc/Makefile.ppc64 | 1 -
6 files changed, 17 insertions(+), 48 deletions(-)
delete mode 100644 lib/ppc64/spinlock.c
--
2.9.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [kvm-unit-tests PATCH v2 1/3] lib: provide generic spinlock
2017-05-15 11:03 ` David Hildenbrand
@ 2017-05-15 11:03 ` David Hildenbrand
-1 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2017-05-15 11:03 UTC (permalink / raw)
To: kvm
Cc: Paolo Bonzini, Radim Krčmář, Thomas Huth, david,
Laurent Vivier, kvm-ppc
Let's provide a basic lock implementation that should work on most
architectures.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
lib/asm-generic/spinlock.h | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lib/asm-generic/spinlock.h b/lib/asm-generic/spinlock.h
index 3141744..31fa510 100644
--- a/lib/asm-generic/spinlock.h
+++ b/lib/asm-generic/spinlock.h
@@ -1,4 +1,18 @@
#ifndef _ASM_GENERIC_SPINLOCK_H_
#define _ASM_GENERIC_SPINLOCK_H_
-#error need architecture specific asm/spinlock.h
+
+struct spinlock {
+ unsigned int v;
+};
+
+static inline void spin_lock(struct spinlock *lock)
+{
+ while (__sync_lock_test_and_set(&lock->v, 1));
+}
+
+static inline void spin_unlock(struct spinlock *lock)
+{
+ __sync_lock_release(&lock->v);
+}
+
#endif
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [kvm-unit-tests PATCH v2 1/3] lib: provide generic spinlock
@ 2017-05-15 11:03 ` David Hildenbrand
0 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2017-05-15 11:03 UTC (permalink / raw)
To: kvm
Cc: Paolo Bonzini, Radim Krčmář, Thomas Huth, david,
Laurent Vivier, kvm-ppc
Let's provide a basic lock implementation that should work on most
architectures.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
lib/asm-generic/spinlock.h | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lib/asm-generic/spinlock.h b/lib/asm-generic/spinlock.h
index 3141744..31fa510 100644
--- a/lib/asm-generic/spinlock.h
+++ b/lib/asm-generic/spinlock.h
@@ -1,4 +1,18 @@
#ifndef _ASM_GENERIC_SPINLOCK_H_
#define _ASM_GENERIC_SPINLOCK_H_
-#error need architecture specific asm/spinlock.h
+
+struct spinlock {
+ unsigned int v;
+};
+
+static inline void spin_lock(struct spinlock *lock)
+{
+ while (__sync_lock_test_and_set(&lock->v, 1));
+}
+
+static inline void spin_unlock(struct spinlock *lock)
+{
+ __sync_lock_release(&lock->v);
+}
+
#endif
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [kvm-unit-tests PATCH v2 2/3] ppc64: use asm-generic spinlock
2017-05-15 11:03 ` David Hildenbrand
@ 2017-05-15 11:03 ` David Hildenbrand
-1 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2017-05-15 11:03 UTC (permalink / raw)
To: kvm
Cc: Paolo Bonzini, Radim Krčmář, Thomas Huth, david,
Laurent Vivier, kvm-ppc
Since the ppc64 implementation is currently only a defunc dummy
implementation, let's replace it by the generic one.
Acked-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
lib/ppc64/asm/spinlock.h | 7 +------
lib/ppc64/spinlock.c | 18 ------------------
powerpc/Makefile.ppc64 | 1 -
3 files changed, 1 insertion(+), 25 deletions(-)
delete mode 100644 lib/ppc64/spinlock.c
diff --git a/lib/ppc64/asm/spinlock.h b/lib/ppc64/asm/spinlock.h
index 002cdb1..f59eed1 100644
--- a/lib/ppc64/asm/spinlock.h
+++ b/lib/ppc64/asm/spinlock.h
@@ -1,11 +1,6 @@
#ifndef _ASMPPC64_SPINLOCK_H_
#define _ASMPPC64_SPINLOCK_H_
-struct spinlock {
- int v;
-};
-
-extern void spin_lock(struct spinlock *lock);
-extern void spin_unlock(struct spinlock *lock);
+#include <asm-generic/spinlock.h>
#endif /* _ASMPPC64_SPINLOCK_H_ */
diff --git a/lib/ppc64/spinlock.c b/lib/ppc64/spinlock.c
deleted file mode 100644
index 1b26ee1..0000000
--- a/lib/ppc64/spinlock.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * ppc64 (dummy) spinlock implementation
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Library General Public License version 2.
- */
-
-#include <asm/spinlock.h>
-
-void spin_lock(struct spinlock *lock)
-{
- lock->v = 1;
-}
-
-void spin_unlock(struct spinlock *lock)
-{
- lock->v = 0;
-}
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
index 3da3a83..17ece66 100644
--- a/powerpc/Makefile.ppc64
+++ b/powerpc/Makefile.ppc64
@@ -15,7 +15,6 @@ endif
cstart.o = $(TEST_DIR)/cstart64.o
reloc.o = $(TEST_DIR)/reloc64.o
-cflatobjs += lib/ppc64/spinlock.o
# ppc64 specific tests
tests --
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [kvm-unit-tests PATCH v2 2/3] ppc64: use asm-generic spinlock
@ 2017-05-15 11:03 ` David Hildenbrand
0 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2017-05-15 11:03 UTC (permalink / raw)
To: kvm
Cc: Paolo Bonzini, Radim Krčmář, Thomas Huth, david,
Laurent Vivier, kvm-ppc
Since the ppc64 implementation is currently only a defunc dummy
implementation, let's replace it by the generic one.
Acked-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
lib/ppc64/asm/spinlock.h | 7 +------
lib/ppc64/spinlock.c | 18 ------------------
powerpc/Makefile.ppc64 | 1 -
3 files changed, 1 insertion(+), 25 deletions(-)
delete mode 100644 lib/ppc64/spinlock.c
diff --git a/lib/ppc64/asm/spinlock.h b/lib/ppc64/asm/spinlock.h
index 002cdb1..f59eed1 100644
--- a/lib/ppc64/asm/spinlock.h
+++ b/lib/ppc64/asm/spinlock.h
@@ -1,11 +1,6 @@
#ifndef _ASMPPC64_SPINLOCK_H_
#define _ASMPPC64_SPINLOCK_H_
-struct spinlock {
- int v;
-};
-
-extern void spin_lock(struct spinlock *lock);
-extern void spin_unlock(struct spinlock *lock);
+#include <asm-generic/spinlock.h>
#endif /* _ASMPPC64_SPINLOCK_H_ */
diff --git a/lib/ppc64/spinlock.c b/lib/ppc64/spinlock.c
deleted file mode 100644
index 1b26ee1..0000000
--- a/lib/ppc64/spinlock.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * ppc64 (dummy) spinlock implementation
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Library General Public License version 2.
- */
-
-#include <asm/spinlock.h>
-
-void spin_lock(struct spinlock *lock)
-{
- lock->v = 1;
-}
-
-void spin_unlock(struct spinlock *lock)
-{
- lock->v = 0;
-}
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
index 3da3a83..17ece66 100644
--- a/powerpc/Makefile.ppc64
+++ b/powerpc/Makefile.ppc64
@@ -15,7 +15,6 @@ endif
cstart.o = $(TEST_DIR)/cstart64.o
reloc.o = $(TEST_DIR)/reloc64.o
-cflatobjs += lib/ppc64/spinlock.o
# ppc64 specific tests
tests =
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [kvm-unit-tests PATCH v2 3/3] x86: use asm-generic spinlock
2017-05-15 11:03 ` David Hildenbrand
@ 2017-05-15 11:03 ` David Hildenbrand
-1 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2017-05-15 11:03 UTC (permalink / raw)
To: kvm
Cc: Paolo Bonzini, Radim Krčmář, Thomas Huth, david,
Laurent Vivier, kvm-ppc
Signed-off-by: David Hildenbrand <david@redhat.com>
---
lib/x86/asm/spinlock.h | 7 +------
lib/x86/smp.c | 16 ----------------
2 files changed, 1 insertion(+), 22 deletions(-)
diff --git a/lib/x86/asm/spinlock.h b/lib/x86/asm/spinlock.h
index 4b0cb33..692020c 100644
--- a/lib/x86/asm/spinlock.h
+++ b/lib/x86/asm/spinlock.h
@@ -1,11 +1,6 @@
#ifndef __ASM_SPINLOCK_H
#define __ASM_SPINLOCK_H
-struct spinlock {
- int v;
-};
-
-void spin_lock(struct spinlock *lock);
-void spin_unlock(struct spinlock *lock);
+#include <asm-generic/spinlock.h>
#endif
diff --git a/lib/x86/smp.c b/lib/x86/smp.c
index 1eb49f2..4bdbeae 100644
--- a/lib/x86/smp.c
+++ b/lib/x86/smp.c
@@ -43,22 +43,6 @@ asm (
#endif
);
-void spin_lock(struct spinlock *lock)
-{
- int v = 1;
-
- do {
- asm volatile ("xchg %1, %0" : "+m"(lock->v), "+r"(v));
- } while (v);
- asm volatile ("" : : : "memory");
-}
-
-void spin_unlock(struct spinlock *lock)
-{
- asm volatile ("" : : : "memory");
- lock->v = 0;
-}
-
int cpu_count(void)
{
return _cpu_count;
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [kvm-unit-tests PATCH v2 3/3] x86: use asm-generic spinlock
@ 2017-05-15 11:03 ` David Hildenbrand
0 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2017-05-15 11:03 UTC (permalink / raw)
To: kvm
Cc: Paolo Bonzini, Radim Krčmář, Thomas Huth, david,
Laurent Vivier, kvm-ppc
Signed-off-by: David Hildenbrand <david@redhat.com>
---
lib/x86/asm/spinlock.h | 7 +------
lib/x86/smp.c | 16 ----------------
2 files changed, 1 insertion(+), 22 deletions(-)
diff --git a/lib/x86/asm/spinlock.h b/lib/x86/asm/spinlock.h
index 4b0cb33..692020c 100644
--- a/lib/x86/asm/spinlock.h
+++ b/lib/x86/asm/spinlock.h
@@ -1,11 +1,6 @@
#ifndef __ASM_SPINLOCK_H
#define __ASM_SPINLOCK_H
-struct spinlock {
- int v;
-};
-
-void spin_lock(struct spinlock *lock);
-void spin_unlock(struct spinlock *lock);
+#include <asm-generic/spinlock.h>
#endif
diff --git a/lib/x86/smp.c b/lib/x86/smp.c
index 1eb49f2..4bdbeae 100644
--- a/lib/x86/smp.c
+++ b/lib/x86/smp.c
@@ -43,22 +43,6 @@ asm (
#endif
);
-void spin_lock(struct spinlock *lock)
-{
- int v = 1;
-
- do {
- asm volatile ("xchg %1, %0" : "+m"(lock->v), "+r"(v));
- } while (v);
- asm volatile ("" : : : "memory");
-}
-
-void spin_unlock(struct spinlock *lock)
-{
- asm volatile ("" : : : "memory");
- lock->v = 0;
-}
-
int cpu_count(void)
{
return _cpu_count;
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [kvm-unit-tests PATCH v2 0/3] provide asm-generic spinlock
2017-05-15 11:03 ` David Hildenbrand
@ 2017-05-19 16:21 ` Radim Krčmář
-1 siblings, 0 replies; 10+ messages in thread
From: Radim Krčmář @ 2017-05-19 16:21 UTC (permalink / raw)
To: David Hildenbrand
Cc: kvm, Paolo Bonzini, Thomas Huth, Laurent Vivier, kvm-ppc
2017-05-15 13:03+0200, David Hildenbrand:
> Let's introduce a simple generic version that should be sufficient for
> our purposes.
Applied, thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [kvm-unit-tests PATCH v2 0/3] provide asm-generic spinlock
@ 2017-05-19 16:21 ` Radim Krčmář
0 siblings, 0 replies; 10+ messages in thread
From: Radim Krčmář @ 2017-05-19 16:21 UTC (permalink / raw)
To: David Hildenbrand
Cc: kvm, Paolo Bonzini, Thomas Huth, Laurent Vivier, kvm-ppc
2017-05-15 13:03+0200, David Hildenbrand:
> Let's introduce a simple generic version that should be sufficient for
> our purposes.
Applied, thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-05-19 16:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-15 11:03 [kvm-unit-tests PATCH v2 0/3] provide asm-generic spinlock David Hildenbrand
2017-05-15 11:03 ` David Hildenbrand
2017-05-15 11:03 ` [kvm-unit-tests PATCH v2 1/3] lib: provide generic spinlock David Hildenbrand
2017-05-15 11:03 ` David Hildenbrand
2017-05-15 11:03 ` [kvm-unit-tests PATCH v2 2/3] ppc64: use asm-generic spinlock David Hildenbrand
2017-05-15 11:03 ` David Hildenbrand
2017-05-15 11:03 ` [kvm-unit-tests PATCH v2 3/3] x86: " David Hildenbrand
2017-05-15 11:03 ` David Hildenbrand
2017-05-19 16:21 ` [kvm-unit-tests PATCH v2 0/3] provide " Radim Krčmář
2017-05-19 16:21 ` Radim Krčmář
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.