rt-tests/SOURCES/rt-tests-queuelat-Fix-stori...

112 lines
3.3 KiB
Diff

From 41a3f9e53920d50b48c04593bfa3eb0e87fcf49f Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Tue, 12 May 2020 11:02:39 -0400
Subject: [PATCH] rt-tests: queuelat: Fix storing unsigned long long in int
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