Some more 64bit function eradication.

. Replace 64bit funcions with operators in arch_clock.c
  . Replace 64bit funcions with operators in proc.c
  . Replace 64bit funcions with operators in vbox.c
  . Replace 64bit funcions with operators in driver.c
  . Eradicates is_zero64, make_zero64, neg64

Change-Id: Ie4e1242a73534f114725271b2e2365b2004cb7b9
This commit is contained in:
Lukasz Hryniuk
2013-08-07 12:17:09 +02:00
committed by Ben Gras
parent 7c62cdaaa7
commit 06154a34a4
9 changed files with 59 additions and 66 deletions

View File

@@ -52,8 +52,8 @@ void cycles_accounting_init(void)
{
read_tsc_64(get_cpu_var_ptr(cpu, tsc_ctr_switch));
make_zero64(get_cpu_var(cpu, cpu_last_tsc));
make_zero64(get_cpu_var(cpu, cpu_last_idle));
get_cpu_var(cpu, cpu_last_tsc) = 0;
get_cpu_var(cpu, cpu_last_idle) = 0;
}
void context_stop(struct proc * p)

View File

@@ -119,11 +119,11 @@ static void estimate_cpu_freq(void)
/* remove the probe */
rm_irq_handler(&calib_cpu);
tsc_delta = sub64(tsc1, tsc0);
tsc_delta = tsc1 - tsc0;
cpu_freq = mul64(div64u64(tsc_delta, PROBE_TICKS - 1), make64(system_hz, 0));
cpu_freq = (tsc_delta / (PROBE_TICKS - 1)) * system_hz;
cpu_set_freq(cpuid, cpu_freq);
cpu_info[cpuid].freq = div64u(cpu_freq, 1000000);
cpu_info[cpuid].freq = (unsigned long)(cpu_freq / 1000000);
BOOT_VERBOSE(cpu_print_freq(cpuid));
}
@@ -133,10 +133,9 @@ int init_local_timer(unsigned freq)
/* if we know the address, lapic is enabled and we should use it */
if (lapic_addr) {
unsigned cpu = cpuid;
tsc_per_ms[cpu] = div64u(cpu_get_freq(cpu), 1000);
lapic_set_timer_one_shot(1000000/system_hz);
} else
{
tsc_per_ms[cpu] = (unsigned long)(cpu_get_freq(cpu) / 1000);
lapic_set_timer_one_shot(1000000 / system_hz);
} else {
BOOT_VERBOSE(printf("Initiating legacy i8253 timer\n"));
#else
{
@@ -144,7 +143,7 @@ int init_local_timer(unsigned freq)
init_8253A_timer(freq);
estimate_cpu_freq();
/* always only 1 cpu in the system */
tsc_per_ms[0] = div64u(cpu_get_freq(0), 1000);
tsc_per_ms[0] = (unsigned long)(cpu_get_freq(0) / 1000);
}
return 0;
@@ -199,8 +198,8 @@ void cycles_accounting_init(void)
read_tsc_64(get_cpu_var_ptr(cpu, tsc_ctr_switch));
make_zero64(get_cpu_var(cpu, cpu_last_tsc));
make_zero64(get_cpu_var(cpu, cpu_last_idle));
get_cpu_var(cpu, cpu_last_tsc) = 0;
get_cpu_var(cpu, cpu_last_idle) = 0;
}
void context_stop(struct proc * p)
@@ -223,9 +222,9 @@ void context_stop(struct proc * p)
u64_t tmp;
read_tsc_64(&tsc);
tmp = sub64(tsc, *__tsc_ctr_switch);
kernel_ticks[cpu] = add64(kernel_ticks[cpu], tmp);
p->p_cycles = add64(p->p_cycles, tmp);
tmp = tsc - *__tsc_ctr_switch;
kernel_ticks[cpu] = kernel_ticks[cpu] + tmp;
p->p_cycles = p->p_cycles + tmp;
must_bkl_unlock = 1;
} else {
u64_t bkl_tsc;
@@ -239,11 +238,11 @@ void context_stop(struct proc * p)
read_tsc_64(&tsc);
bkl_ticks[cpu] = add64(bkl_ticks[cpu], sub64(tsc, bkl_tsc));
bkl_ticks[cpu] = bkl_ticks[cpu] + tsc - bkl_tsc;
bkl_tries[cpu]++;
bkl_succ[cpu] += !(!(succ == 0));
p->p_cycles = add64(p->p_cycles, sub64(tsc, *__tsc_ctr_switch));
p->p_cycles = p->p_cycles + tsc - *__tsc_ctr_switch;
#ifdef CONFIG_SMP
/*
@@ -261,20 +260,20 @@ void context_stop(struct proc * p)
}
#else
read_tsc_64(&tsc);
p->p_cycles = add64(p->p_cycles, sub64(tsc, *__tsc_ctr_switch));
p->p_cycles = p->p_cycles + tsc - *__tsc_ctr_switch;
#endif
tsc_delta = sub64(tsc, *__tsc_ctr_switch);
tsc_delta = tsc - *__tsc_ctr_switch;
if(kbill_ipc) {
if (kbill_ipc) {
kbill_ipc->p_kipc_cycles =
add64(kbill_ipc->p_kipc_cycles, tsc_delta);
kbill_ipc->p_kipc_cycles + tsc_delta;
kbill_ipc = NULL;
}
if(kbill_kcall) {
if (kbill_kcall) {
kbill_kcall->p_kcall_cycles =
add64(kbill_kcall->p_kcall_cycles, tsc_delta);
kbill_kcall->p_kcall_cycles + tsc_delta;
kbill_kcall = NULL;
}
@@ -285,15 +284,15 @@ void context_stop(struct proc * p)
*/
if (p->p_endpoint >= 0) {
#if DEBUG_RACE
make_zero64(p->p_cpu_time_left);
p->p_cpu_time_left = 0;
#else
/* if (tsc_delta < p->p_cpu_time_left) in 64bit */
if (ex64hi(tsc_delta) < ex64hi(p->p_cpu_time_left) ||
(ex64hi(tsc_delta) == ex64hi(p->p_cpu_time_left) &&
ex64lo(tsc_delta) < ex64lo(p->p_cpu_time_left)))
p->p_cpu_time_left = sub64(p->p_cpu_time_left, tsc_delta);
p->p_cpu_time_left = p->p_cpu_time_left - tsc_delta;
else {
make_zero64(p->p_cpu_time_left);
p->p_cpu_time_left = 0;
}
#endif
}
@@ -329,12 +328,12 @@ void context_stop_idle(void)
u64_t ms_2_cpu_time(unsigned ms)
{
return mul64u(tsc_per_ms[cpuid], ms);
return (u64_t)tsc_per_ms[cpuid] * ms;
}
unsigned cpu_time_2_ms(u64_t cpu_time)
{
return div64u(cpu_time, tsc_per_ms[cpuid]);
return (unsigned long)(cpu_time / tsc_per_ms[cpuid]);
}
short cpu_load(void)
@@ -357,13 +356,13 @@ short cpu_load(void)
current_idle = &idle->p_cycles; /* ptr to idle proc */
/* calculate load since last cpu_load invocation */
if (!is_zero64(*last_tsc)) {
tsc_delta = sub64(current_tsc, *last_tsc);
idle_delta = sub64(*current_idle, *last_idle);
if (*last_tsc) {
tsc_delta = current_tsc - *last_tsc;
idle_delta = *current_idle - *last_idle;
busy = sub64(tsc_delta, idle_delta);
busy = mul64(busy, make64(100, 0));
load = ex64lo(div64(busy, tsc_delta));
busy = tsc_delta - idle_delta;
busy = busy * 100;
load = ex64lo(busy / tsc_delta);
if (load > 100)
load = 100;

View File

@@ -197,8 +197,7 @@ static void amd_watchdog_init(const unsigned cpu)
val = 1 << 20 | 1 << 17 | 1 << 16 | 0x76;
ia32_msr_write(AMD_MSR_EVENT_SEL0, 0, val);
cpuf = cpu_get_freq(cpu);
neg64(cpuf);
cpuf = -cpu_get_freq(cpu);
watchdog->resetval = watchdog->watchdog_resetval = cpuf;
ia32_msr_write(AMD_MSR_EVENT_CTR0,
@@ -224,9 +223,8 @@ static int amd_watchdog_profile_init(const unsigned freq)
/* FIXME works only if all CPUs have the same freq */
cpuf = cpu_get_freq(cpuid);
cpuf = div64u64(cpuf, freq);
cpuf = -div64u64(cpuf, freq);
neg64(cpuf);
watchdog->profile_resetval = cpuf;
return OK;