Skip to content

Commit 81cddae

Browse files
committed
fix cpu cache data not push
1 parent aaacb30 commit 81cddae

2 files changed

Lines changed: 48 additions & 6 deletions

File tree

agent/src/ebpf/kernel/files_rw.bpf.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ static __inline int trace_io_event_common(void *ctx,
322322
}
323323

324324
buffer->bytes_count = data_args->bytes_count;
325-
buffer->latency = latency;
326-
buffer->operation = direction;
325+
//buffer->latency = latency;
326+
//buffer->operation = direction;
327327
struct __socket_data_buffer *v_buff =
328328
bpf_map_lookup_elem(&NAME(data_buf), &k0);
329329
if (!v_buff)
@@ -343,7 +343,7 @@ static __inline int trace_io_event_common(void *ctx,
343343
v->fd = data_args->fd;
344344
v->tgid = tgid;
345345
v->pid = (__u32) pid_tgid;
346-
v->coroutine_id = trace_key.goid;
346+
//v->coroutine_id = trace_key.goid;
347347
v->timestamp = data_args->enter_ts;
348348
v->syscall_len = sizeof(*buffer);
349349
// hs_err_pid
@@ -354,11 +354,12 @@ static __inline int trace_io_event_common(void *ctx,
354354
v->source = DATA_SOURCE_FILE_WRITE;
355355
v->syscall_len = data_args->bytes_count;
356356
} else {
357+
__sync_fetch_and_add(&tracer_ctx->push_buffer_refcnt, -1);
357358
return 0;
358-
v->source = DATA_SOURCE_IO_EVENT;
359-
v->syscall_len = sizeof(*buffer);
359+
//v->source = DATA_SOURCE_IO_EVENT;
360+
//v->syscall_len = sizeof(*buffer);
360361
}
361-
v->thread_trace_id = trace_id;
362+
//v->thread_trace_id = trace_id;
362363
v->msg_type = MSG_COMMON;
363364
bpf_get_current_comm(v->comm, sizeof(v->comm));
364365
bool is_vecs = false;

agent/src/ebpf/user/ctrl_tracer.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,8 +1223,49 @@ static int parse_args(int argc, char *argv[], struct df_bpf_conf *conf)
12231223
return 0;
12241224
}
12251225

1226+
#define LOG_PATH "/var/log/deepflow-agent/java-crash.log"
1227+
1228+
int ensure_log_file(void)
1229+
{
1230+
int fd;
1231+
1232+
/* 先检查文件是否存在 */
1233+
if (access(LOG_PATH, F_OK) == 0) {
1234+
return 0; // 已存在,什么都不做
1235+
}
1236+
1237+
/* 确保目录存在 */
1238+
if (mkdir("/var/log/deepflow-agent", 0755) != 0 && errno != EEXIST) {
1239+
perror("mkdir");
1240+
return -1;
1241+
}
1242+
1243+
/* 创建文件(仅当不存在时创建) */
1244+
fd = open(LOG_PATH, O_WRONLY | O_CREAT | O_EXCL, 0644);
1245+
if (fd < 0) {
1246+
if (errno == EEXIST) return 0;
1247+
perror("open");
1248+
return -1;
1249+
}
1250+
1251+
/* 写入初始内容 */
1252+
const char *init = "-----\n";
1253+
if (write(fd, init, strlen(init)) < 0) {
1254+
perror("write");
1255+
close(fd);
1256+
return -1;
1257+
}
1258+
1259+
close(fd);
1260+
return 0;
1261+
}
1262+
12261263
int main(int argc, char *argv[])
12271264
{
1265+
if (ensure_log_file() != 0) {
1266+
fprintf(stderr, "java log file failed\n");
1267+
}
1268+
12281269
char *prog;
12291270
struct df_bpf_conf conf;
12301271
struct df_bpf_obj *obj;

0 commit comments

Comments
 (0)