From: vincentfu@gmail.com
To: axboe@kernel.dk, fio@vger.kernel.org
Cc: Vincent Fu <vincent.fu@wdc.com>
Subject: [PATCH 1/2] stat: clean up calc_clat_percentiles
Date: Thu, 7 Feb 2019 10:51:06 -0500 [thread overview]
Message-ID: <20190207155107.7148-2-vincentfu@gmail.com> (raw)
In-Reply-To: <20190207155107.7148-1-vincentfu@gmail.com>
From: Vincent Fu <vincent.fu@wdc.com>
We already know the size of the buffer needed. So there
is no need to do anything fancy when allocating it.
---
stat.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/stat.c b/stat.c
index 351c49cc..7c843e6b 100644
--- a/stat.c
+++ b/stat.c
@@ -139,7 +139,6 @@ unsigned int calc_clat_percentiles(uint64_t *io_u_plat, unsigned long long nr,
{
unsigned long long sum = 0;
unsigned int len, i, j = 0;
- unsigned int oval_len = 0;
unsigned long long *ovals = NULL;
bool is_last;
@@ -161,6 +160,10 @@ unsigned int calc_clat_percentiles(uint64_t *io_u_plat, unsigned long long nr,
if (len > 1)
qsort((void *)plist, len, sizeof(plist[0]), double_cmp);
+ ovals = malloc(len * sizeof(*ovals));
+ if (!ovals)
+ return 0;
+
/*
* Calculate bucket values, note down max and min values
*/
@@ -170,11 +173,6 @@ unsigned int calc_clat_percentiles(uint64_t *io_u_plat, unsigned long long nr,
while (sum >= (plist[j].u.f / 100.0 * nr)) {
assert(plist[j].u.f <= 100.0);
- if (j == oval_len) {
- oval_len += 100;
- ovals = realloc(ovals, oval_len * sizeof(*ovals));
- }
-
ovals[j] = plat_idx_to_val(i);
if (ovals[j] < *minv)
*minv = ovals[j];
--
2.17.1
next prev parent reply other threads:[~2019-02-07 15:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-07 15:51 [PATCH 0/2] stat cleanup/bugfix patches vincentfu
2019-02-07 15:51 ` vincentfu [this message]
2019-02-07 15:51 ` [PATCH 2/2] stat: put 'percentiles' object in appropriate 'clat_ns' or 'lat_ns' parent vincentfu
2019-02-07 16:49 ` [PATCH 0/2] stat cleanup/bugfix patches Jens Axboe
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=20190207155107.7148-2-vincentfu@gmail.com \
--to=vincentfu@gmail.com \
--cc=axboe@kernel.dk \
--cc=fio@vger.kernel.org \
--cc=vincent.fu@wdc.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox