x86/tsc: calibrate tsc only once
Quoted 7 lines
static unsigned long
__initget_loops_per_jiffy(void){ unsigned long lpj = tsc_khz * KHZ; do_div(lpj, HZ); return lpj; }
Just tried this with 4.19-rc2 on x86(32bit). lpj return as zero which is not expected After disassembling the code,
0xc1239a9e <+199>: imul $0x3e8,0xc12296e4,%edx 0xc1239aa8 <+209>: xor %ecx,%ecx 0xc1239aaa <+211>: test %edx,%edx 0xc1239aac <+213>: mov %eax,%ebx 0xc1239aae <+215>: je 0xc1239abd <tsc_init+230> 0xc1239ab0 <+217>: mov $0x64,%ecx 0xc1239ab5 <+222>: mov %edx,%eax 0xc1239ab7 <+224>: xor %edx,%edx 0xc1239ab9 <+226>: div %ecx 0xc1239abb <+228>: mov %eax,%ecx 0xc1239abd <+230>: mov %ebx,%eax 0xc1239abf <+232>: mov $0x64,%ebx 0xc1239ac4 <+237>: div %ebx 0xc1239ac6 <+239>: mov %ecx,%edx
imul will load the result into %edx, %edx supposed to be high 32 bit which is not zero, It should be zero in this case. both lpj and tsc_khz should be u64 to work properly.
Quoted 24 lines · Lei
Quoted 7 lines
static unsigned long
__initget_loops_per_jiffy(void){ unsigned long lpj = tsc_khz * KHZ; do_div(lpj, HZ); return lpj; }Just tried this with 4.19-rc2 on x86(32bit). lpj return as zero which is not expected
After disassembling the code,0xc1239a9e <+199>: imul $0x3e8,0xc12296e4,%edx 0xc1239aa8 <+209>: xor %ecx,%ecx 0xc1239aaa <+211>: test %edx,%edx 0xc1239aac <+213>: mov %eax,%ebx 0xc1239aae <+215>: je 0xc1239abd <tsc_init+230> 0xc1239ab0 <+217>: mov $0x64,%ecx 0xc1239ab5 <+222>: mov %edx,%eax 0xc1239ab7 <+224>: xor %edx,%edx 0xc1239ab9 <+226>: div %ecx 0xc1239abb <+228>: mov %eax,%ecx 0xc1239abd <+230>: mov %ebx,%eax 0xc1239abf <+232>: mov $0x64,%ebx 0xc1239ac4 <+237>: div %ebx 0xc1239ac6 <+239>: mov %ecx,%edx
Quoted 4 lines
imul will load the result into %edx, %edx supposed to be high 32 bit which is not zero,
It should be zero in this case. both lpj andtsc_khzshould be u64 to work properly.
Good catch! Care to send a patch?
Thanks,
tglx