From nobody Sun Nov 16 07:44:18 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1599130749; cv=none; d=zohomail.com; s=zohoarc; b=ORRx2CTvnnnWnrT1kpNWt4aLqiGgDpF7xt9cLBmOVhfpz+tIdgqsiF+XV0JU5CsX9Jt4wGgBXFJDdiJPLbv/apWfVKclmfSQb86Y5VGatSB9Vk/dm5lVYYctiKTxHusuwrHiTnXrbjYdWIow+RrKRj8rtg/xMPWDlbPkSW3Pysg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599130749; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C3o5dOTpX0DalSmz8GcwaExRnSW/JwAdY1r1sBrQk80=; b=lHIvYOR5Rn+psEEjPEX18xgL/ub17SZVLQE3/VxQG7X8Irdo5Jc0s6++WIEGtBGeX0MMtnB+sXE5tH1pJd7fOhJYZ2lTLD2ffRPwPlybfDYsm8gRp5PD+/SRFdBNtrIEO7GJasT7FjGYO/1lnTNJo51UBCpPJButWNz4Vmo8vlc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159913074941069.48785556050325; Thu, 3 Sep 2020 03:59:09 -0700 (PDT) Received: from localhost ([::1]:47442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDmxQ-0007on-JC for importer@patchew.org; Thu, 03 Sep 2020 06:59:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDmul-0002m0-8q for qemu-devel@nongnu.org; Thu, 03 Sep 2020 06:56:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:48736) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDmui-0004W8-An for qemu-devel@nongnu.org; Thu, 03 Sep 2020 06:56:22 -0400 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4B42DB609; Thu, 3 Sep 2020 10:56:19 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Roman Bolshakov Subject: [PATCH v7 02/16] icount: rename functions to be consistent with the module name Date: Thu, 3 Sep 2020 12:56:00 +0200 Message-Id: <20200903105614.17772-3-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903105614.17772-1-cfontana@suse.de> References: <20200903105614.17772-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.15; envelope-from=cfontana@suse.de; helo=mx2.suse.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/03 00:06:01 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Alberto Garcia , Eduardo Habkost , Pavel Dovgalyuk , Marcelo Tosatti , Richard Henderson , qemu-devel@nongnu.org, Markus Armbruster , Colin Xu , Wenchao Wang , haxm-team@intel.com, Sunil Muthuswamy , Claudio Fontana Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Claudio Fontana Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- accel/tcg/cpu-exec.c | 6 +++--- docs/replay.txt | 6 +++--- include/sysemu/cpu-timers.h | 16 +++++++------- include/sysemu/replay.h | 4 ++-- replay/replay.c | 2 +- softmmu/cpu-timers.c | 6 +++--- softmmu/cpus.c | 6 +++--- softmmu/icount.c | 42 ++++++++++++++++++------------------- softmmu/vl.c | 2 +- stubs/icount.c | 16 +++++++------- target/arm/helper.c | 4 ++-- target/riscv/csr.c | 4 ++-- util/main-loop.c | 2 +- util/qemu-timer.c | 4 ++-- 14 files changed, 60 insertions(+), 60 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index ee9d22d92c..b44e92b753 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -71,7 +71,7 @@ static void align_clocks(SyncClocks *sc, CPUState *cpu) } =20 cpu_icount =3D cpu->icount_extra + cpu_neg(cpu)->icount_decr.u16.low; - sc->diff_clk +=3D cpu_icount_to_ns(sc->last_cpu_icount - cpu_icount); + sc->diff_clk +=3D icount_to_ns(sc->last_cpu_icount - cpu_icount); sc->last_cpu_icount =3D cpu_icount; =20 if (sc->diff_clk > VM_CLOCK_ADVANCE) { @@ -664,7 +664,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, Tran= slationBlock *tb, assert(icount_enabled()); #ifndef CONFIG_USER_ONLY /* Ensure global icount has gone forward */ - cpu_update_icount(cpu); + icount_update(cpu); /* Refill decrementer and continue execution. */ insns_left =3D MIN(0xffff, cpu->icount_budget); cpu_neg(cpu)->icount_decr.u16.low =3D insns_left; @@ -774,7 +774,7 @@ void dump_drift_info(void) } =20 qemu_printf("Host - Guest clock %"PRIi64" ms\n", - (cpu_get_clock() - cpu_get_icount()) / SCALE_MS); + (cpu_get_clock() - icount_get()) / SCALE_MS); if (icount_align_option) { qemu_printf("Max guest delay %"PRIi64" ms\n", -max_delay / SCALE_MS); diff --git a/docs/replay.txt b/docs/replay.txt index 70c27edb36..8952e6d852 100644 --- a/docs/replay.txt +++ b/docs/replay.txt @@ -184,11 +184,11 @@ is then incremented (which is called "warping" the vi= rtual clock) as soon as the timer fires or the CPUs need to go out of the idle state. Two functions are used for this purpose; because these actions change virtual machine state and must be deterministic, each of them creates a -checkpoint. qemu_start_warp_timer checks if the CPUs are idle and if so -starts accounting real time to virtual clock. qemu_account_warp_timer +checkpoint. icount_start_warp_timer checks if the CPUs are idle and if so +starts accounting real time to virtual clock. icount_account_warp_timer is called when the CPUs get an interrupt or when the warp timer fires, and it warps the virtual clock by the amount of real time that has passed -since qemu_start_warp_timer. +since icount_start_warp_timer. =20 Bottom halves ------------- diff --git a/include/sysemu/cpu-timers.h b/include/sysemu/cpu-timers.h index 4b621fea51..7726e005cd 100644 --- a/include/sysemu/cpu-timers.h +++ b/include/sysemu/cpu-timers.h @@ -35,30 +35,30 @@ extern int use_icount; * Update the icount with the executed instructions. Called by * cpus-tcg vCPU thread so the main-loop can see time has moved forward. */ -void cpu_update_icount(CPUState *cpu); +void icount_update(CPUState *cpu); =20 /* get raw icount value */ -int64_t cpu_get_icount_raw(void); +int64_t icount_get_raw(void); =20 /* return the virtual CPU time in ns, based on the instruction counter. */ -int64_t cpu_get_icount(void); +int64_t icount_get(void); /* * convert an instruction counter value to ns, based on the icount shift. * This shift is set as a fixed value with the icount "shift" option * (precise mode), or it is constantly approximated and corrected at * runtime in adaptive mode. */ -int64_t cpu_icount_to_ns(int64_t icount); +int64_t icount_to_ns(int64_t icount); =20 /* configure the icount options, including "shift" */ -void configure_icount(QemuOpts *opts, Error **errp); +void icount_configure(QemuOpts *opts, Error **errp); =20 /* used by tcg vcpu thread to calc icount budget */ -int64_t qemu_icount_round(int64_t count); +int64_t icount_round(int64_t count); =20 /* if the CPUs are idle, start accounting real time to virtual clock. */ -void qemu_start_warp_timer(void); -void qemu_account_warp_timer(void); +void icount_start_warp_timer(void); +void icount_account_warp_timer(void); =20 /* * CPU Ticks and Clock diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index 5471bb514d..a140d69a73 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -109,12 +109,12 @@ int64_t replay_read_clock(ReplayClockKind kind); #define REPLAY_CLOCK(clock, value) \ (replay_mode =3D=3D REPLAY_MODE_PLAY ? replay_read_clock((clock)) = \ : replay_mode =3D=3D REPLAY_MODE_RECORD = \ - ? replay_save_clock((clock), (value), cpu_get_icount_raw()) \ + ? replay_save_clock((clock), (value), icount_get_raw()) \ : (value)) #define REPLAY_CLOCK_LOCKED(clock, value) \ (replay_mode =3D=3D REPLAY_MODE_PLAY ? replay_read_clock((clock)) = \ : replay_mode =3D=3D REPLAY_MODE_RECORD = \ - ? replay_save_clock((clock), (value), cpu_get_icount_raw_locke= d()) \ + ? replay_save_clock((clock), (value), icount_get_raw_locked())= \ : (value)) =20 /* Processing data from random generators */ diff --git a/replay/replay.c b/replay/replay.c index 7e4a1ba78e..4c1457b07e 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -64,7 +64,7 @@ bool replay_next_event_is(int event) =20 uint64_t replay_get_current_icount(void) { - return cpu_get_icount_raw(); + return icount_get_raw(); } =20 int replay_get_instructions(void) diff --git a/softmmu/cpu-timers.c b/softmmu/cpu-timers.c index 6c6c56090f..7efec17fea 100644 --- a/softmmu/cpu-timers.c +++ b/softmmu/cpu-timers.c @@ -70,7 +70,7 @@ int64_t cpu_get_ticks(void) int64_t ticks; =20 if (icount_enabled()) { - return cpu_get_icount(); + return icount_get(); } =20 qemu_spin_lock(&timers_state.vm_clock_lock); @@ -160,7 +160,7 @@ static bool adjust_timers_state_needed(void *opaque) return s->icount_rt_timer !=3D NULL; } =20 -static bool shift_state_needed(void *opaque) +static bool icount_shift_state_needed(void *opaque) { return icount_enabled() =3D=3D 2; } @@ -196,7 +196,7 @@ static const VMStateDescription icount_vmstate_shift = =3D { .name =3D "timer/icount/shift", .version_id =3D 1, .minimum_version_id =3D 1, - .needed =3D shift_state_needed, + .needed =3D icount_shift_state_needed, .fields =3D (VMStateField[]) { VMSTATE_INT16(icount_time_shift, TimersState), VMSTATE_END_OF_LIST() diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 773018ef1a..54fdb2761c 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -560,7 +560,7 @@ static int64_t tcg_get_icount_limit(void) deadline =3D INT32_MAX; } =20 - return qemu_icount_round(deadline); + return icount_round(deadline); } else { return replay_get_instructions(); } @@ -615,7 +615,7 @@ static void process_icount_data(CPUState *cpu) { if (icount_enabled()) { /* Account for executed instructions */ - cpu_update_icount(cpu); + icount_update(cpu); =20 /* Reset the counters */ cpu_neg(cpu)->icount_decr.u16.low =3D 0; @@ -716,7 +716,7 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) replay_mutex_lock(); qemu_mutex_lock_iothread(); /* Account partial waits to QEMU_CLOCK_VIRTUAL. */ - qemu_account_warp_timer(); + icount_account_warp_timer(); =20 /* Run the timers here. This is much more efficient than * waking up the I/O thread and waiting for completion. diff --git a/softmmu/icount.c b/softmmu/icount.c index 4e26bf445d..40854a863e 100644 --- a/softmmu/icount.c +++ b/softmmu/icount.c @@ -73,7 +73,7 @@ static void icount_enable_adaptive(void) * originally budgeted minus the current state of the decrementing * icount counters in extra/u16.low. */ -static int64_t cpu_get_icount_executed(CPUState *cpu) +static int64_t icount_get_executed(CPUState *cpu) { return (cpu->icount_budget - (cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra)); @@ -84,9 +84,9 @@ static int64_t cpu_get_icount_executed(CPUState *cpu) * account executed instructions. This is done by the TCG vCPU * thread so the main-loop can see time has moved forward. */ -static void cpu_update_icount_locked(CPUState *cpu) +static void icount_update_locked(CPUState *cpu) { - int64_t executed =3D cpu_get_icount_executed(cpu); + int64_t executed =3D icount_get_executed(cpu); cpu->icount_budget -=3D executed; =20 atomic_set_i64(&timers_state.qemu_icount, @@ -98,16 +98,16 @@ static void cpu_update_icount_locked(CPUState *cpu) * account executed instructions. This is done by the TCG vCPU * thread so the main-loop can see time has moved forward. */ -void cpu_update_icount(CPUState *cpu) +void icount_update(CPUState *cpu) { seqlock_write_lock(&timers_state.vm_clock_seqlock, &timers_state.vm_clock_lock); - cpu_update_icount_locked(cpu); + icount_update_locked(cpu); seqlock_write_unlock(&timers_state.vm_clock_seqlock, &timers_state.vm_clock_lock); } =20 -static int64_t cpu_get_icount_raw_locked(void) +static int64_t icount_get_raw_locked(void) { CPUState *cpu =3D current_cpu; =20 @@ -117,47 +117,47 @@ static int64_t cpu_get_icount_raw_locked(void) exit(1); } /* Take into account what has run */ - cpu_update_icount_locked(cpu); + icount_update_locked(cpu); } /* The read is protected by the seqlock, but needs atomic64 to avoid U= B */ return atomic_read_i64(&timers_state.qemu_icount); } =20 -static int64_t cpu_get_icount_locked(void) +static int64_t icount_get_locked(void) { - int64_t icount =3D cpu_get_icount_raw_locked(); + int64_t icount =3D icount_get_raw_locked(); return atomic_read_i64(&timers_state.qemu_icount_bias) + - cpu_icount_to_ns(icount); + icount_to_ns(icount); } =20 -int64_t cpu_get_icount_raw(void) +int64_t icount_get_raw(void) { int64_t icount; unsigned start; =20 do { start =3D seqlock_read_begin(&timers_state.vm_clock_seqlock); - icount =3D cpu_get_icount_raw_locked(); + icount =3D icount_get_raw_locked(); } while (seqlock_read_retry(&timers_state.vm_clock_seqlock, start)); =20 return icount; } =20 /* Return the virtual CPU time, based on the instruction counter. */ -int64_t cpu_get_icount(void) +int64_t icount_get(void) { int64_t icount; unsigned start; =20 do { start =3D seqlock_read_begin(&timers_state.vm_clock_seqlock); - icount =3D cpu_get_icount_locked(); + icount =3D icount_get_locked(); } while (seqlock_read_retry(&timers_state.vm_clock_seqlock, start)); =20 return icount; } =20 -int64_t cpu_icount_to_ns(int64_t icount) +int64_t icount_to_ns(int64_t icount) { return icount << atomic_read(&timers_state.icount_time_shift); } @@ -188,7 +188,7 @@ static void icount_adjust(void) &timers_state.vm_clock_lock); cur_time =3D REPLAY_CLOCK_LOCKED(REPLAY_CLOCK_VIRTUAL_RT, cpu_get_clock_locked()); - cur_icount =3D cpu_get_icount_locked(); + cur_icount =3D icount_get_locked(); =20 delta =3D cur_icount - cur_time; /* FIXME: This is a very crude algorithm, somewhat prone to oscillatio= n. */ @@ -229,7 +229,7 @@ static void icount_adjust_vm(void *opaque) icount_adjust(); } =20 -int64_t qemu_icount_round(int64_t count) +int64_t icount_round(int64_t count) { int shift =3D atomic_read(&timers_state.icount_time_shift); return (count + (1 << shift) - 1) >> shift; @@ -266,7 +266,7 @@ static void icount_warp_rt(void) * In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too * far ahead of real time. */ - int64_t cur_icount =3D cpu_get_icount_locked(); + int64_t cur_icount =3D icount_get_locked(); int64_t delta =3D clock - cur_icount; warp_delta =3D MIN(warp_delta, delta); } @@ -291,7 +291,7 @@ static void icount_timer_cb(void *opaque) icount_warp_rt(); } =20 -void qemu_start_warp_timer(void) +void icount_start_warp_timer(void) { int64_t clock; int64_t deadline; @@ -394,7 +394,7 @@ void qemu_start_warp_timer(void) } } =20 -void qemu_account_warp_timer(void) +void icount_account_warp_timer(void) { if (!icount_enabled() || !icount_sleep) { return; @@ -417,7 +417,7 @@ void qemu_account_warp_timer(void) icount_warp_rt(); } =20 -void configure_icount(QemuOpts *opts, Error **errp) +void icount_configure(QemuOpts *opts, Error **errp) { const char *option =3D qemu_opt_get(opts, "shift"); bool sleep =3D qemu_opt_get_bool(opts, "sleep", true); diff --git a/softmmu/vl.c b/softmmu/vl.c index 13a2dfd5e0..4a3e2b5a98 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2693,7 +2693,7 @@ static void user_register_global_props(void) =20 static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) { - configure_icount(opts, errp); + icount_configure(opts, errp); return 0; } =20 diff --git a/stubs/icount.c b/stubs/icount.c index 61e28cbaf9..f13c43568b 100644 --- a/stubs/icount.c +++ b/stubs/icount.c @@ -6,40 +6,40 @@ =20 int use_icount; =20 -void cpu_update_icount(CPUState *cpu) +void icount_update(CPUState *cpu) { abort(); } -void configure_icount(QemuOpts *opts, Error **errp) +void icount_configure(QemuOpts *opts, Error **errp) { /* signal error */ error_setg(errp, "cannot configure icount, TCG support not available"); } -int64_t cpu_get_icount_raw(void) +int64_t icount_get_raw(void) { abort(); return 0; } -int64_t cpu_get_icount(void) +int64_t icount_get(void) { abort(); return 0; } -int64_t cpu_icount_to_ns(int64_t icount) +int64_t icount_to_ns(int64_t icount) { abort(); return 0; } -int64_t qemu_icount_round(int64_t count) +int64_t icount_round(int64_t count) { abort(); return 0; } -void qemu_start_warp_timer(void) +void icount_start_warp_timer(void) { abort(); } -void qemu_account_warp_timer(void) +void icount_account_warp_timer(void) { abort(); } diff --git a/target/arm/helper.c b/target/arm/helper.c index dc2b91084c..2e74614d6d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1212,12 +1212,12 @@ static bool instructions_supported(CPUARMState *env) =20 static uint64_t instructions_get_count(CPUARMState *env) { - return (uint64_t)cpu_get_icount_raw(); + return (uint64_t)icount_get_raw(); } =20 static int64_t instructions_ns_per(uint64_t icount) { - return cpu_icount_to_ns((int64_t)icount); + return icount_to_ns((int64_t)icount); } #endif =20 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 5231404a70..a6738b87ec 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -300,7 +300,7 @@ static int read_instret(CPURISCVState *env, int csrno, = target_ulong *val) { #if !defined(CONFIG_USER_ONLY) if (icount_enabled()) { - *val =3D cpu_get_icount(); + *val =3D icount_get(); } else { *val =3D cpu_get_host_ticks(); } @@ -315,7 +315,7 @@ static int read_instreth(CPURISCVState *env, int csrno,= target_ulong *val) { #if !defined(CONFIG_USER_ONLY) if (icount_enabled()) { - *val =3D cpu_get_icount() >> 32; + *val =3D icount_get() >> 32; } else { *val =3D cpu_get_host_ticks() >> 32; } diff --git a/util/main-loop.c b/util/main-loop.c index 4015d58967..744b42fc54 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -522,7 +522,7 @@ void main_loop_wait(int nonblocking) * CPU thread can infinitely wait for event after * missing the warp */ - qemu_start_warp_timer(); + icount_start_warp_timer(); } qemu_clock_run_all_timers(); } diff --git a/util/qemu-timer.c b/util/qemu-timer.c index aeb6b613b8..9a0e3bacaa 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -419,7 +419,7 @@ static void timerlist_rearm(QEMUTimerList *timer_list) { /* Interrupt execution to force deadline recalculation. */ if (icount_enabled() && timer_list->clock->type =3D=3D QEMU_CLOCK_VIRT= UAL) { - qemu_start_warp_timer(); + icount_start_warp_timer(); } timerlist_notify(timer_list); } @@ -636,7 +636,7 @@ int64_t qemu_clock_get_ns(QEMUClockType type) default: case QEMU_CLOCK_VIRTUAL: if (icount_enabled()) { - return cpu_get_icount(); + return icount_get(); } else if (qtest_enabled()) { /* for qtest_clock_warp */ return qtest_get_virtual_clock(); } else { --=20 2.26.2