Skip to content

Commit

Permalink
trigger CI
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Kilimnik <[email protected]>
  • Loading branch information
benkilimnik committed Nov 30, 2023
1 parent 56cc19e commit 47b7bef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "src/stirling/upid/upid.h"

// This keeps instruction count below BPF's limit of 4096 per probe.
#define LOOP_LIMIT 42
#define LOOP_LIMIT BPF_LOOP_LIMIT
#define PROTOCOL_VEC_LIMIT 3

const int32_t kInvalidFD = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct close_event_t {
// This defines how many chunks a perf_submit can support.
// This applies to messages that are over MAX_MSG_SIZE,
// and effectively makes the maximum message size to be CHUNK_LIMIT*MAX_MSG_SIZE.
#define CHUNK_LIMIT 4
#define CHUNK_LIMIT BPF_CHUNK_LIMIT

// Unique ID to all syscalls and a few other notable functions.
// This applies to events sent to user-space.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <google/protobuf/text_format.h>
#include <google/protobuf/util/delimited_message_util.h>
#include <magic_enum.hpp>
#include "src/common/system/kernel_version.h"

#include "src/common/base/base.h"
#include "src/common/base/utils.h"
Expand Down Expand Up @@ -431,6 +432,20 @@ auto SocketTraceConnector::InitPerfBufferSpecs() {
}

Status SocketTraceConnector::InitBPF() {
// set BPF loop limit and chunk limit based on kernel version
auto kernel = system::GetCachedKernelVersion();
int loop_limit = 42;
int chunk_limit = 4;
if (kernel.version >= 5 || (kernel.version == 5 && kernel.major_rev >= 1)) {
// Kernels >= 5.1 have higher BPF instruction limits (1 million for verifier).
// This enables a 21x increase to our loop and chunk limits
loop_limit = 882;
chunk_limit = 84;
LOG(INFO) << absl::Substitute(
"Kernel version greater than V5.1 detected ($0), raised loop limit to $1 and chunk limit "
"to $2",
kernel.ToString(), loop_limit, chunk_limit);
}
// PROTOCOL_LIST: Requires update on new protocols.
std::vector<std::string> defines = {
absl::StrCat("-DENABLE_TLS_DEBUG_SOURCES=", FLAGS_stirling_debug_tls_sources),
Expand All @@ -445,6 +460,8 @@ Status SocketTraceConnector::InitBPF() {
absl::StrCat("-DENABLE_NATS_TRACING=", protocol_transfer_specs_[kProtocolNATS].enabled),
absl::StrCat("-DENABLE_AMQP_TRACING=", protocol_transfer_specs_[kProtocolAMQP].enabled),
absl::StrCat("-DENABLE_MONGO_TRACING=", protocol_transfer_specs_[kProtocolMongo].enabled),
absl::StrCat("-DBPF_LOOP_LIMIT=", loop_limit),
absl::StrCat("-DBPF_CHUNK_LIMIT=", chunk_limit),
};
PX_RETURN_IF_ERROR(bcc_->InitBPFProgram(socket_trace_bcc_script, defines));

Expand Down

0 comments on commit 47b7bef

Please sign in to comment.