Daniel Wagner reported to me that readproc.h got deprecated. Also,
while the procps-ng library was available on Fedora, it was not available
on RHEL, which is a piece of evidence that it was not that used.
rtla uses procps-ng only to find the PID of the tracers' workload.
I used the procps-ng library to avoid reinventing the wheel. But in this
case, reinventing the wheel took me less time than the time we already
took trying to work around problems.
Implement a function that reads /proc/ entries, checking if:
- the entry is a directory
- the directory name is composed only of digits (PID)
- the directory contains the comm file
- the comm file contains a comm that matches the tracers'
workload prefix.
- then return true; otherwise, return false.
And use it instead of procps-ng.
Link: https://lkml.kernel.org/r/e8276e122ee9eb2c5a0ba8e673fb6488b924b825.1652423574.git.bristot@kernel.org
Cc: John Kacur <jkacur@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tao Zhou <tao.zhou@linux.dev>
Fixes: b1696371d8
("rtla: Helper functions for rtla")
Reported-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
58 lines
1.3 KiB
C
58 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <stdint.h>
|
|
#include <time.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 set_comm_sched_attr(const char *comm_prefix, struct sched_attr *attr);
|
|
int set_cpu_dma_latency(int32_t latency);
|