[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86: replace a few do_div() uses
commit 8dc44294806c83456794ba9488b4b440aa6193c2 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Fri Feb 18 14:47:25 2022 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Fri Feb 18 14:47:25 2022 +0100 x86: replace a few do_div() uses When the macro's "return value" is not used, the macro use can be replaced by a simply division, avoiding some obfuscation. According to my observations, no change to generated code. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/arch/x86/cpu/intel.c | 3 +-- xen/arch/x86/hpet.c | 5 +---- xen/arch/x86/nmi.c | 5 ++--- xen/arch/x86/time.c | 6 ++---- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c index d7c6e2bd7d..eb5fba35ca 100644 --- a/xen/arch/x86/cpu/intel.c +++ b/xen/arch/x86/cpu/intel.c @@ -424,9 +424,8 @@ static void intel_log_freq(const struct cpuinfo_x86 *c) unsigned long long val = ecx; val *= ebx; - do_div(val, eax); printk("CPU%u: TSC: %u Hz * %u / %u = %Lu Hz\n", - smp_processor_id(), ecx, ebx, eax, val); + smp_processor_id(), ecx, ebx, eax, val / eax); } else if ( ecx | eax | ebx ) { diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c index afe104dc93..2fe8b005a5 100644 --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -105,10 +105,7 @@ custom_param("hpet", parse_hpet_param); static inline unsigned long div_sc(unsigned long ticks, unsigned long nsec, int shift) { - uint64_t tmp = ((uint64_t)ticks) << shift; - - do_div(tmp, nsec); - return (unsigned long) tmp; + return ((uint64_t)ticks << shift) / nsec; } /* diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index ab94a96c4d..c515de6336 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -292,10 +292,9 @@ static void clear_msr_range(unsigned int base, unsigned int n) static inline void write_watchdog_counter(const char *descr) { - u64 count = (u64)cpu_khz * 1000; + uint64_t count = cpu_khz * 1000ULL / nmi_hz; - do_div(count, nmi_hz); - if(descr) + if ( descr ) Dprintk("setting %s to -%#"PRIx64"\n", descr, count); wrmsrl(nmi_perfctr_msr, 0 - count); } diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 17f64a6ccd..bc41a3aa37 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -615,8 +615,7 @@ static uint64_t xen_timer_cpu_frequency(void) struct vcpu_time_info *info = &this_cpu(vcpu_info)->time; uint64_t freq; - freq = 1000000000ULL << 32; - do_div(freq, info->tsc_to_system_mul); + freq = (1000000000ULL << 32) / info->tsc_to_system_mul; if ( info->tsc_shift < 0 ) freq <<= -info->tsc_shift; else @@ -2178,8 +2177,7 @@ void __init early_time_init(void) set_time_scale(&t->tsc_scale, tmp); t->stamp.local_tsc = boot_tsc_stamp; - do_div(tmp, 1000); - cpu_khz = (unsigned long)tmp; + cpu_khz = tmp / 1000; printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000); -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |