Re: [Qemu-block] [PATCH v2] Replaced get_tick_per_sec() by NANOSECONDS_PER_SECOND
On Mon, Mar 21, 2016 at 12:01 AM, <rutu.shah...@gmail.com> wrote: Hi, Some lines seem to have been skipped some how. This patch replaces get_ticks_per_sec() calls to NANOSECONDS_PER_SECOND. Also, as there are no callers, get_ticks_per_sec() has been removed. Replacement imporves readability and understandability of code. > Example given by Paolo Bonzini, > > timer_mod(fdctrl->result_timer, > qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (get_ticks_per_sec() / 50)); > > NANOSECONDS_PER_SECOND makes it obvious that the timer will expire in 1/50th > of a second. > > --- > audio/audio.c | 3 +-- > audio/noaudio.c | 8 > audio/spiceaudio.c| 4 ++-- > audio/wavaudio.c | 2 +- > backends/baum.c | 2 +- > block/qed.c | 2 +- > cpus.c| 6 +++--- > hw/acpi/core.c| 4 ++-- > hw/arm/omap1.c| 17 + > hw/arm/spitz.c| 2 +- > hw/arm/stellaris.c| 2 +- > hw/arm/strongarm.c| 2 +- > hw/audio/adlib.c | 2 +- > hw/audio/sb16.c | 4 ++-- > hw/block/fdc.c| 4 ++-- > hw/block/pflash_cfi02.c | 8 > hw/bt/hci-csr.c | 4 ++-- > hw/char/cadence_uart.c| 4 ++-- > hw/char/serial.c | 10 ++ > hw/display/vga.c | 6 +++--- > hw/dma/rc4030.c | 2 +- > hw/ide/core.c | 4 ++-- > hw/input/hid.c| 2 +- > hw/input/tsc2005.c| 3 ++- > hw/input/tsc210x.c| 3 ++- > hw/intc/i8259.c | 2 +- > hw/misc/arm_sysctl.c | 3 ++- > hw/misc/macio/cuda.c | 16 > hw/misc/macio/macio.c | 2 +- > hw/net/dp8393x.c | 2 +- > hw/ppc/ppc.c | 21 - > hw/ppc/ppc405_uc.c| 4 ++-- > hw/ppc/ppc_booke.c| 2 +- > hw/sd/sdhci-internal.h| 2 +- > hw/sparc64/sun4u.c| 4 ++-- > hw/timer/i8254.c | 4 ++-- > hw/timer/i8254_common.c | 6 +++--- > hw/timer/mc146818rtc.c| 14 -- > hw/timer/omap_gptimer.c | 2 +- > hw/timer/omap_synctimer.c | 3 ++- > hw/timer/pl031.c | 10 +- > hw/timer/pxa2xx_timer.c | 18 ++ > hw/usb/hcd-ehci.c | 5 +++-- > hw/usb/hcd-musb.c | 2 +- > hw/usb/hcd-ohci.c | 10 +- > hw/usb/hcd-uhci.c | 6 +++--- > hw/usb/tusb6010.c | 6 +++--- > hw/watchdog/wdt_diag288.c | 2 +- > hw/watchdog/wdt_ib700.c | 2 +- > include/hw/acpi/acpi.h| 2 +- > include/qemu/timer.h | 9 ++--- > monitor.c | 4 ++-- > target-ppc/kvm.c | 4 ++-- > 53 files changed, 143 insertions(+), 134 deletions(-) > --- > Thanks, > Rutuja Shah
Re: [Qemu-block] [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah...@gmail.com>
Hi, Sorry for the inconvenience caused due to the format of my patch. Due to a typo mail id was wrong, adding blauwir...@gmail.com On Mar 11, 2016 1:00 AM, <rutu.shah...@gmail.com> wrote: > From: Rutuja Shah <rutu.shah...@gmail.com> > > --- > audio/audio.c | 2 +- > audio/noaudio.c | 4 ++-- > audio/spiceaudio.c| 2 +- > audio/wavaudio.c | 2 +- > backends/baum.c | 2 +- > block/qed.c | 2 +- > cpus.c| 6 +++--- > hw/acpi/core.c| 4 ++-- > hw/arm/omap1.c| 14 +++--- > hw/arm/spitz.c| 2 +- > hw/arm/stellaris.c| 2 +- > hw/arm/strongarm.c| 2 +- > hw/audio/adlib.c | 2 +- > hw/audio/sb16.c | 4 ++-- > hw/block/fdc.c| 2 +- > hw/block/pflash_cfi02.c | 4 ++-- > hw/bt/hci-csr.c | 4 ++-- > hw/char/cadence_uart.c| 4 ++-- > hw/char/serial.c | 6 +++--- > hw/display/vga.c | 6 +++--- > hw/dma/rc4030.c | 2 +- > hw/ide/core.c | 2 +- > hw/input/hid.c| 2 +- > hw/input/tsc2005.c| 2 +- > hw/input/tsc210x.c| 2 +- > hw/intc/i8259.c | 2 +- > hw/misc/arm_sysctl.c | 2 +- > hw/misc/macio/cuda.c | 16 > hw/misc/macio/macio.c | 2 +- > hw/net/dp8393x.c | 2 +- > hw/ppc/ppc.c | 18 +- > hw/ppc/ppc405_uc.c| 4 ++-- > hw/ppc/ppc_booke.c| 2 +- > hw/sd/sdhci-internal.h| 2 +- > hw/sparc64/sun4u.c| 4 ++-- > hw/timer/i8254.c | 4 ++-- > hw/timer/i8254_common.c | 6 +++--- > hw/timer/mc146818rtc.c| 6 +++--- > hw/timer/omap_gptimer.c | 2 +- > hw/timer/omap_synctimer.c | 2 +- > hw/timer/pl031.c | 10 +- > hw/timer/pxa2xx_timer.c | 14 +++--- > hw/usb/hcd-ehci.c | 4 ++-- > hw/usb/hcd-musb.c | 2 +- > hw/usb/hcd-ohci.c | 10 +- > hw/usb/hcd-uhci.c | 6 +++--- > hw/usb/tusb6010.c | 4 ++-- > hw/watchdog/wdt_diag288.c | 2 +- > hw/watchdog/wdt_ib700.c | 2 +- > include/hw/acpi/acpi.h| 2 +- > include/qemu/timer.h | 9 ++--- > monitor.c | 4 ++-- > target-ppc/kvm.c | 4 ++-- > 53 files changed, 114 insertions(+), 119 deletions(-) > > diff --git a/audio/audio.c b/audio/audio.c > index e841532..8c2c495 100644 > --- a/audio/audio.c > +++ b/audio/audio.c > @@ -1870,7 +1870,7 @@ static void audio_init (void) > conf.period.ticks = 1; > } else { > conf.period.ticks = > -muldiv64 (1, get_ticks_per_sec (), conf.period.hertz); > +muldiv64 (1, NANOSECONDS_PER_SECOND, conf.period.hertz); > } > > e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, > s); > diff --git a/audio/noaudio.c b/audio/noaudio.c > index 09588b9..931aa03 100644 > --- a/audio/noaudio.c > +++ b/audio/noaudio.c > @@ -49,7 +49,7 @@ static int no_run_out (HWVoiceOut *hw, int live) > > now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); > ticks = now - no->old_ticks; > -bytes = muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec > ()); > +bytes = muldiv64 (ticks, hw->info.bytes_per_second, > NANOSECONDS_PER_SECOND); > bytes = audio_MIN (bytes, INT_MAX); > samples = bytes >> hw->info.shift; > > @@ -106,7 +106,7 @@ static int no_run_in (HWVoiceIn *hw) > int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); > int64_t ticks = now - no->old_ticks; > int64_t bytes = > -muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec > ()); > +muldiv64 (ticks, hw->info.bytes_per_second, > NANOSECONDS_PER_SECOND); > > no->old_ticks = now; > bytes = audio_MIN (bytes, INT_MAX); > diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c > index 297fd41..a098057 100644 > --- a/audio/spiceaudio.c > +++ b/audio/spiceaudio.c > @@ -104,7 +104,7 @@ static int rate_get_samples (struct audio_pcm_info > *info, SpiceRateCtl *rate) > > now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); > ticks = now - rate->start_ticks; > -bytes = muldiv64 (ticks, info->bytes_per_second, get_ticks_per_sec > ()); > +bytes = muldiv64 (ticks, info->bytes_per_second, > NANOSECONDS_PER_SECOND); > samples = (bytes - rate->bytes_sent) >> info->shift; > if (samples < 0 || samples > 65536) { > error_report("Resetting rate control (%" PRId64 " samples)", > samp
Re: [Qemu-block] [Qemu-devel] [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah...@gmail.com>
Thanks Eric. I will keep these points in mind while sending patches. Regards Rutuja Shah On Fri, Mar 11, 2016 at 2:40 AM, Eric Blake <ebl...@redhat.com> wrote: > On 03/10/2016 12:30 PM, rutu.shah...@gmail.com wrote: >> From: Rutuja Shah <rutu.shah...@gmail.com> >> > > Your commit message body was botched, cramming everything into the > subject line. Be sure you have a one-line summary (preferably shorter > than 60 characters), then a blank line, before the rest of your > description and S-o-b. Also, it's good to say "why" in the commit body, > not just "what". Something like: > > maint: Drop unused get_ticks_per_sec() > > Replace the use of get_ticks_per_sec() with NANOSECONDS_PER_SECOND, > because... > > Signed-off-by: Rutuja Shah <rutu.shah...@gmail.com> > > -- > Eric Blake eblake redhat com+1-919-301-3266 > Libvirt virtualization library http://libvirt.org >
[Qemu-block] [PATCH] Replaced get_ticks_per_sec calls with NANOSECONDS_PER_SECOND
MU_CLOCK_VIRTUAL) + get_ticks_per_sec() / 2); + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + NANOSECONDS_PER_SECOND / 2); } } diff --git a/hw/watchdog/wdt_diag288.c b/hw/watchdog/wdt_diag288.c index 1c3658e..f54a35a 100644 --- a/hw/watchdog/wdt_diag288.c +++ b/hw/watchdog/wdt_diag288.c @@ -79,7 +79,7 @@ static int wdt_diag288_handle_timer(DIAG288State *diag288, } timer_mod(diag288->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + - timeout * get_ticks_per_sec()); + timeout * NANOSECONDS_PER_SECOND); break; case WDT_DIAG288_CANCEL: if (!diag288->enabled) { diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c index 532530b..532afe8 100644 --- a/hw/watchdog/wdt_ib700.c +++ b/hw/watchdog/wdt_ib700.c @@ -64,7 +64,7 @@ static void ib700_write_enable_reg(void *vp, uint32_t addr, uint32_t data) ib700_debug("addr = %x, data = %x\n", addr, data); -timeout = (int64_t) time_map[data & 0xF] * get_ticks_per_sec(); +timeout = (int64_t) time_map[data & 0xF] * NANOSECONDS_PER_SECOND; timer_mod(s->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + timeout); } diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index 7462e20..a2aa704 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -155,7 +155,7 @@ void acpi_pm_tmr_reset(ACPIREGS *ar); static inline int64_t acpi_pm_tmr_get_clock(void) { return muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), PM_TIMER_FREQUENCY, -get_ticks_per_sec()); +NANOSECONDS_PER_SECOND); } /* PM1a_EVT: piix and ich9 don't implement PM1b. */ diff --git a/include/qemu/timer.h b/include/qemu/timer.h index d0946cb..ea38a71 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -796,7 +796,7 @@ static inline int64_t get_max_clock_jump(void) * generated by the RTC on clock jumps, but large enough to avoid frequent * unnecessary resets in idle VMs. */ -return 60 * get_ticks_per_sec(); +return 60 * NANOSECONDS_PER_SECOND; } /* @@ -822,7 +822,7 @@ static inline int64_t get_clock(void) { LARGE_INTEGER ti; QueryPerformanceCounter(); -return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq); +return muldiv64(ti.QuadPart, NANOSECONDS_PER_SECOND, clock_freq); } #else diff --git a/monitor.c b/monitor.c index e99ca8c..6bdf174 100644 --- a/monitor.c +++ b/monitor.c @@ -1506,9 +1506,9 @@ int64_t dev_time; static void hmp_info_profile(Monitor *mon, const QDict *qdict) { monitor_printf(mon, "async time %" PRId64 " (%0.3f)\n", - dev_time, dev_time / (double)get_ticks_per_sec()); + dev_time, dev_time / (double)NANOSECONDS_PER_SECOND); monitor_printf(mon, "qemu time %" PRId64 " (%0.3f)\n", - tcg_time, tcg_time / (double)get_ticks_per_sec()); + tcg_time, tcg_time / (double)NANOSECONDS_PER_SECOND); tcg_time = 0; dev_time = 0; } diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index d67c169..a095c91 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -1336,7 +1336,7 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) /* Always wake up soon in case the interrupt was level based */ timer_mod(idle_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + - (get_ticks_per_sec() / 50)); + (NANOSECONDS_PER_SECOND / 50)); } /* We don't know if there are more interrupts pending after this. However, @@ -1796,7 +1796,7 @@ uint32_t kvmppc_get_tbfreq(void) { char line[512]; char *ns; -uint32_t retval = get_ticks_per_sec(); +uint32_t retval = NANOSECONDS_PER_SECOND; if (read_cpuinfo("timebase", line, sizeof(line))) { return retval; -- 1.9.1 Regards Rutuja Shah