summaryrefslogtreecommitdiff
path: root/source/module
diff options
context:
space:
mode:
authorJohn Doe <[email protected]>2023-12-01 09:26:42 +0000
committerJohn Doe <[email protected]>2023-12-01 09:30:53 +0000
commit21862f1271acad91e1ff3a33deda1751fc57dfb7 (patch)
treed046698a0e1539fd1c0a307a43569b6f912103be /source/module
parentfc79e537e20b0dd32678440fb69b0e9f93d2ac8c (diff)
temp save
Diffstat (limited to 'source/module')
-rw-r--r--source/module/monitor_kernel_lib.c37
-rw-r--r--source/module/monitor_timer.h2
-rw-r--r--source/module/monitor_trace.h3
3 files changed, 38 insertions, 4 deletions
diff --git a/source/module/monitor_kernel_lib.c b/source/module/monitor_kernel_lib.c
index 48ee89f..68ed9ad 100644
--- a/source/module/monitor_kernel_lib.c
+++ b/source/module/monitor_kernel_lib.c
@@ -33,6 +33,35 @@ static unsigned char w_arg2k_w_arg(void *kptr, watch_arg warg,
return 0;
}
+// static long long convert_to_longlong(void *ptr, int size, char isUnsigned) {
+// // ptr is null
+// if (!ptr) {
+// return 0;
+// }
+// switch (size) {
+// case 1: // 8-bit integer.
+// if (isUnsigned) {
+// return (long long)(*(uint8_t*)ptr);
+// } else {
+// return (long long)(*(int8_t*)ptr);
+// }
+// case 2: // 16-bit integer.
+// if (isUnsigned) {
+// return (long long)(*(uint16_t*)ptr);
+// } else {
+// return (long long)(*(int16_t*)ptr);
+// }
+// case 4: // 32-bit integer.
+// if (isUnsigned) {
+// return (long long)(*(uint32_t*)ptr);
+// } else {
+// return (long long)(*(int32_t*)ptr);
+// }
+// default:
+// return 0;
+// }
+// }
+
/**
* @brief kernel_watch_arg to threshold
*
@@ -46,6 +75,9 @@ static void k_w_arg2threshold(kernel_watch_arg *k_watch_arg,
threshold->name[MAX_NAME_LEN + 1] = '\0';
threshold->ptr = k_watch_arg->ptr;
threshold->threshold = k_watch_arg->threshold;
+ // read true value
+ // threshold->true_value = convert_to_longlong(k_watch_arg->ptr, k_watch_arg->length_byte, k_watch_arg->is_unsigned);
+
}
static void init_mm_tree(mm_tree *mm_tree) {
@@ -149,9 +181,9 @@ void diag_task_info_work(struct work_struct *work) {
kwarg = &k_watch_timer->k_watch_args[k_watch_timer->threshold_buffer[i]];
k_w_arg2threshold(kwarg, &vm_record.threshold_record[i]);
}
- printk(KERN_INFO "-------------------------------------\n");
+ // printk(KERN_INFO "-------------------------------------\n");
printk(KERN_INFO "-----------variable monitor----------\n");
- printk(KERN_INFO "超出阈值:%lld\n", vm_record.tv);
+ printk(KERN_INFO "threshold exceeded, Timestamp %lld:\n", vm_record.tv);
for (i = 0; i < vm_record.threshold_num; i++) {
printk(KERN_INFO "\t: pid: %d, name: %s, ptr: %p, threshold:%lld\n",
@@ -160,6 +192,7 @@ void diag_task_info_work(struct work_struct *work) {
.name, // Assuming name is a null-terminated string
vm_record.threshold_record[i].ptr,
vm_record.threshold_record[i].threshold);
+ // vm_record.threshold_record[i].true_value);
}
rcu_read_lock();
diff --git a/source/module/monitor_timer.h b/source/module/monitor_timer.h
index 1bdab9f..910fdcf 100644
--- a/source/module/monitor_timer.h
+++ b/source/module/monitor_timer.h
@@ -3,7 +3,7 @@
#define MAX_TIMER_NUM (128) // max timer number
#define TIMER_MAX_WATCH_NUM (32) // A timer max watch number at once time
-#define MAX_NAME_LEN (15) // max name length
+#define MAX_NAME_LEN (127) // max name length
typedef struct {
pid_t task_id; // current process id
diff --git a/source/module/monitor_trace.h b/source/module/monitor_trace.h
index 49fc530..1878077 100644
--- a/source/module/monitor_trace.h
+++ b/source/module/monitor_trace.h
@@ -14,7 +14,7 @@
#define PROCESS_CHAINS_COUNT 10 // max count of process chains
#define PROCESS_ARGV_LEN 128 // max length of process argv
-#define MAX_NAME_LEN (15) // max name length
+#define MAX_NAME_LEN (127) // max name length
#define TIMER_MAX_WATCH_NUM (32) // A timer max watch number at once time
#define DIAG_USER_STACK_SIZE (16 * 1024)
@@ -28,6 +28,7 @@ typedef struct {
char name[MAX_NAME_LEN + 1]; // name
void *ptr; // virtual address
long long threshold; // threshold value
+ // long long true_value; // target true value
} threshold;
typedef struct {