aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2006-10-01 02:27:45 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-01 03:39:22 -0400
commit3c1fcfe229e99752c74efb945a4a3f560be04204 (patch)
tree44085d9b599e06a92426141811a6f712beac17aa /arch
parentcdc39363d33506b0e067d41fc91f89d186bdf7f7 (diff)
[PATCH] Directed yield: direct yield of spinlocks for s390.
Use the new diagnose 0x9c in the spinlock implementation for s390. It yields the remaining timeslice of the virtual cpu that tries to acquire a lock to the virtual cpu that is the current holder of the lock. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/s390/kernel/head31.S11
-rw-r--r--arch/s390/kernel/head64.S11
-rw-r--r--arch/s390/lib/spinlock.c62
3 files changed, 61 insertions, 23 deletions
diff --git a/arch/s390/kernel/head31.S b/arch/s390/kernel/head31.S
index 1fa9fa1ca740..1b952a3664e2 100644
--- a/arch/s390/kernel/head31.S
+++ b/arch/s390/kernel/head31.S
@@ -254,6 +254,16 @@ startup_continue:
254 oi 3(%r12),0x80 # set IDTE flag 254 oi 3(%r12),0x80 # set IDTE flag
255.Lchkidte: 255.Lchkidte:
256 256
257#
258# find out if the diag 0x9c is available
259#
260 mvc __LC_PGM_NEW_PSW(8),.Lpcdiag9c-.LPG1(%r13)
261 stap __LC_CPUID+4 # store cpu address
262 lh %r1,__LC_CPUID+4
263 diag %r1,0,0x9c # test diag 0x9c
264 oi 2(%r12),1 # set diag9c flag
265.Lchkdiag9c:
266
257 lpsw .Lentry-.LPG1(13) # jump to _stext in primary-space, 267 lpsw .Lentry-.LPG1(13) # jump to _stext in primary-space,
258 # virtual and never return ... 268 # virtual and never return ...
259 .align 8 269 .align 8
@@ -281,6 +291,7 @@ startup_continue:
281.Lpccsp:.long 0x00080000,0x80000000 + .Lchkcsp 291.Lpccsp:.long 0x00080000,0x80000000 + .Lchkcsp
282.Lpcmvpg:.long 0x00080000,0x80000000 + .Lchkmvpg 292.Lpcmvpg:.long 0x00080000,0x80000000 + .Lchkmvpg
283.Lpcidte:.long 0x00080000,0x80000000 + .Lchkidte 293.Lpcidte:.long 0x00080000,0x80000000 + .Lchkidte
294.Lpcdiag9c:.long 0x00080000,0x80000000 + .Lchkdiag9c
284.Lmemsize:.long memory_size 295.Lmemsize:.long memory_size
285.Lmchunk:.long memory_chunk 296.Lmchunk:.long memory_chunk
286.Lmflags:.long machine_flags 297.Lmflags:.long machine_flags
diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S
index 48998d50b00a..b30e5897cdf7 100644
--- a/arch/s390/kernel/head64.S
+++ b/arch/s390/kernel/head64.S
@@ -251,6 +251,17 @@ startup_continue:
2510: 2510:
252 252
253# 253#
254# find out if the diag 0x9c is available
255#
256 la %r1,0f-.LPG1(%r13) # set program check address
257 stg %r1,__LC_PGM_NEW_PSW+8
258 stap __LC_CPUID+4 # store cpu address
259 lh %r1,__LC_CPUID+4
260 diag %r1,0,0x9c # test diag 0x9c
261 oi 6(%r12),1 # set diag9c flag
2620:
263
264#
254# find out if we have the MVCOS instruction 265# find out if we have the MVCOS instruction
255# 266#
256 la %r1,0f-.LPG1(%r13) # set program check address 267 la %r1,0f-.LPG1(%r13) # set program check address
diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c
index b9b7958a226a..8d76403fcf89 100644
--- a/arch/s390/lib/spinlock.c
+++ b/arch/s390/lib/spinlock.c
@@ -24,57 +24,76 @@ static int __init spin_retry_setup(char *str)
24} 24}
25__setup("spin_retry=", spin_retry_setup); 25__setup("spin_retry=", spin_retry_setup);
26 26
27static inline void 27static inline void _raw_yield(void)
28_diag44(void)
29{ 28{
30#ifdef CONFIG_64BIT
31 if (MACHINE_HAS_DIAG44) 29 if (MACHINE_HAS_DIAG44)
32#endif
33 asm volatile("diag 0,0,0x44"); 30 asm volatile("diag 0,0,0x44");
34} 31}
35 32
36void 33static inline void _raw_yield_cpu(int cpu)
37_raw_spin_lock_wait(raw_spinlock_t *lp, unsigned int pc) 34{
35 if (MACHINE_HAS_DIAG9C)
36 asm volatile("diag %0,0,0x9c"
37 : : "d" (__cpu_logical_map[cpu]));
38 else
39 _raw_yield();
40}
41
42void _raw_spin_lock_wait(raw_spinlock_t *lp, unsigned int pc)
38{ 43{
39 int count = spin_retry; 44 int count = spin_retry;
45 unsigned int cpu = ~smp_processor_id();
40 46
41 while (1) { 47 while (1) {
42 if (count-- <= 0) { 48 if (count-- <= 0) {
43 _diag44(); 49 unsigned int owner = lp->owner_cpu;
50 if (owner != 0)
51 _raw_yield_cpu(~owner);
44 count = spin_retry; 52 count = spin_retry;
45 } 53 }
46 if (__raw_spin_is_locked(lp)) 54 if (__raw_spin_is_locked(lp))
47 continue; 55 continue;
48 if (_raw_compare_and_swap(&lp->lock, 0, pc) == 0) 56 if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0) {
57 lp->owner_pc = pc;
49 return; 58 return;
59 }
50 } 60 }
51} 61}
52EXPORT_SYMBOL(_raw_spin_lock_wait); 62EXPORT_SYMBOL(_raw_spin_lock_wait);
53 63
54int 64int _raw_spin_trylock_retry(raw_spinlock_t *lp, unsigned int pc)
55_raw_spin_trylock_retry(raw_spinlock_t *lp, unsigned int pc)
56{ 65{
57 int count = spin_retry; 66 unsigned int cpu = ~smp_processor_id();
67 int count;
58 68
59 while (count-- > 0) { 69 for (count = spin_retry; count > 0; count--) {
60 if (__raw_spin_is_locked(lp)) 70 if (__raw_spin_is_locked(lp))
61 continue; 71 continue;
62 if (_raw_compare_and_swap(&lp->lock, 0, pc) == 0) 72 if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0) {
73 lp->owner_pc = pc;
63 return 1; 74 return 1;
75 }
64 } 76 }
65 return 0; 77 return 0;
66} 78}
67EXPORT_SYMBOL(_raw_spin_trylock_retry); 79EXPORT_SYMBOL(_raw_spin_trylock_retry);
68 80
69void 81void _raw_spin_relax(raw_spinlock_t *lock)
70_raw_read_lock_wait(raw_rwlock_t *rw) 82{
83 unsigned int cpu = lock->owner_cpu;
84 if (cpu != 0)
85 _raw_yield_cpu(~cpu);
86}
87EXPORT_SYMBOL(_raw_spin_relax);
88
89void _raw_read_lock_wait(raw_rwlock_t *rw)
71{ 90{
72 unsigned int old; 91 unsigned int old;
73 int count = spin_retry; 92 int count = spin_retry;
74 93
75 while (1) { 94 while (1) {
76 if (count-- <= 0) { 95 if (count-- <= 0) {
77 _diag44(); 96 _raw_yield();
78 count = spin_retry; 97 count = spin_retry;
79 } 98 }
80 if (!__raw_read_can_lock(rw)) 99 if (!__raw_read_can_lock(rw))
@@ -86,8 +105,7 @@ _raw_read_lock_wait(raw_rwlock_t *rw)
86} 105}
87EXPORT_SYMBOL(_raw_read_lock_wait); 106EXPORT_SYMBOL(_raw_read_lock_wait);
88 107
89int 108int _raw_read_trylock_retry(raw_rwlock_t *rw)
90_raw_read_trylock_retry(raw_rwlock_t *rw)
91{ 109{
92 unsigned int old; 110 unsigned int old;
93 int count = spin_retry; 111 int count = spin_retry;
@@ -103,14 +121,13 @@ _raw_read_trylock_retry(raw_rwlock_t *rw)
103} 121}
104EXPORT_SYMBOL(_raw_read_trylock_retry); 122EXPORT_SYMBOL(_raw_read_trylock_retry);
105 123
106void 124void _raw_write_lock_wait(raw_rwlock_t *rw)
107_raw_write_lock_wait(raw_rwlock_t *rw)
108{ 125{
109 int count = spin_retry; 126 int count = spin_retry;
110 127
111 while (1) { 128 while (1) {
112 if (count-- <= 0) { 129 if (count-- <= 0) {
113 _diag44(); 130 _raw_yield();
114 count = spin_retry; 131 count = spin_retry;
115 } 132 }
116 if (!__raw_write_can_lock(rw)) 133 if (!__raw_write_can_lock(rw))
@@ -121,8 +138,7 @@ _raw_write_lock_wait(raw_rwlock_t *rw)
121} 138}
122EXPORT_SYMBOL(_raw_write_lock_wait); 139EXPORT_SYMBOL(_raw_write_lock_wait);
123 140
124int 141int _raw_write_trylock_retry(raw_rwlock_t *rw)
125_raw_write_trylock_retry(raw_rwlock_t *rw)
126{ 142{
127 int count = spin_retry; 143 int count = spin_retry;
128 144