From nobody Sun May 10 17:52:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CFACC433F5 for ; Thu, 28 Apr 2022 21:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352627AbiD1Vzl (ORCPT ); Thu, 28 Apr 2022 17:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352564AbiD1Vy7 (ORCPT ); Thu, 28 Apr 2022 17:54:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2E9E33886 for ; Thu, 28 Apr 2022 14:51:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4916AB83035 for ; Thu, 28 Apr 2022 21:51:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FABDC385B1; Thu, 28 Apr 2022 21:51:41 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nkC32-003MYb-1x; Thu, 28 Apr 2022 17:51:40 -0400 Message-ID: <20220428215139.888187334@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 28 Apr 2022 17:51:03 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Tom Zanussi , Thomas Gleixner , Kurt Kanzenbach Subject: [for-next][PATCH 1/8] ring-buffer: Have absolute time stamps handle large numbers References: <20220428215102.260147624@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" There's an absolute timestamp event in the ring buffer, but this only saves 59 bits of the timestamp, as the 5 MSB is used for meta data (stating it is an absolute time stamp). This was never an issue as all the clocks currently in use never used those 5 MSB. But now there's a new clock (TAI) that does. To handle this case, when reading an absolute timestamp, a previous full timestamp is passed in, and the 5 MSB of that timestamp is OR'd to the absolute timestamp (if any of the 5 MSB are set), and then to test for overflow, if the new result is smaller than the passed in previous timestamp, then 1 << 59 is added to it. All the extra processing is done on the reader "slow" path, with the exception of the "too big delta" check, and the reading of timestamps for histograms. Note, libtraceevent will need to be updated to handle this case as well. But this is not a user space regression, as user space was never able to handle any timestamps that used more than 59 bits. Link: https://lore.kernel.org/all/20220426175338.3807ca4f@gandalf.local.hom= e/ Link: https://lkml.kernel.org/r/20220427153339.16c33f75@gandalf.local.home Cc: Tom Zanussi Cc: Thomas Gleixner Cc: Kurt Kanzenbach Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ring_buffer.c | 49 ++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 655d6db3e3c3..3a0c7ed0e93f 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -29,6 +29,14 @@ =20 #include =20 +/* + * The "absolute" timestamp in the buffer is only 59 bits. + * If a clock has the 5 MSBs set, it needs to be saved and + * reinserted. + */ +#define TS_MSB (0xf8ULL << 56) +#define ABS_TS_MASK (~TS_MSB) + static void update_pages_handler(struct work_struct *work); =20 /* @@ -783,6 +791,24 @@ static inline void verify_event(struct ring_buffer_per= _cpu *cpu_buffer, } #endif =20 +/* + * The absolute time stamp drops the 5 MSBs and some clocks may + * require them. The rb_fix_abs_ts() will take a previous full + * time stamp, and add the 5 MSB of that time stamp on to the + * saved absolute time stamp. Then they are compared in case of + * the unlikely event that the latest time stamp incremented + * the 5 MSB. + */ +static inline u64 rb_fix_abs_ts(u64 abs, u64 save_ts) +{ + if (save_ts & TS_MSB) { + abs |=3D save_ts & TS_MSB; + /* Check for overflow */ + if (unlikely(abs < save_ts)) + abs +=3D 1ULL << 59; + } + return abs; +} =20 static inline u64 rb_time_stamp(struct trace_buffer *buffer); =20 @@ -811,8 +837,10 @@ u64 ring_buffer_event_time_stamp(struct trace_buffer *= buffer, u64 ts; =20 /* If the event includes an absolute time, then just use that */ - if (event->type_len =3D=3D RINGBUF_TYPE_TIME_STAMP) - return rb_event_time_stamp(event); + if (event->type_len =3D=3D RINGBUF_TYPE_TIME_STAMP) { + ts =3D rb_event_time_stamp(event); + return rb_fix_abs_ts(ts, cpu_buffer->tail_page->page->time_stamp); + } =20 nest =3D local_read(&cpu_buffer->committing); verify_event(cpu_buffer, event); @@ -2754,8 +2782,15 @@ static void rb_add_timestamp(struct ring_buffer_per_= cpu *cpu_buffer, (RB_ADD_STAMP_FORCE | RB_ADD_STAMP_ABSOLUTE); =20 if (unlikely(info->delta > (1ULL << 59))) { + /* + * Some timers can use more than 59 bits, and when a timestamp + * is added to the buffer, it will lose those bits. + */ + if (abs && (info->ts & TS_MSB)) { + info->delta &=3D ABS_TS_MASK; + /* did the clock go backwards */ - if (info->before =3D=3D info->after && info->before > info->ts) { + } else if (info->before =3D=3D info->after && info->before > info->ts) { /* not interrupted */ static int once; =20 @@ -3304,7 +3339,7 @@ static void dump_buffer_page(struct buffer_data_page = *bpage, =20 case RINGBUF_TYPE_TIME_STAMP: delta =3D rb_event_time_stamp(event); - ts =3D delta; + ts =3D rb_fix_abs_ts(delta, ts); pr_warn(" [%lld] absolute:%lld TIME STAMP\n", ts, delta); break; =20 @@ -3380,7 +3415,7 @@ static void check_buffer(struct ring_buffer_per_cpu *= cpu_buffer, =20 case RINGBUF_TYPE_TIME_STAMP: delta =3D rb_event_time_stamp(event); - ts =3D delta; + ts =3D rb_fix_abs_ts(delta, ts); break; =20 case RINGBUF_TYPE_PADDING: @@ -4367,6 +4402,7 @@ rb_update_read_stamp(struct ring_buffer_per_cpu *cpu_= buffer, =20 case RINGBUF_TYPE_TIME_STAMP: delta =3D rb_event_time_stamp(event); + delta =3D rb_fix_abs_ts(delta, cpu_buffer->read_stamp); cpu_buffer->read_stamp =3D delta; return; =20 @@ -4397,6 +4433,7 @@ rb_update_iter_read_stamp(struct ring_buffer_iter *it= er, =20 case RINGBUF_TYPE_TIME_STAMP: delta =3D rb_event_time_stamp(event); + delta =3D rb_fix_abs_ts(delta, iter->read_stamp); iter->read_stamp =3D delta; return; =20 @@ -4650,6 +4687,7 @@ rb_buffer_peek(struct ring_buffer_per_cpu *cpu_buffer= , u64 *ts, case RINGBUF_TYPE_TIME_STAMP: if (ts) { *ts =3D rb_event_time_stamp(event); + *ts =3D rb_fix_abs_ts(*ts, reader->page->time_stamp); ring_buffer_normalize_time_stamp(cpu_buffer->buffer, cpu_buffer->cpu, ts); } @@ -4741,6 +4779,7 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts) case RINGBUF_TYPE_TIME_STAMP: if (ts) { *ts =3D rb_event_time_stamp(event); + *ts =3D rb_fix_abs_ts(*ts, iter->head_page->page->time_stamp); ring_buffer_normalize_time_stamp(cpu_buffer->buffer, cpu_buffer->cpu, ts); } --=20 2.35.1 From nobody Sun May 10 17:52:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06F27C433F5 for ; Thu, 28 Apr 2022 21:51:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350252AbiD1VzJ (ORCPT ); Thu, 28 Apr 2022 17:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344429AbiD1Vy6 (ORCPT ); Thu, 28 Apr 2022 17:54:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DDB01C131 for ; Thu, 28 Apr 2022 14:51:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CE20561F14 for ; Thu, 28 Apr 2022 21:51:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 438C3C385AE; Thu, 28 Apr 2022 21:51:41 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nkC32-003MZA-7q; Thu, 28 Apr 2022 17:51:40 -0400 Message-ID: <20220428215140.077110408@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 28 Apr 2022 17:51:04 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton Subject: [for-next][PATCH 2/8] ring-buffer: Have 32 bit time stamps use all 64 bits References: <20220428215102.260147624@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" When the new logic was made to handle deltas of events from interrupts that interrupted other events, it required 64 bit local atomics. Unfortunately, 64 bit local atomics are expensive on 32 bit architectures. Thus, commit 10464b4aa605e ("ring-buffer: Add rb_time_t 64 bit operations for speeding up 32 bit") created a type of seq lock timer for 32 bits. It used two 32 bit local atomics, but required 2 bits from them each for synchronization, making it only 60 bits. Add a new "msb" field to hold the extra 4 bits that are cut off. Link: https://lore.kernel.org/all/20220426175338.3807ca4f@gandalf.local.hom= e/ Link: https://lkml.kernel.org/r/20220427170812.53cc7139@gandalf.local.home Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ring_buffer.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 3a0c7ed0e93f..d59b6a328b7f 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -476,6 +476,7 @@ struct rb_time_struct { local_t cnt; local_t top; local_t bottom; + local_t msb; }; #else #include @@ -577,7 +578,6 @@ struct ring_buffer_iter { * For the ring buffer, 64 bit required operations for the time is * the following: * - * - Only need 59 bits (uses 60 to make it even). * - Reads may fail if it interrupted a modification of the time stamp. * It will succeed if it did not interrupt another write even if * the read itself is interrupted by a write. @@ -602,6 +602,7 @@ struct ring_buffer_iter { */ #define RB_TIME_SHIFT 30 #define RB_TIME_VAL_MASK ((1 << RB_TIME_SHIFT) - 1) +#define RB_TIME_MSB_SHIFT 60 =20 static inline int rb_time_cnt(unsigned long val) { @@ -621,7 +622,7 @@ static inline u64 rb_time_val(unsigned long top, unsign= ed long bottom) =20 static inline bool __rb_time_read(rb_time_t *t, u64 *ret, unsigned long *c= nt) { - unsigned long top, bottom; + unsigned long top, bottom, msb; unsigned long c; =20 /* @@ -633,6 +634,7 @@ static inline bool __rb_time_read(rb_time_t *t, u64 *re= t, unsigned long *cnt) c =3D local_read(&t->cnt); top =3D local_read(&t->top); bottom =3D local_read(&t->bottom); + msb =3D local_read(&t->msb); } while (c !=3D local_read(&t->cnt)); =20 *cnt =3D rb_time_cnt(top); @@ -641,7 +643,8 @@ static inline bool __rb_time_read(rb_time_t *t, u64 *re= t, unsigned long *cnt) if (*cnt !=3D rb_time_cnt(bottom)) return false; =20 - *ret =3D rb_time_val(top, bottom); + /* The shift to msb will lose its cnt bits */ + *ret =3D rb_time_val(top, bottom) | ((u64)msb << RB_TIME_MSB_SHIFT); return true; } =20 @@ -657,10 +660,12 @@ static inline unsigned long rb_time_val_cnt(unsigned = long val, unsigned long cnt return (val & RB_TIME_VAL_MASK) | ((cnt & 3) << RB_TIME_SHIFT); } =20 -static inline void rb_time_split(u64 val, unsigned long *top, unsigned lon= g *bottom) +static inline void rb_time_split(u64 val, unsigned long *top, unsigned lon= g *bottom, + unsigned long *msb) { *top =3D (unsigned long)((val >> RB_TIME_SHIFT) & RB_TIME_VAL_MASK); *bottom =3D (unsigned long)(val & RB_TIME_VAL_MASK); + *msb =3D (unsigned long)(val >> RB_TIME_MSB_SHIFT); } =20 static inline void rb_time_val_set(local_t *t, unsigned long val, unsigned= long cnt) @@ -671,15 +676,16 @@ static inline void rb_time_val_set(local_t *t, unsign= ed long val, unsigned long =20 static void rb_time_set(rb_time_t *t, u64 val) { - unsigned long cnt, top, bottom; + unsigned long cnt, top, bottom, msb; =20 - rb_time_split(val, &top, &bottom); + rb_time_split(val, &top, &bottom, &msb); =20 /* Writes always succeed with a valid number even if it gets interrupted.= */ do { cnt =3D local_inc_return(&t->cnt); rb_time_val_set(&t->top, top, cnt); rb_time_val_set(&t->bottom, bottom, cnt); + rb_time_val_set(&t->msb, val >> RB_TIME_MSB_SHIFT, cnt); } while (cnt !=3D local_read(&t->cnt)); } =20 @@ -694,8 +700,8 @@ rb_time_read_cmpxchg(local_t *l, unsigned long expect, = unsigned long set) =20 static int rb_time_cmpxchg(rb_time_t *t, u64 expect, u64 set) { - unsigned long cnt, top, bottom; - unsigned long cnt2, top2, bottom2; + unsigned long cnt, top, bottom, msb; + unsigned long cnt2, top2, bottom2, msb2; u64 val; =20 /* The cmpxchg always fails if it interrupted an update */ @@ -711,16 +717,18 @@ static int rb_time_cmpxchg(rb_time_t *t, u64 expect, = u64 set) =20 cnt2 =3D cnt + 1; =20 - rb_time_split(val, &top, &bottom); + rb_time_split(val, &top, &bottom, &msb); top =3D rb_time_val_cnt(top, cnt); bottom =3D rb_time_val_cnt(bottom, cnt); =20 - rb_time_split(set, &top2, &bottom2); + rb_time_split(set, &top2, &bottom2, &msb2); top2 =3D rb_time_val_cnt(top2, cnt2); bottom2 =3D rb_time_val_cnt(bottom2, cnt2); =20 if (!rb_time_read_cmpxchg(&t->cnt, cnt, cnt2)) return false; + if (!rb_time_read_cmpxchg(&t->msb, msb, msb2)) + return false; if (!rb_time_read_cmpxchg(&t->top, top, top2)) return false; if (!rb_time_read_cmpxchg(&t->bottom, bottom, bottom2)) --=20 2.35.1 From nobody Sun May 10 17:52:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD153C433EF for ; Thu, 28 Apr 2022 21:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352607AbiD1VzM (ORCPT ); Thu, 28 Apr 2022 17:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346726AbiD1Vy6 (ORCPT ); Thu, 28 Apr 2022 17:54:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 955F926101 for ; Thu, 28 Apr 2022 14:51:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 103B662006 for ; Thu, 28 Apr 2022 21:51:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76D80C385B5; Thu, 28 Apr 2022 21:51:41 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nkC32-003MZi-DY; Thu, 28 Apr 2022 17:51:40 -0400 Message-ID: <20220428215140.258564440@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 28 Apr 2022 17:51:05 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Kurt Kanzenbach Subject: [for-next][PATCH 3/8] tracing: Introduce trace clock tai References: <20220428215102.260147624@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kurt Kanzenbach A fast/NMI safe accessor for CLOCK_TAI has been introduced. Use it for adding the additional trace clock "tai". Link: https://lkml.kernel.org/r/20220414091805.89667-3-kurt@linutronix.de Signed-off-by: Kurt Kanzenbach Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 400d3e9fe9ff..087740f63d92 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -1542,6 +1542,7 @@ static struct { { ktime_get_mono_fast_ns, "mono", 1 }, { ktime_get_raw_fast_ns, "mono_raw", 1 }, { ktime_get_boot_fast_ns, "boot", 1 }, + { ktime_get_tai_fast_ns, "tai", 1 }, ARCH_TRACE_CLOCKS }; =20 --=20 2.35.1 From nobody Sun May 10 17:52:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCFCEC433F5 for ; Thu, 28 Apr 2022 21:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352682AbiD1Vzq (ORCPT ); Thu, 28 Apr 2022 17:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237165AbiD1Vy6 (ORCPT ); Thu, 28 Apr 2022 17:54:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9465221E3B for ; Thu, 28 Apr 2022 14:51:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1AC0461FB9 for ; Thu, 28 Apr 2022 21:51:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 809CAC385B9; Thu, 28 Apr 2022 21:51:41 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nkC32-003MaG-Jh; Thu, 28 Apr 2022 17:51:40 -0400 Message-ID: <20220428215140.438634489@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 28 Apr 2022 17:51:06 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Kurt Kanzenbach Subject: [for-next][PATCH 4/8] tracing: Add documentation for trace clock tai References: <20220428215102.260147624@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kurt Kanzenbach Add documentation for newly introduced trace clock "tai". This clock corresponds to CLOCK_TAI. Link: https://lkml.kernel.org/r/20220414091805.89667-4-kurt@linutronix.de Signed-off-by: Kurt Kanzenbach Signed-off-by: Steven Rostedt (Google) --- Documentation/trace/ftrace.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst index 45b8c56af67a..b37dc19e4d40 100644 --- a/Documentation/trace/ftrace.rst +++ b/Documentation/trace/ftrace.rst @@ -517,6 +517,18 @@ of ftrace. Here is a list of some of the key files: processing should be able to handle them. See comments in the ktime_get_boot_fast_ns() function for more information. =20 + tai: + This is the tai clock (CLOCK_TAI) and is derived from the wall- + clock time. However, this clock does not experience + discontinuities and backwards jumps caused by NTP inserting leap + seconds. Since the clock access is designed for use in tracing, + side effects are possible. The clock access may yield wrong + readouts in case the internal TAI offset is updated e.g., caused + by setting the system time or using adjtimex() with an offset. + These effects are rare and post processing should be able to + handle them. See comments in the ktime_get_tai_fast_ns() + function for more information. + To set a clock, simply echo the clock name into this file:: =20 # echo global > trace_clock --=20 2.35.1 From nobody Sun May 10 17:52:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71172C433EF for ; Thu, 28 Apr 2022 21:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350837AbiD1VzG (ORCPT ); Thu, 28 Apr 2022 17:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344513AbiD1VzB (ORCPT ); Thu, 28 Apr 2022 17:55:01 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B8546162 for ; Thu, 28 Apr 2022 14:51:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 8D4B8CE2D7A for ; Thu, 28 Apr 2022 21:51:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB35AC385B3; Thu, 28 Apr 2022 21:51:41 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nkC32-003Mao-PY; Thu, 28 Apr 2022 17:51:40 -0400 Message-ID: <20220428215140.625844927@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 28 Apr 2022 17:51:07 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Ingo Molnar , Jakob Koschel Subject: [for-next][PATCH 5/8] tracing: Remove usage of list iterator after the loop body References: <20220428215102.260147624@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakob Koschel In preparation to limit the scope of the list iterator variable to the traversal loop, use a dedicated pointer to point to the found element [1]. Before, the code implicitly used the head when no element was found when using &pos->list. Since the new variable is only set if an element was found, the head needs to be used explicitly if the variable is NULL. Link: https://lkml.kernel.org/r/20220427170734.819891-2-jakobkoschel@gmail.= com Cc: Ingo Molnar Link: https://lore.kernel.org/all/CAHk-=3DwgRr_D8CB-D9Kg-c=3DEHreAsk5SqXPwr= 9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_output.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index d89e3f7e26eb..67f47ea27921 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -692,7 +692,7 @@ static LIST_HEAD(ftrace_event_list); =20 static int trace_search_list(struct list_head **list) { - struct trace_event *e; + struct trace_event *e =3D NULL, *iter; int next =3D __TRACE_LAST_TYPE; =20 if (list_empty(&ftrace_event_list)) { @@ -704,9 +704,11 @@ static int trace_search_list(struct list_head **list) * We used up all possible max events, * lets see if somebody freed one. */ - list_for_each_entry(e, &ftrace_event_list, list) { - if (e->type !=3D next) + list_for_each_entry(iter, &ftrace_event_list, list) { + if (iter->type !=3D next) { + e =3D iter; break; + } next++; } =20 @@ -714,7 +716,10 @@ static int trace_search_list(struct list_head **list) if (next > TRACE_EVENT_TYPE_MAX) return 0; =20 - *list =3D &e->list; + if (e) + *list =3D &e->list; + else + *list =3D &ftrace_event_list; return next; } =20 --=20 2.35.1 From nobody Sun May 10 17:52:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4503C433F5 for ; Thu, 28 Apr 2022 21:52:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347549AbiD1VzY (ORCPT ); Thu, 28 Apr 2022 17:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352598AbiD1Vy7 (ORCPT ); Thu, 28 Apr 2022 17:54:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 775E8340FA for ; Thu, 28 Apr 2022 14:51:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 28BEDB83079 for ; Thu, 28 Apr 2022 21:51:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D32C7C385BB; Thu, 28 Apr 2022 21:51:41 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nkC32-003MbM-VP; Thu, 28 Apr 2022 17:51:40 -0400 Message-ID: <20220428215140.807739542@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 28 Apr 2022 17:51:08 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Ingo Molnar , Jakob Koschel Subject: [for-next][PATCH 6/8] tracing: Remove usage of list iterator variable after the loop References: <20220428215102.260147624@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakob Koschel In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. Link: https://lore.kernel.org/all/CAHk-=3DwgRr_D8CB-D9Kg-c=3DEHreAsk5SqXPwr= 9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Link: https://lkml.kernel.org/r/20220427170734.819891-3-jakobkoschel@gmail.= com Cc: Ingo Molnar Signed-off-by: Jakob Koschel Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index e11e167b7809..e4a442060707 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1723,9 +1723,9 @@ static LIST_HEAD(event_subsystems); =20 static int subsystem_open(struct inode *inode, struct file *filp) { + struct trace_subsystem_dir *dir =3D NULL, *iter_dir; + struct trace_array *tr =3D NULL, *iter_tr; struct event_subsystem *system =3D NULL; - struct trace_subsystem_dir *dir =3D NULL; /* Initialize for gcc */ - struct trace_array *tr; int ret; =20 if (tracing_is_disabled()) @@ -1734,10 +1734,12 @@ static int subsystem_open(struct inode *inode, stru= ct file *filp) /* Make sure the system still exists */ mutex_lock(&event_mutex); mutex_lock(&trace_types_lock); - list_for_each_entry(tr, &ftrace_trace_arrays, list) { - list_for_each_entry(dir, &tr->systems, list) { - if (dir =3D=3D inode->i_private) { + list_for_each_entry(iter_tr, &ftrace_trace_arrays, list) { + list_for_each_entry(iter_dir, &iter_tr->systems, list) { + if (iter_dir =3D=3D inode->i_private) { /* Don't open systems with no events */ + tr =3D iter_tr; + dir =3D iter_dir; if (dir->nr_events) { __get_system_dir(dir); system =3D dir->subsystem; @@ -1753,9 +1755,6 @@ static int subsystem_open(struct inode *inode, struct= file *filp) if (!system) return -ENODEV; =20 - /* Some versions of gcc think dir can be uninitialized here */ - WARN_ON(!dir); - /* Still need to increment the ref count of the system */ if (trace_array_get(tr) < 0) { put_system(dir); --=20 2.35.1 From nobody Sun May 10 17:52:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B643C433EF for ; Thu, 28 Apr 2022 21:52:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352681AbiD1VzU (ORCPT ); Thu, 28 Apr 2022 17:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352489AbiD1Vy7 (ORCPT ); Thu, 28 Apr 2022 17:54:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BCA82C121 for ; Thu, 28 Apr 2022 14:51:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A1F016200C for ; Thu, 28 Apr 2022 21:51:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17965C385BE; Thu, 28 Apr 2022 21:51:42 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nkC33-003Mbu-4w; Thu, 28 Apr 2022 17:51:41 -0400 Message-ID: <20220428215140.989667850@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 28 Apr 2022 17:51:09 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Ingo Molnar , Jakob Koschel Subject: [for-next][PATCH 7/8] tracing: Replace usage of found with dedicated list iterator variable References: <20220428215102.260147624@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakob Koschel To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1]. This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit. Link: https://lkml.kernel.org/r/20220427170734.819891-4-jakobkoschel@gmail.= com Cc: Ingo Molnar Link: https://lore.kernel.org/all/CAHk-=3DwgRr_D8CB-D9Kg-c=3DEHreAsk5SqXPwr= 9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_hist.c | 15 +++++++-------- kernel/trace/trace_events_trigger.c | 24 +++++++++++------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_h= ist.c index fe10179893c1..038dc591545d 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -6117,20 +6117,19 @@ static void hist_unregister_trigger(char *glob, struct event_trigger_data *data, struct trace_event_file *file) { + struct event_trigger_data *test =3D NULL, *iter, *named_data =3D NULL; struct hist_trigger_data *hist_data =3D data->private_data; - struct event_trigger_data *test, *named_data =3D NULL; - bool unregistered =3D false; =20 lockdep_assert_held(&event_mutex); =20 if (hist_data->attrs->name) named_data =3D find_named_trigger(hist_data->attrs->name); =20 - list_for_each_entry(test, &file->triggers, list) { - if (test->cmd_ops->trigger_type =3D=3D ETT_EVENT_HIST) { - if (!hist_trigger_match(data, test, named_data, false)) + list_for_each_entry(iter, &file->triggers, list) { + if (iter->cmd_ops->trigger_type =3D=3D ETT_EVENT_HIST) { + if (!hist_trigger_match(data, iter, named_data, false)) continue; - unregistered =3D true; + test =3D iter; list_del_rcu(&test->list); trace_event_trigger_enable_disable(file, 0); update_cond_flag(file); @@ -6138,11 +6137,11 @@ static void hist_unregister_trigger(char *glob, } } =20 - if (unregistered && test->ops->free) + if (test && test->ops->free) test->ops->free(test); =20 if (hist_data->enable_timestamps) { - if (!hist_data->remove || unregistered) + if (!hist_data->remove || test) tracing_set_filter_buffering(file->tr, false); } } diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_event= s_trigger.c index 62c44dab8f46..21592bed2e89 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -609,14 +609,13 @@ static void unregister_trigger(char *glob, struct event_trigger_data *test, struct trace_event_file *file) { - struct event_trigger_data *data; - bool unregistered =3D false; + struct event_trigger_data *data =3D NULL, *iter; =20 lockdep_assert_held(&event_mutex); =20 - list_for_each_entry(data, &file->triggers, list) { - if (data->cmd_ops->trigger_type =3D=3D test->cmd_ops->trigger_type) { - unregistered =3D true; + list_for_each_entry(iter, &file->triggers, list) { + if (iter->cmd_ops->trigger_type =3D=3D test->cmd_ops->trigger_type) { + data =3D iter; list_del_rcu(&data->list); trace_event_trigger_enable_disable(file, 0); update_cond_flag(file); @@ -624,7 +623,7 @@ static void unregister_trigger(char *glob, } } =20 - if (unregistered && data->ops->free) + if (data && data->ops->free) data->ops->free(data); } =20 @@ -1870,19 +1869,18 @@ void event_enable_unregister_trigger(char *glob, struct trace_event_file *file) { struct enable_trigger_data *test_enable_data =3D test->private_data; + struct event_trigger_data *data =3D NULL, *iter; struct enable_trigger_data *enable_data; - struct event_trigger_data *data; - bool unregistered =3D false; =20 lockdep_assert_held(&event_mutex); =20 - list_for_each_entry(data, &file->triggers, list) { - enable_data =3D data->private_data; + list_for_each_entry(iter, &file->triggers, list) { + enable_data =3D iter->private_data; if (enable_data && - (data->cmd_ops->trigger_type =3D=3D + (iter->cmd_ops->trigger_type =3D=3D test->cmd_ops->trigger_type) && (enable_data->file =3D=3D test_enable_data->file)) { - unregistered =3D true; + data =3D iter; list_del_rcu(&data->list); trace_event_trigger_enable_disable(file, 0); update_cond_flag(file); @@ -1890,7 +1888,7 @@ void event_enable_unregister_trigger(char *glob, } } =20 - if (unregistered && data->ops->free) + if (data && data->ops->free) data->ops->free(data); } =20 --=20 2.35.1 From nobody Sun May 10 17:52:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5504C433EF for ; Thu, 28 Apr 2022 21:52:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352635AbiD1VzR (ORCPT ); Thu, 28 Apr 2022 17:55:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351789AbiD1Vy7 (ORCPT ); Thu, 28 Apr 2022 17:54:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BDDC2E0AB for ; Thu, 28 Apr 2022 14:51:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B292062008 for ; Thu, 28 Apr 2022 21:51:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D9A2C385C0; Thu, 28 Apr 2022 21:51:42 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nkC33-003McU-Aw; Thu, 28 Apr 2022 17:51:41 -0400 Message-ID: <20220428215141.173085779@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 28 Apr 2022 17:51:10 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Ingo Molnar , Jakob Koschel Subject: [for-next][PATCH 8/8] tracing: Remove check of list iterator against head past the loop body References: <20220428215102.260147624@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakob Koschel When list_for_each_entry() completes the iteration over the whole list without breaking the loop, the iterator value will be a bogus pointer computed based on the head element. While it is safe to use the pointer to determine if it was computed based on the head element, either with list_entry_is_head() or &pos->member =3D=3D head, using the iterator variable after the loop should be avoided. In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. Link: https://lkml.kernel.org/r/20220427170734.819891-5-jakobkoschel@gmail.= com Cc: Ingo Molnar Link: https://lore.kernel.org/all/CAHk-=3DwgRr_D8CB-D9Kg-c=3DEHreAsk5SqXPwr= 9Y7k9sA6cWXJ6w@mail.gmail.com/ Signed-off-by: Jakob Koschel Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 20 ++++++++++++-------- kernel/trace/trace_eprobe.c | 14 ++++++++------ kernel/trace/trace_events.c | 12 ++++++------ 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4f1d2f5e7263..5c465e70d146 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -4560,8 +4560,8 @@ register_ftrace_function_probe(char *glob, struct tra= ce_array *tr, struct ftrace_probe_ops *probe_ops, void *data) { + struct ftrace_func_probe *probe =3D NULL, *iter; struct ftrace_func_entry *entry; - struct ftrace_func_probe *probe; struct ftrace_hash **orig_hash; struct ftrace_hash *old_hash; struct ftrace_hash *hash; @@ -4580,11 +4580,13 @@ register_ftrace_function_probe(char *glob, struct t= race_array *tr, =20 mutex_lock(&ftrace_lock); /* Check if the probe_ops is already registered */ - list_for_each_entry(probe, &tr->func_probes, list) { - if (probe->probe_ops =3D=3D probe_ops) + list_for_each_entry(iter, &tr->func_probes, list) { + if (iter->probe_ops =3D=3D probe_ops) { + probe =3D iter; break; + } } - if (&probe->list =3D=3D &tr->func_probes) { + if (!probe) { probe =3D kzalloc(sizeof(*probe), GFP_KERNEL); if (!probe) { mutex_unlock(&ftrace_lock); @@ -4702,9 +4704,9 @@ int unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr, struct ftrace_probe_ops *probe_ops) { + struct ftrace_func_probe *probe =3D NULL, *iter; struct ftrace_ops_hash old_hash_ops; struct ftrace_func_entry *entry; - struct ftrace_func_probe *probe; struct ftrace_glob func_g; struct ftrace_hash **orig_hash; struct ftrace_hash *old_hash; @@ -4732,11 +4734,13 @@ unregister_ftrace_function_probe_func(char *glob, s= truct trace_array *tr, =20 mutex_lock(&ftrace_lock); /* Check if the probe_ops is already registered */ - list_for_each_entry(probe, &tr->func_probes, list) { - if (probe->probe_ops =3D=3D probe_ops) + list_for_each_entry(iter, &tr->func_probes, list) { + if (iter->probe_ops =3D=3D probe_ops) { + probe =3D iter; break; + } } - if (&probe->list =3D=3D &tr->func_probes) + if (!probe) goto err_unlock_ftrace; =20 ret =3D -EINVAL; diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c index b045fa9f276c..7d4478525c66 100644 --- a/kernel/trace/trace_eprobe.c +++ b/kernel/trace/trace_eprobe.c @@ -648,7 +648,7 @@ static struct trace_event_functions eprobe_funcs =3D { static int disable_eprobe(struct trace_eprobe *ep, struct trace_array *tr) { - struct event_trigger_data *trigger; + struct event_trigger_data *trigger =3D NULL, *iter; struct trace_event_file *file; struct eprobe_data *edata; =20 @@ -656,14 +656,16 @@ static int disable_eprobe(struct trace_eprobe *ep, if (!file) return -ENOENT; =20 - list_for_each_entry(trigger, &file->triggers, list) { - if (!(trigger->flags & EVENT_TRIGGER_FL_PROBE)) + list_for_each_entry(iter, &file->triggers, list) { + if (!(iter->flags & EVENT_TRIGGER_FL_PROBE)) continue; - edata =3D trigger->private_data; - if (edata->ep =3D=3D ep) + edata =3D iter->private_data; + if (edata->ep =3D=3D ep) { + trigger =3D iter; break; + } } - if (list_entry_is_head(trigger, &file->triggers, list)) + if (!trigger) return -ENODEV; =20 list_del_rcu(&trigger->list); diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index e4a442060707..78f313b7b315 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2279,8 +2279,8 @@ static struct dentry * event_subsystem_dir(struct trace_array *tr, const char *name, struct trace_event_file *file, struct dentry *parent) { + struct event_subsystem *system, *iter; struct trace_subsystem_dir *dir; - struct event_subsystem *system; struct dentry *entry; =20 /* First see if we did not already create this dir */ @@ -2294,13 +2294,13 @@ event_subsystem_dir(struct trace_array *tr, const c= har *name, } =20 /* Now see if the system itself exists. */ - list_for_each_entry(system, &event_subsystems, list) { - if (strcmp(system->name, name) =3D=3D 0) + system =3D NULL; + list_for_each_entry(iter, &event_subsystems, list) { + if (strcmp(iter->name, name) =3D=3D 0) { + system =3D iter; break; + } } - /* Reset system variable when not found */ - if (&system->list =3D=3D &event_subsystems) - system =3D NULL; =20 dir =3D kmalloc(sizeof(*dir), GFP_KERNEL); if (!dir) --=20 2.35.1