This is an automated email from the ASF dual-hosted git repository.
liuhan pushed a commit to branch program-long
in repository https://gitbox.apache.org/repos/asf/skywalking-rover.git
The following commit(s) were added to refs/heads/program-long by this push:
new 7e365c6 Reduce program size
7e365c6 is described below
commit 7e365c62e7f31cb3f530b46cbf7d86cc205998c5
Author: mrproliu <[email protected]>
AuthorDate: Fri Dec 27 10:46:21 2024 +0800
Reduce program size
---
bpf/include/socket_data.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/bpf/include/socket_data.h b/bpf/include/socket_data.h
index b4076a7..7d57a08 100644
--- a/bpf/include/socket_data.h
+++ b/bpf/include/socket_data.h
@@ -112,10 +112,8 @@ static __always_inline void
__upload_socket_data_with_buffer(void *ctx, __u8 ind
return;
}
- bool is_reach_buffer_size = false;
if (size > sizeof(event->buffer)) {
size = sizeof(event->buffer);
- is_reach_buffer_size = true;
}
// basic data
@@ -123,9 +121,8 @@ static __always_inline void
__upload_socket_data_with_buffer(void *ctx, __u8 ind
event->data_len = size;
event->finished = is_finished;
event->have_reduce_after_chunk = have_reduce_after_chunk;
- asm volatile("%[size] &= 0x7ff;\n" ::[size] "+r"(size) :); // for the BPF
verifier, and the max size is: 2047
- // is the size reach the max buffer size, then it must add 1 back to
2048(sizeof(socket_data_event->buffer)==2048)
- bpf_probe_read(&event->buffer, is_reach_buffer_size ? size + 1 : size,
buf);
+ asm volatile("%[size] &= 0xfff;\n" ::[size] "+r"(size) :); // for the BPF
verifier: R2 min value is negative, either use unsigned or 'var &= const'
+ bpf_probe_read(&event->buffer, size, buf);
rover_submit_buf(ctx, &socket_data_upload_queue, event, sizeof(*event));
}