[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-ab463a252c4c790913c0ca0196e5dc7ea04b1f02@git.kernel.org>
Date: Tue, 13 Feb 2018 04:04:47 -0800
From: tip-bot for Kan Liang <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: tglx@...utronix.de, wangnan0@...wei.com, peterz@...radead.org,
namhyung@...nel.org, hpa@...or.com, ak@...ux.intel.com,
mingo@...nel.org, linux-kernel@...r.kernel.org, jolsa@...nel.org,
yao.jin@...ux.intel.com, acme@...hat.com, kan.liang@...el.com
Subject: [tip:perf/urgent] perf mmap: Recalculate size for overwrite mode
Commit-ID: ab463a252c4c790913c0ca0196e5dc7ea04b1f02
Gitweb: https://git.kernel.org/tip/ab463a252c4c790913c0ca0196e5dc7ea04b1f02
Author: Kan Liang <kan.liang@...el.com>
AuthorDate: Thu, 18 Jan 2018 13:26:17 -0800
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Tue, 6 Feb 2018 10:11:49 -0300
perf mmap: Recalculate size for overwrite mode
In perf_mmap__push(), the 'size' need to be recalculated, otherwise the
invalid data might be pushed to the record in overwrite mode.
The issue is introduced by commit 7fb4b407a124 ("perf mmap: Don't
discard prev in backward mode").
When the ring buffer is full in overwrite mode, backward_rb_find_range()
will be called to recalculate the 'start' and 'end'. The 'size' needs to
be recalculated accordingly.
Unconditionally recalculate the 'size', not just for full ring buffer in
overwrite mode. Because:
- There is no harmful to recalculate the 'size' for other cases.
- The code of calculating 'start' and 'end' will be factored out later.
The new function does not need to return 'size'.
Signed-off-by: Kan Liang <kan.liang@...el.com>
Acked-by: Jiri Olsa <jolsa@...nel.org>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Jin Yao <yao.jin@...ux.intel.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Wang Nan <wangnan0@...wei.com>
Fixes: 7fb4b407a124 ("perf mmap: Don't discard prev in backward mode")
Link: http://lkml.kernel.org/r/1516310792-208685-3-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/mmap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 05076e6..97cf4fa 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -302,6 +302,8 @@ int perf_mmap__push(struct perf_mmap *md, bool overwrite,
return -1;
}
+ size = end - start;
+
if ((start & md->mask) + size != (end & md->mask)) {
buf = &data[start & md->mask];
size = md->mask + 1 - (start & md->mask);
Powered by blists - more mailing lists