From: Jiri Olsa <jolsa@redhat.com>
To: Tommi Rantala <tommi.t.rantala@nokia.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Darren Hart <dvhart@infradead.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] perf bench: Fix div-by-zero if runtime is zero
Date: Mon, 20 Apr 2020 11:05:26 +0200 [thread overview]
Message-ID: <20200420090526.GF718574@krava> (raw)
In-Reply-To: <20200417132330.119407-4-tommi.t.rantala@nokia.com>
On Fri, Apr 17, 2020 at 04:23:29PM +0300, Tommi Rantala wrote:
> Fix div-by-zero if runtime is zero:
>
> $ perf bench futex hash --runtime=0
> # Running 'futex/hash' benchmark:
> Run summary [PID 12090]: 4 threads, each operating on 1024 [private] futexes for 0 secs.
> Floating point exception (core dumped)
>
> Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
thanks,
jirka
> ---
> tools/perf/bench/epoll-wait.c | 3 ++-
> tools/perf/bench/futex-hash.c | 3 ++-
> tools/perf/bench/futex-lock-pi.c | 3 ++-
> 3 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/bench/epoll-wait.c b/tools/perf/bench/epoll-wait.c
> index f938c585d512..cf797362675b 100644
> --- a/tools/perf/bench/epoll-wait.c
> +++ b/tools/perf/bench/epoll-wait.c
> @@ -519,7 +519,8 @@ int bench_epoll_wait(int argc, const char **argv)
> qsort(worker, nthreads, sizeof(struct worker), cmpworker);
>
> for (i = 0; i < nthreads; i++) {
> - unsigned long t = worker[i].ops / bench__runtime.tv_sec;
> + unsigned long t = bench__runtime.tv_sec > 0 ?
> + worker[i].ops / bench__runtime.tv_sec : 0;
>
> update_stats(&throughput_stats, t);
>
> diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c
> index 65eebe06c04d..915bf3da7ce2 100644
> --- a/tools/perf/bench/futex-hash.c
> +++ b/tools/perf/bench/futex-hash.c
> @@ -205,7 +205,8 @@ int bench_futex_hash(int argc, const char **argv)
> pthread_mutex_destroy(&thread_lock);
>
> for (i = 0; i < nthreads; i++) {
> - unsigned long t = worker[i].ops / bench__runtime.tv_sec;
> + unsigned long t = bench__runtime.tv_sec > 0 ?
> + worker[i].ops / bench__runtime.tv_sec : 0;
> update_stats(&throughput_stats, t);
> if (!silent) {
> if (nfutexes == 1)
> diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c
> index 89fd8f325f38..bb25d8beb3b8 100644
> --- a/tools/perf/bench/futex-lock-pi.c
> +++ b/tools/perf/bench/futex-lock-pi.c
> @@ -211,7 +211,8 @@ int bench_futex_lock_pi(int argc, const char **argv)
> pthread_mutex_destroy(&thread_lock);
>
> for (i = 0; i < nthreads; i++) {
> - unsigned long t = worker[i].ops / bench__runtime.tv_sec;
> + unsigned long t = bench__runtime.tv_sec > 0 ?
> + worker[i].ops / bench__runtime.tv_sec : 0;
>
> update_stats(&throughput_stats, t);
> if (!silent)
> --
> 2.25.2
>
next prev parent reply other threads:[~2020-04-20 9:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-17 13:23 [PATCH 1/4] perf cgroup: Avoid needless closing of unopened fd Tommi Rantala
2020-04-17 13:23 ` [PATCH 2/4] perf tools: Move zstd_fini() to session deletion Tommi Rantala
2020-04-20 8:54 ` Jiri Olsa
2020-04-23 5:52 ` Rantala, Tommi T. (Nokia - FI/Espoo)
2020-04-17 13:23 ` [PATCH 3/4] perf tools: Fix segfaults due to missing zstd decompressor initialization Tommi Rantala
2020-04-20 9:05 ` Jiri Olsa
2020-04-17 13:23 ` [PATCH 4/4] perf bench: Fix div-by-zero if runtime is zero Tommi Rantala
2020-04-20 9:05 ` Jiri Olsa [this message]
2020-04-20 12:05 ` Arnaldo Carvalho de Melo
2020-05-08 13:05 ` [tip: perf/core] " tip-bot2 for Tommi Rantala
2020-04-20 8:48 ` [PATCH 1/4] perf cgroup: Avoid needless closing of unopened fd Jiri Olsa
2020-04-20 12:05 ` Arnaldo Carvalho de Melo
2020-05-08 13:05 ` [tip: perf/core] " tip-bot2 for Tommi Rantala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200420090526.GF718574@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tommi.t.rantala@nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.