Skip to content

Commit

Permalink
Add logic to access strings used by remote config bpf probe (#2983)
Browse files Browse the repository at this point in the history
Signed-off-by: grantseltzer <[email protected]>
Co-authored-by: Dario Castañé <[email protected]>
  • Loading branch information
grantseltzer and darccio authored Dec 3, 2024
1 parent 5dcc739 commit 076462a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ddtrace/tracer/remote_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package tracer
import (
"encoding/json"
"fmt"
"io"
"regexp"
"strings"
"sync"
Expand Down Expand Up @@ -298,13 +299,31 @@ func initalizeDynamicInstrumentationRemoteConfigState() {
time.Sleep(time.Second * 5)
diRCState.Lock()
for _, v := range diRCState.state {
accessStringsToMitigatePageFault(v.runtimeID, v.configPath, v.configContent)
passProbeConfiguration(v.runtimeID, v.configPath, v.configContent)
}
diRCState.Unlock()
}
}()
}

// accessStringsToMitigatePageFault iterates over each string to trigger a page fault,
// ensuring it is loaded into RAM or listed in the translation lookaside buffer.
// This is done by writing the string to io.Discard.
//
// This function addresses an issue with the bpf program that hooks the
// `passProbeConfiguration()` function from system-probe. The bpf program fails
// to read strings if a page fault occurs because the `bpf_probe_read()` helper
// disables paging (uprobe bpf programs can't sleep). Consequently, page faults
// cause `bpf_probe_read()` to return an error and not read any data.
// By preloading the strings, we mitigate this issue, enhancing the reliability
// of the Go Dynamic Instrumentation product.
func accessStringsToMitigatePageFault(strs ...string) {
for i := range strs {
io.WriteString(io.Discard, strs[i])
}
}

// startRemoteConfig starts the remote config client.
// It registers the APM_TRACING product with a callback,
// and the LIVE_DEBUGGING product without a callback.
Expand Down

0 comments on commit 076462a

Please sign in to comment.