From 5501fa14619fd0afa3a85af21e2cf2057a271265 Mon Sep 17 00:00:00 2001 From: nocjj <1250062498@qq.com> Date: Mon, 14 Sep 2020 20:02:23 +0800 Subject: [PATCH 1/6] bugfix: fix %ST, %GUE, %HYP formula Since the steal time, gtime, stime which are acquired from debugfs count in ns unit, the usage formula should be: usage = time * 100 / 1000000000 / delay time And expand display align of %ST, %GUE, %HYP to avoid abnormal display. Signed-off-by: Jiajun Chen <1250062498@qq.com> --- bugfix-fix-ST-GUE-HYP-formula.patch | 67 +++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 bugfix-fix-ST-GUE-HYP-formula.patch diff --git a/bugfix-fix-ST-GUE-HYP-formula.patch b/bugfix-fix-ST-GUE-HYP-formula.patch new file mode 100644 index 0000000..20965e1 --- /dev/null +++ b/bugfix-fix-ST-GUE-HYP-formula.patch @@ -0,0 +1,67 @@ +From f4189eb5ddbebe0ddf58e7ea4bd25e8a5141930f Mon Sep 17 00:00:00 2001 +From: nocjj <1250062498@qq.com> +Date: Mon, 14 Sep 2020 20:02:23 +0800 +Subject: [PATCH] bugfix: fix %ST, %GUE, %HYP formula + +Since the steal time, gtime, stime which are acquired from debugfs +count in ns unit, the usage formula should be: +usage = time * 100 / 1000000000 / delay time + +And expand display align of %ST, %GUE, %HYP to avoid abnormal display. + +Signed-off-by: Jiajun Chen <1250062498@qq.com> +--- + src/field.c | 6 +++--- + src/vmtop.c | 9 ++++++--- + 2 files changed, 9 insertions(+), 6 deletions(-) + +diff --git a/src/field.c b/src/field.c +index d5484b3..21be4fd 100644 +--- a/src/field.c ++++ b/src/field.c +@@ -39,9 +39,9 @@ FID fields[] = { + {"EXTsum", FIELDS_DISPLAY, 10 }, + {"S", FIELDS_DISPLAY, 5 }, + {"P", FIELDS_DISPLAY, 5 }, +- {"%ST", FIELDS_DISPLAY, 6 }, +- {"%GUE", FIELDS_DISPLAY, 6 }, +- {"%HYP", FIELDS_DISPLAY, 6 } ++ {"%ST", FIELDS_DISPLAY, 8 }, ++ {"%GUE", FIELDS_DISPLAY, 8 }, ++ {"%HYP", FIELDS_DISPLAY, 8 } + }; + + int get_show_field_num(void) +diff --git a/src/vmtop.c b/src/vmtop.c +index d45418b..cdf6ec4 100644 +--- a/src/vmtop.c ++++ b/src/vmtop.c +@@ -219,19 +219,22 @@ static void print_domain_field(struct domain *dom, int field) + } + case FD_ST: { + print_scr("%*.1f", fields[i].align, +- (double)dom->DELTA_VALUE(steal) / 1000000.0f / delay_time); ++ (double)dom->DELTA_VALUE(steal) * 100 / ++ 1000000000.0f / delay_time); + break; + } + case FD_GUE: { + print_scr("%*.1f", fields[i].align, +- (double)dom->DELTA_VALUE(gtime) / 1000000.0f / delay_time); ++ (double)dom->DELTA_VALUE(gtime) * 100 / ++ 1000000000.0f / delay_time); + break; + } + case FD_HYP: { + u64 hyp_time = dom->DELTA_VALUE(vcpu_utime) - dom->DELTA_VALUE(gtime) + + dom->DELTA_VALUE(vcpu_stime); + print_scr("%*.1f", fields[i].align, +- (double)hyp_time / 1000000.0f / delay_time); ++ (double)hyp_time * 100 / ++ 1000000000.0f / delay_time); + break; + } + default: +-- +2.23.0 + -- Gitee From 215d8d82534e10523d93a002600382657a9b67be Mon Sep 17 00:00:00 2001 From: nocjj <1250062498@qq.com> Date: Sat, 19 Sep 2020 11:36:36 +0800 Subject: [PATCH 2/6] display: expand row size in TEXT mode Currently default row size = 1024, which means only 1024 row will show in TEXT mode. But in some case, there are more than 1024 tasks include vcpu, iothreads and etc. So expand default row size to 2048. Signed-off-by: Jiajun Chen <1250062498@qq.com> --- display-expand-row-size-in-TEXT-mode.patch | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 display-expand-row-size-in-TEXT-mode.patch diff --git a/display-expand-row-size-in-TEXT-mode.patch b/display-expand-row-size-in-TEXT-mode.patch new file mode 100644 index 0000000..78a1beb --- /dev/null +++ b/display-expand-row-size-in-TEXT-mode.patch @@ -0,0 +1,30 @@ +From bd91aa4d39611d838ca60f8c3f27473e6a6b0c59 Mon Sep 17 00:00:00 2001 +From: nocjj <1250062498@qq.com> +Date: Sat, 19 Sep 2020 11:36:36 +0800 +Subject: [PATCH] display: expand row size in TEXT mode + +Currently default row size = 1024, which means only 1024 row +will show in TEXT mode. But in some case, there are more than 1024 tasks +include vcpu, iothreads and etc. So expand default row size to 2048. + +Signed-off-by: Jiajun Chen <1250062498@qq.com> +--- + src/vmtop.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/vmtop.c b/src/vmtop.c +index cdf6ec4..7cfb1b3 100644 +--- a/src/vmtop.c ++++ b/src/vmtop.c +@@ -63,7 +63,7 @@ static void init_parameter(void) + scr_mode = TERM_MODE; + quit_flag = 0; + delay_time = 1; /* default delay 1s between display */ +- scr_row_size = 1024; /* defualt size row */ ++ scr_row_size = 2048; /* defualt size row */ + scr_col_size = 1024; /* default size col */ + } + +-- +2.23.0 + -- Gitee From 7fbe8ce9e91d66d69d2fcf162943f154c181f289 Mon Sep 17 00:00:00 2001 From: nocjj <1250062498@qq.com> Date: Sat, 19 Sep 2020 11:46:08 +0800 Subject: [PATCH 3/6] bugfix: exit vmtop when arguments are invalid Currently if vmtop receive invalid args, vmtop will still run. It is a abnormal behavior, so exit vmtop when arguments are invalid. Signed-off-by: Jiajun Chen <1250062498@qq.com> --- ...xit-vmtop-when-arguments-are-invalid.patch | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bugfix-exit-vmtop-when-arguments-are-invalid.patch diff --git a/bugfix-exit-vmtop-when-arguments-are-invalid.patch b/bugfix-exit-vmtop-when-arguments-are-invalid.patch new file mode 100644 index 0000000..93272a3 --- /dev/null +++ b/bugfix-exit-vmtop-when-arguments-are-invalid.patch @@ -0,0 +1,28 @@ +From 92239c1b444cd3f2904e2b3d7c7eaada1e9693ec Mon Sep 17 00:00:00 2001 +From: nocjj <1250062498@qq.com> +Date: Sat, 19 Sep 2020 11:46:08 +0800 +Subject: [PATCH] bugfix: exit vmtop when arguments are invalid + +Currently if vmtop receive invalid args, vmtop will still run. +It is a abnormal behavior, so exit vmtop when arguments are invalid. + +Signed-off-by: Jiajun Chen <1250062498@qq.com> +--- + src/vmtop.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/vmtop.c b/src/vmtop.c +index 7cfb1b3..18d3010 100644 +--- a/src/vmtop.c ++++ b/src/vmtop.c +@@ -96,6 +96,7 @@ static void parse_args(int argc, char *argv[]) + break; + } + default: ++ exit(1); /* exit vmtop when args are invalid */ + break; + } + } +-- +2.23.0 + -- Gitee From cf7bd4b603d3063c7fe18506658edc4152d10313 Mon Sep 17 00:00:00 2001 From: nocjj <1250062498@qq.com> Date: Sat, 19 Sep 2020 14:48:06 +0800 Subject: [PATCH 4/6] bugfix: check unsigned number flip before getting delta Sometimes, a very large number will appear in EXTxxx display items. The reason of this phenomenon is that we do not check the size of two unsigned numbers before getting delta value of them, which will cause unsigned number flip. So add check before getting delta value. Signed-off-by: Jiajun Chen <1250062498@qq.com> --- ...igned-number-flip-before-getting-del.patch | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 bugfix-check-unsigned-number-flip-before-getting-del.patch diff --git a/bugfix-check-unsigned-number-flip-before-getting-del.patch b/bugfix-check-unsigned-number-flip-before-getting-del.patch new file mode 100644 index 0000000..53eafc9 --- /dev/null +++ b/bugfix-check-unsigned-number-flip-before-getting-del.patch @@ -0,0 +1,50 @@ +From 4eb3e65353484c6c5cf81046d7b2296151ef3b83 Mon Sep 17 00:00:00 2001 +From: nocjj <1250062498@qq.com> +Date: Sat, 19 Sep 2020 14:48:06 +0800 +Subject: [PATCH] bugfix: check unsigned number flip before getting delta + +Sometimes, a very large number will appear in EXTxxx display items. +The reason of this phenomenon is that we do not check the size of +two unsigned numbers before getting delta value of them, +which will cause unsigned number flip. +So add check before getting delta value. + +Signed-off-by: Jiajun Chen <1250062498@qq.com> +--- + src/type.h | 6 +++++- + src/vmtop.c | 2 +- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/type.h b/src/type.h +index 85edc52..0e92388 100644 +--- a/src/type.h ++++ b/src/type.h +@@ -42,7 +42,11 @@ typedef unsigned long long u64; + static inline void DELTA_NAME(v)(struct domain *new, \ + struct domain *old) \ + { \ +- new->DELTA_VALUE(v) = new->v - old->v; \ ++ if (new->v >= old->v) { \ ++ new->DELTA_VALUE(v) = new->v - old->v; \ ++ } else { \ ++ new->DELTA_VALUE(v) = old->DELTA_VALUE(v); \ ++ } \ + } + + #define SUM_NAME(v) domain_sum_ ## v +diff --git a/src/vmtop.c b/src/vmtop.c +index 18d3010..7a1b19b 100644 +--- a/src/vmtop.c ++++ b/src/vmtop.c +@@ -250,7 +250,7 @@ static void show_task(struct domain *task) + int showd_field = 0; + showd_task++; + if (showd_task < begin_task || +- showd_task - begin_task > scr_row_size - 4) { ++ showd_task - begin_task > scr_row_size - 5) { + return; + } + clrtoeol(); +-- +2.23.0 + -- Gitee From 5139578b364d94fe5d1c21216a093d6dfce42f60 Mon Sep 17 00:00:00 2001 From: Euler Robot Date: Mon, 21 Sep 2020 10:49:46 +0800 Subject: [PATCH 5/6] spec: Update patch and changelog with !5 bugfix: fix %ST, %GUE, %HYP formula display: expand row size in TEXT mode bugfix: exit vmtop when arguments are invalid bugfix: check unsigned number flip before getting delta Signed-off-by: Jiajun Chen <1250062498@qq.com> --- vmtop.spec | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/vmtop.spec b/vmtop.spec index 3755675..69aebb8 100644 --- a/vmtop.spec +++ b/vmtop.spec @@ -1,53 +1,115 @@ Name: vmtop +Patch0002: display-expand-row-size-in-TEXT-mode.patch +Patch0003: bugfix-exit-vmtop-when-arguments-are-invalid.patch +Patch0004: bugfix-check-unsigned-number-flip-before-getting-del.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Version: 1.0 +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Release: 1 +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Summary: A tool for collecting and analyzing data of virtual machine +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch License: Mulan PSL V2 +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Group: Application/System +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch URL: https://gitee.com/openeuler/vmtop +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Source:https://gitee.com/src-openeuler/vmtop/blob/master/%{name}-%{version}.tar.gz +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Requires: libvirt, ncurses +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch BuildRequires: ncurses-devel +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch BuildRequires: libtool +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch BuildRequires: autoconf +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch BuildRequires: automake +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Buildrequires: libvirt-devel +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Provides: vmtop = %{version}-%{release} +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch %description +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch This is a userspace tool which you can run it in host to help detecting VM's performance. By vmtop, you can quickly query vcpu info such as cpu usage, kvm exit times, memory usage and etc. +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch %prep +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch %autosetup -c -n %{name}-%{version} +- bugfix: fix %ST, %GUE, %HYP formula +- display: expand row size in TEXT mode +- bugfix: exit vmtop when arguments are invalid +- bugfix: check unsigned number flip before getting delta +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch + +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch %build +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch aclocal +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch autoconf +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch autoheader +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch automake --add-missing +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch ./configure --libdir=%{_libdir} \ +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch --bindir=%{_bindir} \ +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch --sbindir=%{_sbindir} \ +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch --enable-secure-build +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch make +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch %install +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch rm -rf %{buildroot} +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch mkdir -p %{buildroot}/usr/bin +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch install -m 550 vmtop ${RPM_BUILD_ROOT}/usr/bin/%{name} +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch %files +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch %license License/LICENSE +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch %{_bindir}/vmtop +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch %changelog +* Sat Sep 19 2020 nocjj <1250062498@qq.com> +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch * Wed Sep 09 2020 Jiajun Chen <1250062498@qq.com> - 1.0-1 +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch - vmtop:Show kvm exit items and add document to project +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch * Tue Aug 25 2020 Jiajun Chen <1250062498@qq.com> - 1.0-0 +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch - vmtop: add spec and source code tar for project to build rpm +Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch -- Gitee From 8bbc3877df99dcbc63f1486d3ab739a1463797dc Mon Sep 17 00:00:00 2001 From: Euler Robot Date: Mon, 21 Sep 2020 10:49:46 +0800 Subject: [PATCH 6/6] spec: Update release version with !5 increase release verison by one Signed-off-by: Euler Robot --- vmtop.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmtop.spec b/vmtop.spec index 69aebb8..ec78b65 100644 --- a/vmtop.spec +++ b/vmtop.spec @@ -5,7 +5,7 @@ Patch0004: bugfix-check-unsigned-number-flip-before-getting-del.patch Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Version: 1.0 Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch -Release: 1 +Release: 2 Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch Summary: A tool for collecting and analyzing data of virtual machine Patch0001: bugfix-fix-ST-GUE-HYP-formula.patch -- Gitee