mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-14 03:46:41 +07:00
4449bf927b
Being able to show a cpumask of events can be useful as some events may affect only some CPUs. There is no standard way to record the cpumask and converting it to a string is rather expensive during the trace as traces happen in hotpaths. It would be better to record the raw event mask and be able to parse it at print time. The following macros were added for use with the TRACE_EVENT() macro: __bitmask() __assign_bitmask() __get_bitmask() To test this, I added this to the sched_migrate_task event, which looked like this: TRACE_EVENT(sched_migrate_task, TP_PROTO(struct task_struct *p, int dest_cpu, const struct cpumask *cpus), TP_ARGS(p, dest_cpu, cpus), TP_STRUCT__entry( __array( char, comm, TASK_COMM_LEN ) __field( pid_t, pid ) __field( int, prio ) __field( int, orig_cpu ) __field( int, dest_cpu ) __bitmask( cpumask, num_possible_cpus() ) ), TP_fast_assign( memcpy(__entry->comm, p->comm, TASK_COMM_LEN); __entry->pid = p->pid; __entry->prio = p->prio; __entry->orig_cpu = task_cpu(p); __entry->dest_cpu = dest_cpu; __assign_bitmask(cpumask, cpumask_bits(cpus), num_possible_cpus()); ), TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d cpumask=%s", __entry->comm, __entry->pid, __entry->prio, __entry->orig_cpu, __entry->dest_cpu, __get_bitmask(cpumask)) ); With the output of: ksmtuned-3613 [003] d..2 485.220508: sched_migrate_task: comm=ksmtuned pid=3615 prio=120 orig_cpu=3 dest_cpu=2 cpumask=00000000,0000000f migration/1-13 [001] d..5 485.221202: sched_migrate_task: comm=ksmtuned pid=3614 prio=120 orig_cpu=1 dest_cpu=0 cpumask=00000000,0000000f awk-3615 [002] d.H5 485.221747: sched_migrate_task: comm=rcu_preempt pid=7 prio=120 orig_cpu=0 dest_cpu=1 cpumask=00000000,000000ff migration/2-18 [002] d..5 485.222062: sched_migrate_task: comm=ksmtuned pid=3615 prio=120 orig_cpu=2 dest_cpu=3 cpumask=00000000,0000000f Link: http://lkml.kernel.org/r/1399377998-14870-6-git-send-email-javi.merino@arm.com Link: http://lkml.kernel.org/r/20140506132238.22e136d1@gandalf.local.home Suggested-by: Javi Merino <javi.merino@arm.com> Tested-by: Javi Merino <javi.merino@arm.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
108 lines
2.6 KiB
C
108 lines
2.6 KiB
C
#ifndef _LINUX_TRACE_SEQ_H
|
|
#define _LINUX_TRACE_SEQ_H
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
/*
|
|
* Trace sequences are used to allow a function to call several other functions
|
|
* to create a string of data to use (up to a max of PAGE_SIZE).
|
|
*/
|
|
|
|
struct trace_seq {
|
|
unsigned char buffer[PAGE_SIZE];
|
|
unsigned int len;
|
|
unsigned int readpos;
|
|
int full;
|
|
};
|
|
|
|
static inline void
|
|
trace_seq_init(struct trace_seq *s)
|
|
{
|
|
s->len = 0;
|
|
s->readpos = 0;
|
|
s->full = 0;
|
|
}
|
|
|
|
/*
|
|
* Currently only defined when tracing is enabled.
|
|
*/
|
|
#ifdef CONFIG_TRACING
|
|
extern __printf(2, 3)
|
|
int trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
|
|
extern __printf(2, 0)
|
|
int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args);
|
|
extern int
|
|
trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary);
|
|
extern int trace_print_seq(struct seq_file *m, struct trace_seq *s);
|
|
extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
|
|
size_t cnt);
|
|
extern int trace_seq_puts(struct trace_seq *s, const char *str);
|
|
extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
|
|
extern int trace_seq_putmem(struct trace_seq *s, const void *mem, size_t len);
|
|
extern int trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
|
|
size_t len);
|
|
extern void *trace_seq_reserve(struct trace_seq *s, size_t len);
|
|
extern int trace_seq_path(struct trace_seq *s, const struct path *path);
|
|
|
|
extern int trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
|
|
int nmaskbits);
|
|
|
|
#else /* CONFIG_TRACING */
|
|
static inline int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int
|
|
trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int
|
|
trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
|
|
int nmaskbits)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
|
|
size_t cnt)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int trace_seq_puts(struct trace_seq *s, const char *str)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int trace_seq_putc(struct trace_seq *s, unsigned char c)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int
|
|
trace_seq_putmem(struct trace_seq *s, const void *mem, size_t len)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
|
|
size_t len)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline void *trace_seq_reserve(struct trace_seq *s, size_t len)
|
|
{
|
|
return NULL;
|
|
}
|
|
static inline int trace_seq_path(struct trace_seq *s, const struct path *path)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif /* CONFIG_TRACING */
|
|
|
|
#endif /* _LINUX_TRACE_SEQ_H */
|