fix multiple definition

This commit is contained in:
zy
2023-11-16 18:26:49 +08:00
parent 67b53ae048
commit d94f916f2d
6 changed files with 68 additions and 38 deletions

View File

@@ -1,5 +1,14 @@
#include "monitor_timer.h"
// Global variable
kernel_watch_timer kernel_wtimer_list[MAX_TIMER_NUM] = {
0}; // all kernel_watch_timer
int kernel_wtimer_num = 0; // current kernel_watch_timer number
EXPORT_SYMBOL(kernel_wtimer_list); // export kernel_watch_timer_list
EXPORT_SYMBOL(kernel_wtimer_num); // export kernel_watch_timer_num
#define TIMER_FILLED(timer) ((timer)->sentinel >= TIMER_MAX_WATCH_NUM)
#define TIMER_EMPTY(timer) (!((timer)->time_ns | (timer)->sentinel))
#define TIMER_NO_KWARG(timer) ((timer)->sentinel == 0)
@@ -113,23 +122,23 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
int i = 0, j = 0;
int buffer[TIMER_MAX_WATCH_NUM]; // Buffer to store the messages
// check all watched kernel_watch_arg
for (i = 0; i < k_watch_timer->sentinel; i++) {
if (read_and_compare(&k_watch_timer->k_watch_args[i])) {
// snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "
// name: %s, threshold: %lld, pid: %d\n",
// k_watch_timer->k_watch_args[i].name,
// k_watch_timer->k_watch_args[i].threshold,
// k_watch_timer->k_watch_args[i].task_id);
buffer[j] = i;
j++;
// // check all watched kernel_watch_arg
// for (i = 0; i < k_watch_timer->sentinel; i++) {
// if (read_and_compare(&k_watch_timer->k_watch_args[i])) {
// // snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "
// // name: %s, threshold: %lld, pid: %d\n",
// // k_watch_timer->k_watch_args[i].name,
// // k_watch_timer->k_watch_args[i].threshold,
// // k_watch_timer->k_watch_args[i].task_id);
// buffer[j] = i;
// j++;
// printk(KERN_INFO "j: name %s, threshold: %lld\n",
// k_watch_timer->k_watch_args[i].name,
// k_watch_timer->k_watch_args[i].threshold);
// printk(KERN_INFO "j: %d\n", j);
}
}
// // printk(KERN_INFO "j: name %s, threshold: %lld\n",
// // k_watch_timer->k_watch_args[i].name,
// // k_watch_timer->k_watch_args[i].threshold);
// // printk(KERN_INFO "j: %d\n", j);
// }
// }
if (j > 0) // if any threshold reached
{
printk("-------------------------------------\n");
@@ -142,7 +151,7 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
k_watch_timer->k_watch_args[buffer[i]].threshold,
k_watch_timer->k_watch_args[buffer[i]].task_id);
}
print_task_stack();
// print_task_stack();
// restart timer after 1s
hrtimer_forward(timer, timer->base->get_time(), ktime_set(1, 0)); //! todo
printk("-------------------------------------\n");