Skip to content
Snippets Groups Projects
Commit 4242685e authored by fu5520tp's avatar fu5520tp
Browse files

inital procfs support

parent 5e9f0f1b
No related branches found
No related tags found
No related merge requests found
#include <linux/seq_file.h>
#include <linux/proc_fs.h>
#include "perf_error_detection.h"
#include <linux/syscalls.h>
......@@ -251,3 +253,106 @@ const struct sched_class pb_sched_class = {
EXPORT_SYMBOL(pb_sched_class);
///////////////////// ProcFS Ausgabe ///////////////////////////////////
static int show_pbsched(struct seq_file *seq, void *v)
{
int cpu;
if (v == (void *)1) {
seq_printf(seq, "cpuid mode curr_entry curr_pb_cycles curr_admin_cycles\n");
} else {
char mode;
struct rq *rq;
struct pb_rq *pb;
cpu = (unsigned long)(v - 2);
rq = cpu_rq(cpu);
pb = &(rq->pb);
switch(pb->mode) {
case PB_DISABLED_MODE: mode='D'; break;
case PB_EXEC_MODE: mode='E'; break;
case PB_ADMIN_MODE: mode='A'; break;
default: mode='U'; break;
}
/* runqueue-specific stats */
seq_printf(seq,
"cpu%d %c %u %llu %llu\n",
cpu,
mode,
pb->c_entry,
pb->count_pb_cycles,
pb->count_admin_cycles
);
}
return 0;
}
/*
* This itererator needs some explanation.
* It returns 1 for the header position.
* This means 2 is cpu 0.
* In a hotplugged system some cpus, including cpu 0, may be missing so we have
* to use cpumask_* to iterate over the cpus.
*/
static void *pbsched_start(struct seq_file *file, loff_t *offset)
{
unsigned long n = *offset;
if (n == 0)
return (void *) 1;
n--;
if (n > 0)
n = cpumask_next(n - 1, cpu_online_mask);
else
n = cpumask_first(cpu_online_mask);
*offset = n + 1;
if (n < nr_cpu_ids)
return (void *)(unsigned long)(n + 2);
return NULL;
}
static void *pbsched_next(struct seq_file *file, void *data, loff_t *offset)
{
(*offset)++;
return pbsched_start(file, offset);
}
static void pbsched_stop(struct seq_file *file, void *data)
{
// NOP
}
static const struct seq_operations pbsched_sops = {
.start = pbsched_start,
.next = pbsched_next,
.stop = pbsched_stop,
.show = show_pbsched,
};
static int pbsched_open(struct inode *inode, struct file *file)
{
return seq_open(file, &pbsched_sops);
}
static const struct file_operations proc_pbsched_operations = {
.open = pbsched_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static int __init proc_pbsched_init(void)
{
proc_create("pbsched", 0, NULL, &proc_pbsched_operations);
return 0;
}
subsys_initcall(proc_pbsched_init);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment