RTEMS 6.1-rc7
Loading...
Searching...
No Matches
profiling.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (c) 2014 embedded brains GmbH & Co. KG
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_SCORE_PROFILING
38#define _RTEMS_SCORE_PROFILING
39
40#include <rtems/score/percpu.h>
41#include <rtems/score/isrlock.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif /* __cplusplus */
46
65static inline void _Profiling_Thread_dispatch_disable(
66 Per_CPU_Control *cpu,
67 uint32_t previous_thread_dispatch_disable_level
68)
69{
70#if defined( RTEMS_PROFILING )
71 if ( previous_thread_dispatch_disable_level == 0 ) {
72 Per_CPU_Stats *stats = &cpu->Stats;
73
74 stats->thread_dispatch_disabled_instant = _CPU_Counter_read();
75 ++stats->thread_dispatch_disabled_count;
76 }
77#else
78 (void) cpu;
79 (void) previous_thread_dispatch_disable_level;
80#endif
81}
82
94static inline void _Profiling_Thread_dispatch_disable_critical(
95 Per_CPU_Control *cpu,
96 uint32_t previous_thread_dispatch_disable_level,
97 const ISR_lock_Context *lock_context
98)
99{
100#if defined( RTEMS_PROFILING )
101 if ( previous_thread_dispatch_disable_level == 0 ) {
102 Per_CPU_Stats *stats = &cpu->Stats;
103
104 stats->thread_dispatch_disabled_instant = lock_context->ISR_disable_instant;
105 ++stats->thread_dispatch_disabled_count;
106 }
107#else
108 (void) cpu;
109 (void) previous_thread_dispatch_disable_level;
110 (void) lock_context;
111#endif
112}
113
123static inline void _Profiling_Thread_dispatch_enable(
124 Per_CPU_Control *cpu,
125 uint32_t new_thread_dispatch_disable_level
126)
127{
128#if defined( RTEMS_PROFILING )
129 if ( new_thread_dispatch_disable_level == 0 ) {
130 Per_CPU_Stats *stats = &cpu->Stats;
131 CPU_Counter_ticks now = _CPU_Counter_read();
132 CPU_Counter_ticks delta = now - stats->thread_dispatch_disabled_instant;
133
134 stats->total_thread_dispatch_disabled_time += delta;
135
136 if ( stats->max_thread_dispatch_disabled_time < delta ) {
137 stats->max_thread_dispatch_disabled_time = delta;
138 }
139 }
140#else
141 (void) cpu;
142 (void) new_thread_dispatch_disable_level;
143#endif
144}
145
152static inline void _Profiling_Update_max_interrupt_delay(
153 Per_CPU_Control *cpu,
154 CPU_Counter_ticks interrupt_delay
155)
156{
157#if defined( RTEMS_PROFILING )
158 Per_CPU_Stats *stats = &cpu->Stats;
159
160 if ( stats->max_interrupt_delay < interrupt_delay ) {
161 stats->max_interrupt_delay = interrupt_delay;
162 }
163#else
164 (void) cpu;
165 (void) interrupt_delay;
166#endif
167}
168
180 Per_CPU_Control *cpu,
181 CPU_Counter_ticks interrupt_entry_instant,
182 CPU_Counter_ticks interrupt_exit_instant
183);
184
187#ifdef __cplusplus
188}
189#endif /* __cplusplus */
190
191#endif /* _RTEMS_SCORE_PROFILING */
CPU_Counter_ticks _CPU_Counter_read(void)
Gets the current CPU counter value.
Definition: system-clocks.c:130
void _Profiling_Outer_most_interrupt_entry_and_exit(Per_CPU_Control *cpu, CPU_Counter_ticks interrupt_entry_instant, CPU_Counter_ticks interrupt_exit_instant)
Updates the interrupt profiling statistics.
Definition: profilingisrentryexit.c:44
This header file provides the interfaces of the ISR Locks.
This header file provides the interfaces of the Per-CPU Information.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:94
Per CPU Core Structure.
Definition: percpu.h:384
Per-CPU statistics.
Definition: percpu.h:272