!68 fix -m option

From: @xu_lei_123 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
This commit is contained in:
openeuler-ci-bot 2023-12-27 06:46:01 +00:00 committed by Gitee
commit 924a9e72d9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,42 @@
From d3fcd3415c60995784dbedda8e92d0f880a871b8 Mon Sep 17 00:00:00 2001
From: Steven Rostedt <rostedt@goodmis.org>
Date: Wed, 27 Dec 2023 11:37:43 +0800
Subject: [PATCH] trace-cmd record: Fix -m option
The -m option limits the size of each per-cpu buffer to the value
specified in kbs (or actually pages). That is, if -m 1000 is specified,
then the size per cpu buffer should not be more that 1000 kbs. Since it is
implemented in halfs, it is usually between half and the full amount.
But since the buffer reads can use pipes, the increment of the page count
needs to take that into consideration. Currently, it just increments the
page count every time the count goes over the page size. But due to pipes,
the size increment can be multiple pages (65k in fact), and this distorts
the size.
Have the page count increment via the actually size read and not just by
one even if several pages were read at one go.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
trace-recorder.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/trace-recorder.c b/trace-recorder.c
index c811028..d133d9a 100644
--- a/trace-recorder.c
+++ b/trace-recorder.c
@@ -323,8 +323,8 @@ static inline void update_fd(struct tracecmd_recorder *recorder, int size)
recorder->count += size;
if (recorder->count >= recorder->page_size) {
+ recorder->pages += recorder->count / recorder->page_size;
recorder->count = 0;
- recorder->pages++;
}
if (recorder->pages < recorder->max)
--
2.37.0.windows.1

View File

@ -1,6 +1,6 @@
Name: trace-cmd
Version: 2.7
Release: 6
Release: 7
Summary: A front-end for Ftrace
License: GPLv2 and LGPLv2
URL: http://git.kernel.org/?p=linux/kernel/git/rostedt/trace-cmd.git;a=summary
@ -9,6 +9,7 @@ Source1: kernelshark.desktop
Patch1: 0001-trace-cmd-Figure-out-the-arch-and-install-library-to.patch
Patch2: 0002-trace-cmd-Fix-the-logic-behind-SWIG_DEFINED-in-the-M.patch
Patch3: Backport-trace-cmd-Fix-buffer-overflow-in-arg_eval.patch
Patch4: backport-Fix-m-option-limit.patch
BuildRequires: gcc xmlto asciidoc mlocate libxml2-devel
BuildRequires: gtk2-devel glib2-devel desktop-file-utils
@ -92,6 +93,9 @@ desktop-file-validate $RPM_BUILD_ROOT/%{_datadir}/applications/kernelshark.deskt
%{_mandir}/man5/*
%changelog
* Wed Dec 27 2023 xulei <xulei@xfusion.com> - 2.7-7
- Fix -m option
* Fri Jul 28 2023 Bolehu <heyaohua@xfusion.com> - 2.7-6
- Fix buffer overflow in arg_eval