[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221018120056.1321426-3-sunliming@kylinos.cn>
Date: Tue, 18 Oct 2022 20:00:53 +0800
From: sunliming <sunliming@...inos.cn>
To: rostedt@...dmis.org, mingo@...nel.org
Cc: linux-kernel@...r.kernel.org, kelulanainsley@...il.com,
sunliming <sunliming@...inos.cn>
Subject: [PATCH 2/5] ring-buffer: Remove absolute timestamp from add_timestamp logic
Remove absolute timestamp from add_timestamp logic.
Signed-off-by: sunliming <sunliming@...inos.cn>
---
kernel/trace/ring_buffer.c | 49 +++++++++++++-------------------------
1 file changed, 17 insertions(+), 32 deletions(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 199759c73519..ab0aef15f82a 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -436,14 +436,12 @@ struct rb_event_info {
* Used for the add_timestamp
* NONE
* EXTEND - wants a time extend
- * ABSOLUTE - the buffer requests all events to have absolute time stamps
* FORCE - force a full time stamp.
*/
enum {
RB_ADD_STAMP_NONE = 0,
RB_ADD_STAMP_EXTEND = BIT(1),
- RB_ADD_STAMP_ABSOLUTE = BIT(2),
- RB_ADD_STAMP_FORCE = BIT(3)
+ RB_ADD_STAMP_FORCE = BIT(2)
};
/*
* Used for which event context the event is in.
@@ -2832,8 +2830,7 @@ static void rb_add_timestamp(struct ring_buffer_per_cpu *cpu_buffer,
u64 *delta,
unsigned int *length)
{
- bool abs = info->add_timestamp &
- (RB_ADD_STAMP_FORCE | RB_ADD_STAMP_ABSOLUTE);
+ bool abs = info->add_timestamp & RB_ADD_STAMP_FORCE;
if (unlikely(info->delta > (1ULL << 59))) {
/*
@@ -3435,8 +3432,7 @@ static void check_buffer(struct ring_buffer_per_cpu *cpu_buffer,
if (tail == CHECK_FULL_PAGE) {
full = true;
tail = local_read(&bpage->commit);
- } else if (info->add_timestamp &
- (RB_ADD_STAMP_FORCE | RB_ADD_STAMP_ABSOLUTE)) {
+ } else if (info->add_timestamp & RB_ADD_STAMP_FORCE) {
/* Ignore events with absolute time stamps */
return;
}
@@ -3535,23 +3531,19 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
barrier();
info->ts = rb_time_stamp(cpu_buffer->buffer);
- if ((info->add_timestamp & RB_ADD_STAMP_ABSOLUTE)) {
- info->delta = info->ts;
+ /*
+ * If interrupting an event time update, we may need an
+ * absolute timestamp.
+ * Don't bother if this is the start of a new page (w == 0).
+ */
+ if (unlikely(!a_ok || !b_ok || (info->before != info->after && w))) {
+ info->add_timestamp |= RB_ADD_STAMP_FORCE | RB_ADD_STAMP_EXTEND;
+ info->length += RB_LEN_TIME_EXTEND;
} else {
- /*
- * If interrupting an event time update, we may need an
- * absolute timestamp.
- * Don't bother if this is the start of a new page (w == 0).
- */
- if (unlikely(!a_ok || !b_ok || (info->before != info->after && w))) {
- info->add_timestamp |= RB_ADD_STAMP_FORCE | RB_ADD_STAMP_EXTEND;
+ info->delta = info->ts - info->after;
+ if (unlikely(test_time_stamp(info->delta))) {
+ info->add_timestamp |= RB_ADD_STAMP_EXTEND;
info->length += RB_LEN_TIME_EXTEND;
- } else {
- info->delta = info->ts - info->after;
- if (unlikely(test_time_stamp(info->delta))) {
- info->add_timestamp |= RB_ADD_STAMP_EXTEND;
- info->length += RB_LEN_TIME_EXTEND;
- }
}
}
@@ -3586,8 +3578,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
barrier();
/*E*/ s_ok = rb_time_read(&cpu_buffer->before_stamp, &save_before);
RB_WARN_ON(cpu_buffer, !s_ok);
- if (likely(!(info->add_timestamp &
- (RB_ADD_STAMP_FORCE | RB_ADD_STAMP_ABSOLUTE))))
+ if (likely(!(info->add_timestamp & RB_ADD_STAMP_FORCE)))
/* This did not interrupt any time update */
info->delta = info->ts - info->after;
else
@@ -3644,8 +3635,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
* If this is the first commit on the page, then it has the same
* timestamp as the page itself.
*/
- if (unlikely(!tail && !(info->add_timestamp &
- (RB_ADD_STAMP_FORCE | RB_ADD_STAMP_ABSOLUTE))))
+ if (unlikely(!tail && !(info->add_timestamp & RB_ADD_STAMP_FORCE)))
info->delta = 0;
/* We reserved something on the buffer */
@@ -3698,12 +3688,7 @@ rb_reserve_next_event(struct trace_buffer *buffer,
info.length = rb_calculate_event_length(length);
- if (ring_buffer_time_stamp_abs(cpu_buffer->buffer)) {
- add_ts_default = RB_ADD_STAMP_ABSOLUTE;
- info.length += RB_LEN_TIME_EXTEND;
- } else {
- add_ts_default = RB_ADD_STAMP_NONE;
- }
+ add_ts_default = RB_ADD_STAMP_NONE;
again:
info.add_timestamp = add_ts_default;
--
2.25.1
Powered by blists - more mailing lists