From: John Kacur <jkacur@redhat.com>
To: RT <linux-rt-users@vger.kernel.org>
Cc: Clark Williams <williams@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
John Kacur <jkacur@redhat.com>
Subject: [PATCH] rt-tests: queuelat: Fix storing unsigned long long in int
Date: Tue, 12 May 2020 11:16:51 -0400 [thread overview]
Message-ID: <20200512151651.4642-1-jkacur@redhat.com> (raw)
queuelat can occassionally hang because of overflow mixing
unsigned long long and int
Attaching to process 173912
Reading symbols from /root/rt-tests/queuelat...done.
Reading symbols from /lib64/librt.so.1...Reading symbols from /usr/lib/debug/usr/lib64/librt-2.28.so.debug...done.
done.
Reading symbols from /lib64/libpthread.so.0...Reading symbols from /usr/lib/debug/usr/lib64/libpthread-2.28.so.debug...done.
done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Reading symbols from /lib64/libc.so.6...Reading symbols from /usr/lib/debug/usr/lib64/libc-2.28.so.debug...done.
done.
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/usr/lib64/ld-2.28.so.debug...done.
done.
__memmove_avx_unaligned_erms ()
at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:254
254 rep movsb
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000400c02 in account (val=18446744071562067968)
at src/queuelat/queuelat.c:93
93 buckets[bucket_nr]++;
(gdb) bt full
at src/queuelat/queuelat.c:93
bucket_nr = -193273529
a = 825932047802952
b = 825925371232340
dest = 0xf322b0
src = 0xf4e3f0
i = 45749
delta = -2147483648
loops = 50000
time = 6500
bucket_nr = 65
n = 115000
delta = 3500
at src/queuelat/queuelat.c:671
tsc_freq_mhz = 2398.5039999999999
max_queue_len_f = 159.900284
mvalue = 0x7ffc99d3021c "20000"
cvalue = 0x7ffc99d30225 "300"
pvalue = 0x7ffc99d30238 "6.1"
fvalue = 0x7ffc99d3022c "2398.504"
tvalue = 0x7ffc99d3023f "30"
qvalue = 0x0
index = 0
c = -1
Fix the above by declaring delta as an unsigned long long
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/queuelat/queuelat.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/queuelat/queuelat.c b/src/queuelat/queuelat.c
index 7e5e35768a8b..22b68a84d6ae 100644
--- a/src/queuelat/queuelat.c
+++ b/src/queuelat/queuelat.c
@@ -354,9 +354,9 @@ static void trace_write(char *buf, int len)
static void run_n(int n)
{
- u64 a, b;
+ u64 a, b, delta;
void *dest, *src;
- int i, delta, loops = 50000;
+ int i, loops = 50000;
init_buckets();
@@ -445,9 +445,8 @@ static void print_exit_info(void)
void main_loop(void)
{
- u64 a, b;
+ u64 a, b, delta;
void *dest, *src;
- int delta;
int queue_size = 0;
trace_open();
@@ -500,7 +499,7 @@ void main_loop(void)
continue;
ret = sprintf(buf, "memmove block queue_size=%d queue_dec=%d"
- " queue_inc=%d delta=%d ns\n", queue_size,
+ " queue_inc=%d delta=%llu ns\n", queue_size,
nr_packets_drain_per_block,
nr_packets_fill, delta);
trace_write(buf, ret);
@@ -536,7 +535,7 @@ static void install_signals(void)
int calculate_nr_packets_drain_per_block(void)
{
- int maxcount;
+ unsigned long long maxcount;
int i, time;
int found = 0;
int bucket_nr = find_highest_count_bucket();
--
2.21.3
reply other threads:[~2020-05-12 15:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200512151651.4642-1-jkacur@redhat.com \
--to=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=williams@redhat.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;
as well as URLs for NNTP newsgroup(s).