Add the support for running timerlat threads in user-space. In this
mode, enabled with -u/--user-threads, timerlat dispatches user-space
processes that will loop in the timerlat_fd, measuring the overhead
for going to user-space and then returning to the kernel - in addition
to the existing measurements.
Here is one example of the tool's output with -u enabled:
$ sudo timerlat top -u -d 600 -q
Timer Latency
0 00:10:01 | IRQ Timer Latency (us) | Thread Timer Latency (us) | Ret user Timer Latency (us)
CPU COUNT | cur min avg max | cur min avg max | cur min avg max
0 #600001 | 0 0 0 3 | 2 1 2 9 | 3 2 3 15
1 #600001 | 0 0 0 2 | 2 1 2 13 | 2 2 3 18
2 #600001 | 0 0 0 10 | 2 1 2 16 | 3 2 3 20
3 #600001 | 0 0 0 7 | 2 1 2 10 | 3 2 3 11
4 #600000 | 0 0 0 16 | 2 1 2 41 | 3 2 3 58
5 #600000 | 0 0 0 3 | 2 1 2 10 | 3 2 3 13
6 #600000 | 0 0 0 5 | 2 1 2 7 | 3 2 3 10
7 #600000 | 0 0 0 1 | 2 1 2 7 | 3 2 3 10
The tuning setup like -p or -C work for the user-space threads as well.
Link: https://lkml.kernel.org/r/758ad2292a0a1d884138d08219e1a0f572d257a2.1686066600.git.bristot@kernel.org
Cc: William White <chwhite@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Tested-by: Juri Lelli <juri.lelli@redhat.com>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
69 lines
1.7 KiB
C
69 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <stdint.h>
|
|
#include <time.h>
|
|
#include <sched.h>
|
|
|
|
/*
|
|
* '18446744073709551615\0'
|
|
*/
|
|
#define BUFF_U64_STR_SIZE 24
|
|
#define MAX_PATH 1024
|
|
|
|
#define container_of(ptr, type, member)({ \
|
|
const typeof(((type *)0)->member) *__mptr = (ptr); \
|
|
(type *)((char *)__mptr - offsetof(type, member)) ; })
|
|
|
|
extern int config_debug;
|
|
void debug_msg(const char *fmt, ...);
|
|
void err_msg(const char *fmt, ...);
|
|
|
|
long parse_seconds_duration(char *val);
|
|
void get_duration(time_t start_time, char *output, int output_size);
|
|
|
|
int parse_cpu_list(char *cpu_list, char **monitored_cpus);
|
|
long long get_llong_from_str(char *start);
|
|
|
|
static inline void
|
|
update_min(unsigned long long *a, unsigned long long *b)
|
|
{
|
|
if (*a > *b)
|
|
*a = *b;
|
|
}
|
|
|
|
static inline void
|
|
update_max(unsigned long long *a, unsigned long long *b)
|
|
{
|
|
if (*a < *b)
|
|
*a = *b;
|
|
}
|
|
|
|
static inline void
|
|
update_sum(unsigned long long *a, unsigned long long *b)
|
|
{
|
|
*a += *b;
|
|
}
|
|
|
|
struct sched_attr {
|
|
uint32_t size;
|
|
uint32_t sched_policy;
|
|
uint64_t sched_flags;
|
|
int32_t sched_nice;
|
|
uint32_t sched_priority;
|
|
uint64_t sched_runtime;
|
|
uint64_t sched_deadline;
|
|
uint64_t sched_period;
|
|
};
|
|
|
|
int parse_prio(char *arg, struct sched_attr *sched_param);
|
|
int parse_cpu_set(char *cpu_list, cpu_set_t *set);
|
|
int __set_sched_attr(int pid, struct sched_attr *attr);
|
|
int set_comm_sched_attr(const char *comm_prefix, struct sched_attr *attr);
|
|
int set_comm_cgroup(const char *comm_prefix, const char *cgroup);
|
|
int set_pid_cgroup(pid_t pid, const char *cgroup);
|
|
int set_cpu_dma_latency(int32_t latency);
|
|
int auto_house_keeping(cpu_set_t *monitored_cpus);
|
|
|
|
#define ns_to_usf(x) (((double)x/1000))
|
|
#define ns_to_per(total, part) ((part * 100) / (double)total)
|