summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-02-21 15:07:47 +0800
committeryangwei <[email protected]>2024-02-22 09:52:49 +0800
commit90209da0af1d53eb210ebd1f4cfc012599d34f7b (patch)
tree40f4e273aca31d9572438b781e2a078fd0067664
parent59096f0aef41fca216a0038bb19d6bdbd8e58a69 (diff)
✨ feat(cpu limit): 仅在process延迟日志级别大于INFO时输出CPU100%核的堆栈信息v4.3.38
-rw-r--r--src/support/cpu_limit/cpu_limit.c9
-rw-r--r--src/timer/sapp_timer.c5
2 files changed, 10 insertions, 4 deletions
diff --git a/src/support/cpu_limit/cpu_limit.c b/src/support/cpu_limit/cpu_limit.c
index 2f12b6c..3d125ed 100644
--- a/src/support/cpu_limit/cpu_limit.c
+++ b/src/support/cpu_limit/cpu_limit.c
@@ -278,10 +278,13 @@ static void cl_analysis(cpu_limit_inner_t *h)
if(this_stat->realtime_res_val >= h->user_trigger_value){//超最高限制阈值
cl_analysis_reduce_state(h, tid, this_stat);
- if(this_stat->realtime_res_val >= 99.9 && MESA_handle_runtime_log_level_enabled(ABBR_PROCESS_LATENCY_LOG_HANDLE, RLOG_LV_FATAL))
+ if(this_stat->realtime_res_val >= 99.9)
{
- sapp_process_latency_log(RLOG_LV_FATAL, "[cpu_limit] thread:%d usage:%.2f over 99.9%%, send SIGUSR2 to thread_index:%d, tid:%llu", tid, this_stat->realtime_res_val, tid, sapp_global_val->individual_fixed.thread_obtain_id[tid]);
- pthread_kill(sapp_global_val->individual_fixed.thread_obtain_id[tid], SIGUSR2);
+ sapp_process_latency_log(RLOG_LV_FATAL, "[cpu_limit] thread_index:%d usage:%.2f over 99.9%%, send SIGUSR2 to tid:%llu", tid, this_stat->realtime_res_val, sapp_global_val->individual_fixed.thread_obtain_id[tid]);
+ if(MESA_handle_runtime_log_level_enabled(ABBR_PROCESS_LATENCY_LOG_HANDLE, RLOG_LV_INFO))
+ {
+ pthread_kill(sapp_global_val->individual_fixed.thread_obtain_id[tid], SIGUSR2);
+ }
}
}else{
cl_analysis_observe_state(h, tid, this_stat); /* 可能是从没有过攻击, 可能是刚从攻击状态bypass之后恢复过来 */
diff --git a/src/timer/sapp_timer.c b/src/timer/sapp_timer.c
index 56cda02..3b85e7a 100644
--- a/src/timer/sapp_timer.c
+++ b/src/timer/sapp_timer.c
@@ -463,7 +463,10 @@ static void sapp_watch_dog(void)
getpid(), ABBR_CURRENT_TIME, thread_index, sapp_global_val->individual_fixed.thread_tid[thread_index], sd_notify_enable, deadlock_detected, deadlock_cnt);
}
sapp_process_latency_log(RLOG_LV_FATAL, "sapp_watch_dog detect deadlock at timestamp:%ld, send SIGUSR2 to thread index:%d, tid:%llu", ABBR_CURRENT_TIME, thread_index, sapp_global_val->individual_fixed.thread_obtain_id[thread_index]);
- pthread_kill(sapp_global_val->individual_fixed.thread_obtain_id[thread_index], SIGUSR2);
+ if(MESA_handle_runtime_log_level_enabled(ABBR_PROCESS_LATENCY_LOG_HANDLE, RLOG_LV_FATAL))
+ {
+ pthread_kill(sapp_global_val->individual_fixed.thread_obtain_id[thread_index], SIGUSR2);
+ }
break;
}