Skip to content

Commit 8657403

Browse files
authored
fix(gpu): gate the event monitor on enable_ebpf_probes (#54372)
### What does this PR do? Gates the system-probe event monitor on `gpu_monitoring.enable_ebpf_probes` in addition to `gpu_monitoring.enabled`, in both the module-enablement logic (`pkg/system-probe/config`) and the GPU process-consumer creation (`cmd/system-probe/modules/eventmonitor.go`). The GPU monitoring module itself remains gated on `gpu_monitoring.enabled`, so NVML-based collection is unchanged. ### Motivation The event monitor exists only to feed process exec/exit events to the GPU eBPF probes. Keyed on `gpu_monitoring.enabled` alone, a host running GPU monitoring through NVML only still loaded the event monitor's eBPF programs and built a process consumer that nothing read. Follow-up to the discussion on #54291. ### Describe how you validated your changes Extended `TestEventMonitor` with the `enabled` × `enable_ebpf_probes` matrix, setting both explicitly rather than relying on the default (which is changing as the probes are deprecated). Verified that with the probes disabled the `gpu` module is still enabled while `event_monitor` is not: | `gpu_monitoring.enabled` | `enable_ebpf_probes` | enabled modules | | --- | --- | --- | | true | true | `discovery, event_monitor, gpu` | | true | false | `discovery, gpu` | | false | true | `discovery` | Also built `cmd/system-probe/modules` with `linux_bpf,nvml` to cover the configuration that includes both `eventmonitor.go` and the real `gpu.go`. ### Additional Notes Both gates had to move together to stay consistent with the `EnableEBPFProbes && processEventConsumer == nil` guard in the GPU module factory. Note that `gpu_monitoring.enable_ebpf_probes` still defaults to `true` on `main`, so this is a no-op for default configurations until #54291 lands; it currently only affects deployments that set it to `false` explicitly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: matteo.bertrone <matteo.bertrone@datadoghq.com>
1 parent 822ef92 commit 8657403

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

cmd/system-probe/modules/eventmonitor.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ func createEventMonitorModule(_ *sysconfigtypes.Config, deps module.FactoryDepen
133133
}
134134

135135
gpucfg := gpuconfig.New()
136-
if gpucfg.Enabled {
136+
// Only the eBPF probes consume these events, so skip the consumer entirely
137+
// when they are disabled. Kept in sync with the module gate in
138+
// pkg/system-probe/config, which does not enable the event monitor for GPU
139+
// monitoring unless the probes are enabled too.
140+
if gpucfg.Enabled && gpucfg.EnableEBPFProbes {
137141
err := createGPUProcessEventConsumer(evm)
138142
if err != nil {
139143
return nil, fmt.Errorf("cannot create event consumer for GPU: %w", err)

pkg/system-probe/config/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ func load() (*types.Config, error) {
127127
eudmEnabled := coreCfg.GetString("infrastructure_mode") == "end_user_device"
128128
csmEnabled := cfg.GetBool(secNS("enabled"))
129129
gpuEnabled := cfg.GetBool(gpuNS("enabled"))
130+
// The GPU module only consumes process events when its eBPF probes are
131+
// loaded, so the event monitor is only needed for that combination.
132+
gpuEBPFProbesEnabled := gpuEnabled && cfg.GetBool(gpuNS("enable_ebpf_probes"))
130133
diEnabled := cfg.GetBool(diNS("enabled"))
131134
swEnabled := coreCfg.GetBool(swNS("enabled"))
132135
discoveryServiceMapEnabled := cfg.GetBool(discoveryNS("service_map", "enabled"))
@@ -145,7 +148,7 @@ func load() (*types.Config, error) {
145148
coreCfg.GetBool("sbom.enrichment.usage.enabled") ||
146149
(usmEnabled && cfg.GetBool(smNS("enable_event_stream"))) ||
147150
(c.ModuleIsEnabled(NetworkTracerModule) && cfg.GetBool(evNS("network_process.enabled"))) ||
148-
gpuEnabled ||
151+
gpuEBPFProbesEnabled ||
149152
diEnabled {
150153
c.EnabledModules[EventMonitorModule] = struct{}{}
151154
}

pkg/system-probe/config/config_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func TestEventMonitor(t *testing.T) {
2323

2424
for i, tc := range []struct {
2525
cws, fim, networkEvents, gpu bool
26+
gpuEBPFProbes bool
2627
usmEvents bool
2728
enabled bool
2829
}{
@@ -34,7 +35,11 @@ func TestEventMonitor(t *testing.T) {
3435
{cws: false, fim: true, networkEvents: true, enabled: true},
3536
{cws: true, fim: false, networkEvents: true, enabled: true},
3637
{cws: true, fim: true, networkEvents: true, enabled: true},
37-
{cws: false, fim: false, networkEvents: false, gpu: true, enabled: true},
38+
// GPU monitoring only needs the event monitor to feed its eBPF probes,
39+
// so both settings have to be enabled for the module to be pulled in.
40+
{cws: false, fim: false, networkEvents: false, gpu: true, gpuEBPFProbes: true, enabled: true},
41+
{cws: false, fim: false, networkEvents: false, gpu: true, gpuEBPFProbes: false, enabled: false},
42+
{cws: false, fim: false, networkEvents: false, gpu: false, gpuEBPFProbes: true, enabled: false},
3843
{usmEvents: true, enabled: true},
3944
} {
4045
t.Run(strconv.Itoa(i), func(t *testing.T) {
@@ -44,6 +49,9 @@ func TestEventMonitor(t *testing.T) {
4449
t.Setenv("DD_SYSTEM_PROBE_EVENT_MONITORING_NETWORK_PROCESS_ENABLED", strconv.FormatBool(tc.networkEvents))
4550
t.Setenv("DD_SYSTEM_PROBE_NETWORK_ENABLED", strconv.FormatBool(tc.networkEvents))
4651
t.Setenv("DD_GPU_MONITORING_ENABLED", strconv.FormatBool(tc.gpu))
52+
// Set explicitly rather than relying on the default, which is
53+
// subject to change as the eBPF probes are deprecated.
54+
t.Setenv("DD_GPU_MONITORING_ENABLE_EBPF_PROBES", strconv.FormatBool(tc.gpuEBPFProbes))
4755
t.Setenv("DD_SYSTEM_PROBE_SERVICE_MONITORING_ENABLED", strconv.FormatBool(tc.usmEvents))
4856
t.Setenv("DD_SERVICE_MONITORING_CONFIG_ENABLE_EVENT_STREAM", strconv.FormatBool(tc.usmEvents))
4957

0 commit comments

Comments
 (0)