@@ -86,6 +86,8 @@ static bool cpdbg_use_remote;
86
86
static uint32_t cpdbg_start_time ;
87
87
static uint32_t cpdbg_timeout ;
88
88
89
+ static int g_max_delay ;
90
+
89
91
static u64 get_process_lost_count (struct profiler_context * ctx )
90
92
{
91
93
return atomic64_read (& ctx -> process_lost_count );
@@ -167,6 +169,14 @@ static inline bool is_cpdbg_timeout(void)
167
169
return false;
168
170
}
169
171
172
+ void replace_semicolon_with_newline (char * str ) {
173
+ char * p = strchr (str , ';' ); // 查找第一个 ';'
174
+ while (p != NULL ) {
175
+ * p = '\n' ; // 替换为 '\n'
176
+ p = strchr (p + 1 , ';' ); // 查找下一个 ';'
177
+ }
178
+ }
179
+
170
180
static void print_cp_data (stack_trace_msg_t * msg )
171
181
{
172
182
char * timestamp = gen_timestamp_str (0 );
@@ -180,15 +190,14 @@ static void print_cp_data(stack_trace_msg_t * msg)
180
190
cid = (char * )msg -> container_id ;
181
191
182
192
char buff [DEBUG_BUFF_SIZE ];
193
+ replace_semicolon_with_newline (msg -> data );
183
194
snprintf (buff , sizeof (buff ),
184
- "%s [cpdbg] type %d netns_id %lu container_id %s pid %u tid %u "
185
- "process_name %s comm %s stime %lu u_stack_id %u k_statck_id"
186
- " %u cpu %u count %u tiemstamp %lu datalen %u data %s\n" ,
187
- timestamp , msg -> profiler_type , msg -> netns_id ,
188
- cid , msg -> pid , msg -> tid , msg -> process_name , msg -> comm ,
189
- msg -> stime , msg -> u_stack_id ,
190
- msg -> k_stack_id , msg -> cpu , msg -> count ,
191
- msg -> time_stamp , msg -> data_len , msg -> data );
195
+ "%s pid %u tid %u "
196
+ "process_name %s comm %s "
197
+ "cpu %u Interrupt_latency %lu ms\n\n%s\n" ,
198
+ timestamp , msg -> pid , msg -> tid , msg -> process_name , msg -> comm ,
199
+ msg -> cpu ,
200
+ msg -> delay_ms , msg -> data );
192
201
193
202
free (timestamp );
194
203
@@ -350,6 +359,7 @@ static int create_profiler(struct bpf_tracer *tracer)
350
359
ebpf_info (LOG_CP_TAG "=== oncpu profiler enabled ===\n" );
351
360
tracer -> enable_sample = true;
352
361
set_bpf_run_enabled (tracer , & oncpu_ctx , 0 );
362
+ set_bpf_max_delay (tracer , & oncpu_ctx , g_max_delay );
353
363
354
364
/*
355
365
* create reader for read eBPF-profiler data.
@@ -689,6 +699,8 @@ int write_profiler_running_pid(void)
689
699
int start_continuous_profiler (int freq , int java_syms_update_delay ,
690
700
tracer_callback_t callback )
691
701
{
702
+ g_max_delay = java_syms_update_delay ;
703
+ java_syms_update_delay = 60 ;
692
704
char bpf_load_buffer_name [NAME_LEN ];
693
705
void * bpf_bin_buffer ;
694
706
uword buffer_sz ;
@@ -698,8 +710,8 @@ int start_continuous_profiler(int freq, int java_syms_update_delay,
698
710
* one profiler can be active due to the persistence required for Java symbol
699
711
* generation, which is incompatible with multiple agents.
700
712
*/
701
- if (check_profiler_is_running () != ETR_NOTEXIST )
702
- exit (EXIT_FAILURE );
713
+ // if (check_profiler_is_running() != ETR_NOTEXIST)
714
+ // exit(EXIT_FAILURE);
703
715
704
716
if (!run_conditions_check ())
705
717
exit (EXIT_FAILURE );
@@ -708,7 +720,7 @@ int start_continuous_profiler(int freq, int java_syms_update_delay,
708
720
profiler_context_init (& oncpu_ctx , ONCPU_PROFILER_NAME , LOG_CP_TAG ,
709
721
PROFILER_TYPE_ONCPU , g_enable_oncpu ,
710
722
MAP_PROFILER_STATE_NAME , MAP_STACK_A_NAME ,
711
- MAP_STACK_B_NAME , false , true,
723
+ MAP_STACK_B_NAME , true , true,
712
724
NANOSEC_PER_SEC / freq );
713
725
g_ctx_array [PROFILER_CTX_ONCPU_IDX ] = & oncpu_ctx ;
714
726
@@ -760,8 +772,8 @@ int start_continuous_profiler(int freq, int java_syms_update_delay,
760
772
761
773
tracer -> state = TRACER_RUNNING ;
762
774
763
- if (write_profiler_running_pid () != ETR_OK )
764
- return (-1 );
775
+ // if (write_profiler_running_pid() != ETR_OK)
776
+ // return (-1);
765
777
766
778
return (0 );
767
779
}
0 commit comments