diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2008-12-31 09:11:42 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2008-12-31 09:11:49 -0500 |
commit | c742b31c03f37c5c499178f09f57381aa6c70131 (patch) | |
tree | db0e95b8299d997fcb1264126bc8efe10d0ddd51 /arch/s390/kernel/vdso64 | |
parent | 9cfb9b3c3a7361c793c031e9c3583b177ac5debd (diff) |
[PATCH] fast vdso implementation for CLOCK_THREAD_CPUTIME_ID
The extract cpu time instruction (ectg) instruction allows the user
process to get the current thread cputime without calling into the
kernel. The code that uses the instruction needs to switch to the
access registers mode to get access to the per-cpu info page that
contains the two base values that are needed to calculate the current
cputime from the CPU timer with the ectg instruction.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/vdso64')
-rw-r--r-- | arch/s390/kernel/vdso64/clock_getres.S | 5 | ||||
-rw-r--r-- | arch/s390/kernel/vdso64/clock_gettime.S | 39 |
2 files changed, 39 insertions, 5 deletions
diff --git a/arch/s390/kernel/vdso64/clock_getres.S b/arch/s390/kernel/vdso64/clock_getres.S index 488e31a3c0e..9ce8caafdb4 100644 --- a/arch/s390/kernel/vdso64/clock_getres.S +++ b/arch/s390/kernel/vdso64/clock_getres.S | |||
@@ -22,7 +22,12 @@ __kernel_clock_getres: | |||
22 | cghi %r2,CLOCK_REALTIME | 22 | cghi %r2,CLOCK_REALTIME |
23 | je 0f | 23 | je 0f |
24 | cghi %r2,CLOCK_MONOTONIC | 24 | cghi %r2,CLOCK_MONOTONIC |
25 | je 0f | ||
26 | cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */ | ||
25 | jne 2f | 27 | jne 2f |
28 | larl %r5,_vdso_data | ||
29 | icm %r0,15,__LC_ECTG_OK(%r5) | ||
30 | jz 2f | ||
26 | 0: ltgr %r3,%r3 | 31 | 0: ltgr %r3,%r3 |
27 | jz 1f /* res == NULL */ | 32 | jz 1f /* res == NULL */ |
28 | larl %r1,3f | 33 | larl %r1,3f |
diff --git a/arch/s390/kernel/vdso64/clock_gettime.S b/arch/s390/kernel/vdso64/clock_gettime.S index 738a410b7eb..79dbfee831e 100644 --- a/arch/s390/kernel/vdso64/clock_gettime.S +++ b/arch/s390/kernel/vdso64/clock_gettime.S | |||
@@ -22,8 +22,10 @@ __kernel_clock_gettime: | |||
22 | larl %r5,_vdso_data | 22 | larl %r5,_vdso_data |
23 | cghi %r2,CLOCK_REALTIME | 23 | cghi %r2,CLOCK_REALTIME |
24 | je 4f | 24 | je 4f |
25 | cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */ | ||
26 | je 9f | ||
25 | cghi %r2,CLOCK_MONOTONIC | 27 | cghi %r2,CLOCK_MONOTONIC |
26 | jne 9f | 28 | jne 12f |
27 | 29 | ||
28 | /* CLOCK_MONOTONIC */ | 30 | /* CLOCK_MONOTONIC */ |
29 | ltgr %r3,%r3 | 31 | ltgr %r3,%r3 |
@@ -42,7 +44,7 @@ __kernel_clock_gettime: | |||
42 | alg %r0,__VDSO_WTOM_SEC(%r5) | 44 | alg %r0,__VDSO_WTOM_SEC(%r5) |
43 | clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */ | 45 | clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */ |
44 | jne 0b | 46 | jne 0b |
45 | larl %r5,10f | 47 | larl %r5,13f |
46 | 1: clg %r1,0(%r5) | 48 | 1: clg %r1,0(%r5) |
47 | jl 2f | 49 | jl 2f |
48 | slg %r1,0(%r5) | 50 | slg %r1,0(%r5) |
@@ -68,7 +70,7 @@ __kernel_clock_gettime: | |||
68 | lg %r0,__VDSO_XTIME_SEC(%r5) | 70 | lg %r0,__VDSO_XTIME_SEC(%r5) |
69 | clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */ | 71 | clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */ |
70 | jne 5b | 72 | jne 5b |
71 | larl %r5,10f | 73 | larl %r5,13f |
72 | 6: clg %r1,0(%r5) | 74 | 6: clg %r1,0(%r5) |
73 | jl 7f | 75 | jl 7f |
74 | slg %r1,0(%r5) | 76 | slg %r1,0(%r5) |
@@ -79,11 +81,38 @@ __kernel_clock_gettime: | |||
79 | 8: lghi %r2,0 | 81 | 8: lghi %r2,0 |
80 | br %r14 | 82 | br %r14 |
81 | 83 | ||
84 | /* CLOCK_THREAD_CPUTIME_ID for this thread */ | ||
85 | 9: icm %r0,15,__VDSO_ECTG_OK(%r5) | ||
86 | jz 12f | ||
87 | ear %r2,%a4 | ||
88 | llilh %r4,0x0100 | ||
89 | sar %a4,%r4 | ||
90 | lghi %r4,0 | ||
91 | sacf 512 /* Magic ectg instruction */ | ||
92 | .insn ssf,0xc80100000000,__VDSO_ECTG_BASE(4),__VDSO_ECTG_USER(4),4 | ||
93 | sacf 0 | ||
94 | sar %a4,%r2 | ||
95 | algr %r1,%r0 /* r1 = cputime as TOD value */ | ||
96 | mghi %r1,1000 /* convert to nanoseconds */ | ||
97 | srlg %r1,%r1,12 /* r1 = cputime in nanosec */ | ||
98 | lgr %r4,%r1 | ||
99 | larl %r5,13f | ||
100 | srlg %r1,%r1,9 /* divide by 1000000000 */ | ||
101 | mlg %r0,8(%r5) | ||
102 | srlg %r0,%r0,11 /* r0 = tv_sec */ | ||
103 | stg %r0,0(%r3) | ||
104 | msg %r0,0(%r5) /* calculate tv_nsec */ | ||
105 | slgr %r4,%r0 /* r4 = tv_nsec */ | ||
106 | stg %r4,8(%r3) | ||
107 | lghi %r2,0 | ||
108 | br %r14 | ||
109 | |||
82 | /* Fallback to system call */ | 110 | /* Fallback to system call */ |
83 | 9: lghi %r1,__NR_clock_gettime | 111 | 12: lghi %r1,__NR_clock_gettime |
84 | svc 0 | 112 | svc 0 |
85 | br %r14 | 113 | br %r14 |
86 | 114 | ||
87 | 10: .quad 1000000000 | 115 | 13: .quad 1000000000 |
116 | 14: .quad 19342813113834067 | ||
88 | .cfi_endproc | 117 | .cfi_endproc |
89 | .size __kernel_clock_gettime,.-__kernel_clock_gettime | 118 | .size __kernel_clock_gettime,.-__kernel_clock_gettime |