trace_osnoise.c (0878355b51f5f26632e652c848a8e174bb02d22d) trace_osnoise.c (11e4e3523da98c065a6c249013ace0d388e41c25)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * OS Noise Tracer: computes the OS Noise suffered by a running thread.
4 * Timerlat Tracer: measures the wakeup latency of a timer triggered IRQ and thread.
5 *
6 * Based on "hwlat_detector" tracer by:
7 * Copyright (C) 2008-2009 Jon Masters, Red Hat, Inc. <jcm@redhat.com>
8 * Copyright (C) 2013-2016 Steven Rostedt, Red Hat, Inc. <srostedt@redhat.com>

--- 124 unchanged lines hidden (view full) ---

133 found = 1;
134 break;
135 }
136 }
137
138 if (!found)
139 return;
140
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * OS Noise Tracer: computes the OS Noise suffered by a running thread.
4 * Timerlat Tracer: measures the wakeup latency of a timer triggered IRQ and thread.
5 *
6 * Based on "hwlat_detector" tracer by:
7 * Copyright (C) 2008-2009 Jon Masters, Red Hat, Inc. <jcm@redhat.com>
8 * Copyright (C) 2013-2016 Steven Rostedt, Red Hat, Inc. <srostedt@redhat.com>

--- 124 unchanged lines hidden (view full) ---

133 found = 1;
134 break;
135 }
136 }
137
138 if (!found)
139 return;
140
141 kvfree_rcu(inst);
141 synchronize_rcu();
142 kfree(inst);
142}
143
144/*
145 * NMI runtime info.
146 */
147struct osn_nmi {
148 u64 count;
149 u64 delta_start;

--- 1545 unchanged lines hidden (view full) ---

1695
1696 if (timerlat_enabled()) {
1697 snprintf(comm, 24, "timerlat/%d", cpu);
1698 main = timerlat_main;
1699 } else {
1700 snprintf(comm, 24, "osnoise/%d", cpu);
1701 }
1702
143}
144
145/*
146 * NMI runtime info.
147 */
148struct osn_nmi {
149 u64 count;
150 u64 delta_start;

--- 1545 unchanged lines hidden (view full) ---

1696
1697 if (timerlat_enabled()) {
1698 snprintf(comm, 24, "timerlat/%d", cpu);
1699 main = timerlat_main;
1700 } else {
1701 snprintf(comm, 24, "osnoise/%d", cpu);
1702 }
1703
1703 kthread = kthread_create_on_cpu(main, NULL, cpu, comm);
1704 kthread = kthread_run_on_cpu(main, NULL, cpu, comm);
1704
1705 if (IS_ERR(kthread)) {
1706 pr_err(BANNER "could not start sampling thread\n");
1707 stop_per_cpu_kthreads();
1708 return -ENOMEM;
1709 }
1710
1711 per_cpu(per_cpu_osnoise_var, cpu).kthread = kthread;
1705
1706 if (IS_ERR(kthread)) {
1707 pr_err(BANNER "could not start sampling thread\n");
1708 stop_per_cpu_kthreads();
1709 return -ENOMEM;
1710 }
1711
1712 per_cpu(per_cpu_osnoise_var, cpu).kthread = kthread;
1712 wake_up_process(kthread);
1713
1714 return 0;
1715}
1716
1717/*
1718 * start_per_cpu_kthread - Kick off per-cpu osnoise sampling kthreads
1719 *
1720 * This starts the kernel thread that will look for osnoise on many

--- 396 unchanged lines hidden (view full) ---

2117 return 0;
2118
2119 unhook_softirq_events();
2120out_unhook_irq:
2121 unhook_irq_events();
2122 return -EINVAL;
2123}
2124
1713
1714 return 0;
1715}
1716
1717/*
1718 * start_per_cpu_kthread - Kick off per-cpu osnoise sampling kthreads
1719 *
1720 * This starts the kernel thread that will look for osnoise on many

--- 396 unchanged lines hidden (view full) ---

2117 return 0;
2118
2119 unhook_softirq_events();
2120out_unhook_irq:
2121 unhook_irq_events();
2122 return -EINVAL;
2123}
2124
2125static void osnoise_unhook_events(void)
2126{
2127 unhook_thread_events();
2128 unhook_softirq_events();
2129 unhook_irq_events();
2130}
2131
2132/*
2133 * osnoise_workload_start - start the workload and hook to events
2134 */
2135static int osnoise_workload_start(void)
2136{
2137 int retval;
2138
2139 /*

--- 16 unchanged lines hidden (view full) ---

2156 * Make sure that ftrace_nmi_enter/exit() see reset values
2157 * before enabling trace_osnoise_callback_enabled.
2158 */
2159 barrier();
2160 trace_osnoise_callback_enabled = true;
2161
2162 retval = start_per_cpu_kthreads();
2163 if (retval) {
2125/*
2126 * osnoise_workload_start - start the workload and hook to events
2127 */
2128static int osnoise_workload_start(void)
2129{
2130 int retval;
2131
2132 /*

--- 16 unchanged lines hidden (view full) ---

2149 * Make sure that ftrace_nmi_enter/exit() see reset values
2150 * before enabling trace_osnoise_callback_enabled.
2151 */
2152 barrier();
2153 trace_osnoise_callback_enabled = true;
2154
2155 retval = start_per_cpu_kthreads();
2156 if (retval) {
2164 trace_osnoise_callback_enabled = false;
2165 /*
2166 * Make sure that ftrace_nmi_enter/exit() see
2167 * trace_osnoise_callback_enabled as false before continuing.
2168 */
2169 barrier();
2170
2171 osnoise_unhook_events();
2157 unhook_irq_events();
2172 return retval;
2173 }
2174
2175 return 0;
2176}
2177
2178/*
2179 * osnoise_workload_stop - stop the workload and unhook the events

--- 14 unchanged lines hidden (view full) ---

2194 /*
2195 * Make sure that ftrace_nmi_enter/exit() see
2196 * trace_osnoise_callback_enabled as false before continuing.
2197 */
2198 barrier();
2199
2200 stop_per_cpu_kthreads();
2201
2158 return retval;
2159 }
2160
2161 return 0;
2162}
2163
2164/*
2165 * osnoise_workload_stop - stop the workload and unhook the events

--- 14 unchanged lines hidden (view full) ---

2180 /*
2181 * Make sure that ftrace_nmi_enter/exit() see
2182 * trace_osnoise_callback_enabled as false before continuing.
2183 */
2184 barrier();
2185
2186 stop_per_cpu_kthreads();
2187
2202 osnoise_unhook_events();
2188 unhook_irq_events();
2189 unhook_softirq_events();
2190 unhook_thread_events();
2203}
2204
2205static void osnoise_tracer_start(struct trace_array *tr)
2206{
2207 int retval;
2208
2209 /*
2210 * If the instance is already registered, there is no need to

--- 169 unchanged lines hidden ---
2191}
2192
2193static void osnoise_tracer_start(struct trace_array *tr)
2194{
2195 int retval;
2196
2197 /*
2198 * If the instance is already registered, there is no need to

--- 169 unchanged lines hidden ---