00001
00006 #include "rres_config.h"
00007 #define QOS_DEBUG_LEVEL RRES_MOD_DEBUG_LEVEL
00008 #include "qos_debug.h"
00009
00010 #ifdef CONFIG_OC_RRES_PROC
00011
00012 #include <linux/kernel.h>
00013 #include <linux/spinlock.h>
00014 #include <linux/ctype.h>
00015 #include <stdarg.h>
00016
00017 #include "qos_list.h"
00018
00019 #include "rres_proc_fs.h"
00020 #include "rres.h"
00021 #include "rres_time.h"
00022 #include "rres_interface.h"
00023 #include "rres_kpi_protected.h"
00024
00025 extern struct proc_dir_entry proc_root;
00026 struct proc_dir_entry *aquosa_proc_root = NULL;
00027 struct proc_dir_entry *qres_proc_root = NULL;
00028 EXPORT_SYMBOL_GPL(qres_proc_root);
00029
00031 static int rres_read_tasks(char *page, char **start, off_t off, int count,
00032 int *eof, void *data) {
00033 PROC_PRINT_VARS;
00034 int i;
00035 kal_irq_state flags;
00036 kal_time_t curr_time;
00037 kal_task_t *t;
00038
00039 kal_spin_lock_irqsave(rres_get_spinlock(), &flags);
00040 curr_time = kal_time_now();
00041 PROC_PRINT("time: " KAL_TIME_FMT "\n", KAL_TIME_FMT_ARG(curr_time));
00042 i=0;
00043
00044 if (!list_empty(&server_list)) {
00045 server_t *srv;
00046 struct list_head * tmp_list;
00047
00048 PROC_PRINT("%6s %6s %8s %6s %8s %12s %6s\n",
00049 "srvid |", "pid |", "policy |", "rt_prio |", "state |", "pointer |", "stp");
00050 for_each_server(srv, tmp_list) {
00051 struct list_head *h;
00052 if (rres_empty(srv)) {
00053 PROC_PRINT("%6d Empty\n", srv->id);
00054 continue;
00055 }
00056
00057 for_each_ready_task_in_server(srv, t, h) {
00058 struct task_list *tl = rres_find_task_list(t);
00059 PROC_PRINT("%6d %6d %8u %6u %8li %12p",
00060 srv->id, t->pid, t->policy, t->rt_priority, t->state, rres_find_by_task(t));
00061 if (tl != NULL) {
00062 PROC_PRINT(" %6d", tl->is_stopped);
00063 }
00064 PROC_PRINT("\n");
00065 }
00066 for_each_blocked_task_in_server(srv, t, h) {
00067 struct task_list *tl = rres_find_task_list(t);
00068 PROC_PRINT("%6d %6d %8u %6u %8li %12p",
00069 srv->id, t->pid, t->policy, t->rt_priority, t->state, rres_find_by_task(t));
00070 if (tl != NULL) {
00071 PROC_PRINT(" %6d", tl->is_stopped);
00072 }
00073 PROC_PRINT("\n");
00074 }
00075 }
00076 } else {
00077 PROC_PRINT("No server in the system\n");
00078 }
00079 PROC_PRINT_DONE;
00080
00081 kal_spin_unlock_irqrestore(rres_get_spinlock(), &flags);
00082
00083 PROC_PRINT_END;
00084 }
00085
00087 static int rres_read_sched(char *page, char **start, off_t off, int count,
00088 int *eof, void *data) {
00089 int i;
00090 struct list_head *tmp_list;
00091 server_t *srv;
00092 kal_irq_state flags;
00093 unsigned long period, max_budg, exec_time;
00094 long long int current_budg;
00095 kal_time_t curr_time;
00096 PROC_PRINT_VARS;
00097
00098 kal_spin_lock_irqsave(rres_get_spinlock(), &flags);
00099 curr_time = kal_time_now();
00100 PROC_PRINT("time: " KAL_TIME_FMT "\n", KAL_TIME_FMT_ARG(curr_time));
00101 PROC_PRINT("reserved bandwidth %lu%%\n", U_tot * 100 / MAX_BW);
00102 i=0;
00103 if (! list_empty(&server_list)) {
00104 PROC_PRINT(" " "%6s %8s %8s %10s %12s %10s %12s %4s %4s %4s\n",
00105 "srv|", "period|", "max_bdg|", "cur_bdg|", "deadline|", "diff|", "exec time|", "rdy|", "emp|", "flags");
00106
00107 for_each_server(srv, tmp_list) {
00108 period = srv->period_us;
00109 max_budg = bw2Q(rres_get_bandwidth(srv), srv->period_us);
00110 current_budg = kal_time2usec(srv->c);
00111 exec_time = rres_get_exec_time(srv);
00112 PROC_PRINT("%6d %8lu %8lu %10ld %5lu.%6lu %10ld %12lu %4d %4d %04x\n",
00113 srv->id,
00114 clock2us(period),
00115 clock2us(max_budg),
00116 clock2us(current_budg),
00117 (unsigned long) kal_time_get_sec(srv->deadline), (unsigned long) kal_time_get_usec(srv->deadline),
00118 (long int) kal_time2usec(kal_time_sub(srv->deadline, curr_time)),
00119 exec_time,
00120 rres_has_ready_tasks(srv), rres_empty(srv),
00121 srv->flags
00122 );
00123 }
00124 } else {
00125 PROC_PRINT("No server in the system\n");
00126 }
00127
00128 PROC_PRINT_DONE;
00129
00130 kal_spin_unlock_irqrestore(rres_get_spinlock(), &flags);
00131
00132 PROC_PRINT_END;
00133 }
00134
00136
00137 static int rres_read_modinfo(char *page, char **start, off_t off, int count,
00138 int *eof, void *data) {
00139 PROC_PRINT_VARS;
00140 PROC_PRINT("Enabled options for AQuoSA RRES:\n\n");
00141
00142 PROC_PRINT("Multitasking servers:\t");
00143 PROC_PRINT("on\n");
00144
00145 PROC_PRINT("Precise allocation\t");
00146 PROC_PRINT("on\n");
00147
00148 PROC_PRINT("High resoluton timers\t");
00149 #ifdef KAL_USE_HRTIMER
00150 PROC_PRINT("on\n");
00151 #else
00152 PROC_PRINT("off\n");
00153 #endif
00154
00155 PROC_PRINT("Heap-ordered deadlines\t");
00156 #ifdef RRES_USE_HEAP
00157 PROC_PRINT("on\n");
00158 #else
00159 PROC_PRINT("off\n");
00160 #endif
00161
00162 PROC_PRINT("Task dispatching mech.\t");
00163 #ifdef RRES_DISPATCH_NEW
00164 PROC_PRINT("activate_local/deactivate_local\n");
00165 #elif defined(RRES_DISPATCH_SIG)
00166 PROC_PRINT("sig_send(SIG_STOP)/sig_send(SIG_CONT)\n");
00167 #else
00168 PROC_PRINT("GENSCHED_DISABLED task state\n");
00169 #endif
00170
00171 PROC_PRINT("Default Linux server\t");
00172 #ifdef CONFIG_RRES_DEFAULT_SRV
00173 PROC_PRINT("on\n");
00174 #else
00175 PROC_PRINT("off\n");
00176 #endif
00177
00178 PROC_PRINT("Debugging level\t\t");
00179 #ifdef RRES_MOD_DEBUG_LEVEL
00180 PROC_PRINT("%d\n", RRES_MOD_DEBUG_LEVEL);
00181 #else
00182 PROC_PRINT("off\n");
00183 #endif
00184
00185 PROC_PRINT("Paranoid checks\t\t");
00186 if (RRES_PARANOID)
00187 PROC_PRINT("on\n");
00188 else
00189 PROC_PRINT("off\n");
00190
00191 PROC_PRINT("\n");
00192 PROC_PRINT_DONE;
00193
00194 PROC_PRINT_END;
00195 }
00196
00198 int rres_proc_register(void) {
00199 struct proc_dir_entry *proc_sched_ent;
00200 struct proc_dir_entry *proc_tasks_ent;
00201 struct proc_dir_entry *proc_modinfo_ent;
00202
00203 aquosa_proc_root = create_proc_entry(OC_PROC_ROOT, S_IFDIR, 0);
00204
00205 if (!aquosa_proc_root) {
00206 printk("Unable to initialize /proc/" OC_PROC_ROOT "\n");
00207 return(-1);
00208 }
00209 qres_proc_root = create_proc_entry("qres", S_IFDIR, aquosa_proc_root);
00210 if (!qres_proc_root) {
00211 printk("Unable to initialize /proc/" OC_PROC_ROOT "/qres\n");
00212 return(-1);
00213 }
00214
00215 proc_sched_ent = create_proc_entry("scheduler", S_IFREG|S_IRUGO|S_IWUSR, qres_proc_root);
00216 if (!proc_sched_ent) {
00217 printk("Unable to initialize /proc/" OC_PROC_ROOT "/qres/scheduler\n");
00218 return(-1);
00219 }
00220 proc_sched_ent->read_proc = rres_read_sched;
00221
00222 proc_tasks_ent = create_proc_entry("tasks", S_IFREG|S_IRUGO|S_IWUSR, qres_proc_root);
00223 if (!proc_tasks_ent) {
00224 printk("Unable to initialize /proc/" OC_PROC_ROOT "/qres/tasks\n");
00225 return(-1);
00226 }
00227 proc_tasks_ent->read_proc = rres_read_tasks;
00228 proc_modinfo_ent = create_proc_entry("modinfo", S_IFREG|S_IRUGO|S_IWUSR, qres_proc_root);
00229 if (!proc_modinfo_ent) {
00230 printk("Unable to initialize /proc/" OC_PROC_ROOT "/qres/modinfo\n");
00231 return(-1);
00232 }
00233 proc_modinfo_ent->read_proc = rres_read_modinfo;
00234
00235 return(0);
00236 }
00237
00239 void rres_proc_unregister(void) {
00240
00241 remove_proc_entry("modinfo", qres_proc_root);
00242 remove_proc_entry("tasks", qres_proc_root);
00243
00244 remove_proc_entry("scheduler", qres_proc_root);
00245 remove_proc_entry("qres", aquosa_proc_root);
00246 remove_proc_entry(OC_PROC_ROOT, 0);
00247 }
00248
00249 #else
00250 int rres_proc_register(void) { return 0; }
00251 void rres_proc_unregister(void) {}
00252 #endif