Message ID | 37f94e47c91070b7606fb3ec3fe6fd2302a475a0.1575273217.git.christophe.leroy@c-s.fr (mailing list archive) |
---|---|
State | Accepted |
Commit | e33ffc956b086675551b86f5f83cf50ca47aa71c |
Headers | show |
Series | powerpc/vdso32 enhancement and optimisation | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | warning | Failed to apply on branch powerpc/merge (2e6c4d7e1c5990fa2ccca6db0868a05640ac1df1) |
snowpatch_ozlabs/apply_patch | warning | Failed to apply on branch powerpc/next (2807273f5e88ed086d7d5d838fdee71e11e5085f) |
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch linus/master (596cf45cbf6e4fa7bcb0df33e373a7d062b644b5) |
snowpatch_ozlabs/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 49 lines checked |
snowpatch_ozlabs/needsstable | success | Patch has no Fixes tags |
Hi, On 2019-12-02 07:57, Christophe Leroy wrote: > clock_getres returns hrtimer_res for all clocks but coarse ones > for which it returns KTIME_LOW_RES. > > return EINVAL for unknown clocks. > > Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> > --- > arch/powerpc/kernel/asm-offsets.c | 3 +++ > arch/powerpc/kernel/vdso32/gettimeofday.S | 19 +++++++++++-------- > 2 files changed, 14 insertions(+), 8 deletions(-) > > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c > index 0013197d89a6..90e53d432f2e 100644 > --- a/arch/powerpc/kernel/asm-offsets.c > +++ b/arch/powerpc/kernel/asm-offsets.c > @@ -413,7 +413,10 @@ int main(void) > DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC); > DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE); > DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE); > + DEFINE(CLOCK_MAX, CLOCK_TAI); > DEFINE(NSEC_PER_SEC, NSEC_PER_SEC); > + DEFINE(EINVAL, EINVAL); > + DEFINE(KTIME_LOW_RES, KTIME_LOW_RES); > > #ifdef CONFIG_BUG > DEFINE(BUG_ENTRY_SIZE, sizeof(struct bug_entry)); > diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S > index 9aafacea9c4a..20ae38f3a5a3 100644 > --- a/arch/powerpc/kernel/vdso32/gettimeofday.S > +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S > @@ -196,17 +196,20 @@ V_FUNCTION_END(__kernel_clock_gettime) > V_FUNCTION_BEGIN(__kernel_clock_getres) > .cfi_startproc > /* Check for supported clock IDs */ > - cmpwi cr0,r3,CLOCK_REALTIME > - cmpwi cr1,r3,CLOCK_MONOTONIC > - cror cr0*4+eq,cr0*4+eq,cr1*4+eq > - bne cr0,99f > + cmplwi cr0, r3, CLOCK_MAX > + cmpwi cr1, r3, CLOCK_REALTIME_COARSE > + cmpwi cr7, r3, CLOCK_MONOTONIC_COARSE > + bgt cr0, 99f > + LOAD_REG_IMMEDIATE(r5, KTIME_LOW_RES) > + beq cr1, 1f > + beq cr7, 1f > > mflr r12 > .cfi_register lr,r12 > get_datapage r3, r0 > lwz r5, CLOCK_HRTIMER_RES(r3) > mtlr r12 > - li r3,0 > +1: li r3,0 > cmpli cr0,r4,0 > crclr cr0*4+so > beqlr > @@ -215,11 +218,11 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) > blr > > /* > - * syscall fallback > + * invalid clock > */ > 99: > - li r0,__NR_clock_getres > - sc > + li r3, EINVAL > + crset so > blr > .cfi_endproc > V_FUNCTION_END(__kernel_clock_getres) Removing the syscall fallback looks wrong, and broke access to per-processes clocks. With this change a few glibc tests now fail. This can be reproduced by the simple code below: | #include <errno.h> | #include <stdio.h> | #include <string.h> | #include <sys/types.h> | #include <time.h> | #include <unistd.h> | | int main() | { | struct timespec res; | clockid_t ci; | int e; | | e = clock_getcpuclockid(getpid(), &ci); | if (e) { | printf("clock_getcpuclockid returned %d\n", e); | return e; | } | e = clock_getres (ci, &res); | printf("clock_getres returned %d\n", e); | if (e) { | printf(" errno: %d, %s\n", errno, strerror(errno)); | } | | return e; | } Without this patch or with -m64, it returns: | clock_getres returned 0 With this patch with -m32 it returns: | clock_getres returned -1 | errno: 22, Invalid argument Regards, Aurelien
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 0013197d89a6..90e53d432f2e 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -413,7 +413,10 @@ int main(void) DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC); DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE); DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE); + DEFINE(CLOCK_MAX, CLOCK_TAI); DEFINE(NSEC_PER_SEC, NSEC_PER_SEC); + DEFINE(EINVAL, EINVAL); + DEFINE(KTIME_LOW_RES, KTIME_LOW_RES); #ifdef CONFIG_BUG DEFINE(BUG_ENTRY_SIZE, sizeof(struct bug_entry)); diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S index 9aafacea9c4a..20ae38f3a5a3 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S @@ -196,17 +196,20 @@ V_FUNCTION_END(__kernel_clock_gettime) V_FUNCTION_BEGIN(__kernel_clock_getres) .cfi_startproc /* Check for supported clock IDs */ - cmpwi cr0,r3,CLOCK_REALTIME - cmpwi cr1,r3,CLOCK_MONOTONIC - cror cr0*4+eq,cr0*4+eq,cr1*4+eq - bne cr0,99f + cmplwi cr0, r3, CLOCK_MAX + cmpwi cr1, r3, CLOCK_REALTIME_COARSE + cmpwi cr7, r3, CLOCK_MONOTONIC_COARSE + bgt cr0, 99f + LOAD_REG_IMMEDIATE(r5, KTIME_LOW_RES) + beq cr1, 1f + beq cr7, 1f mflr r12 .cfi_register lr,r12 get_datapage r3, r0 lwz r5, CLOCK_HRTIMER_RES(r3) mtlr r12 - li r3,0 +1: li r3,0 cmpli cr0,r4,0 crclr cr0*4+so beqlr @@ -215,11 +218,11 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) blr /* - * syscall fallback + * invalid clock */ 99: - li r0,__NR_clock_getres - sc + li r3, EINVAL + crset so blr .cfi_endproc V_FUNCTION_END(__kernel_clock_getres)
clock_getres returns hrtimer_res for all clocks but coarse ones for which it returns KTIME_LOW_RES. return EINVAL for unknown clocks. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> --- arch/powerpc/kernel/asm-offsets.c | 3 +++ arch/powerpc/kernel/vdso32/gettimeofday.S | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-)