Skip to content

Commit 75b9533

Browse files
authored
fix(bpf): exclude swapper process bpf_cpu_time (#1830)
Signed-off-by: Vimal Kumar <[email protected]>
1 parent d23e90e commit 75b9533

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

pkg/collector/resourceutilization/bpf/process_bpf_collector.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ func UpdateProcessBPFMetrics(bpfExporter bpf.Exporter, processStats map[uint64]*
8989
for _, ct := range processesData {
9090
comm := C.GoString((*C.char)(unsafe.Pointer(&ct.Comm)))
9191

92+
if ct.Pid == 0 && config.ExcludeSwapperProcess() {
93+
// exclude swapper process
94+
continue
95+
}
96+
9297
if ct.Pid != 0 {
9398
klog.V(6).Infof("process %s (pid=%d, cgroup=%d) has %d process run time, %d CPU cycles, %d instructions, %d cache misses, %d page cache hits",
9499
comm, ct.Pid, ct.CgroupId, ct.ProcessRunTime, ct.CpuCycles, ct.CpuInstr, ct.CacheMiss, ct.PageCacheHit)

pkg/config/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type KeplerConfig struct {
6464
EstimatorSelectFilter string
6565
CPUArchOverride string
6666
MachineSpecFilePath string
67+
ExcludeSwapperProcess bool
6768
}
6869
type MetricsConfig struct {
6970
CoreUsageMetric string
@@ -158,6 +159,7 @@ func getKeplerConfig() KeplerConfig {
158159
EstimatorModel: getConfig("ESTIMATOR_MODEL", defaultMetricValue),
159160
EstimatorSelectFilter: getConfig("ESTIMATOR_SELECT_FILTER", defaultMetricValue), // no filter
160161
CPUArchOverride: getConfig("CPU_ARCH_OVERRIDE", defaultCPUArchOverride),
162+
ExcludeSwapperProcess: getBoolConfig("EXCLUDE_SWAPPER_PROCESS", defaultExcludeSwapperProcess),
161163
}
162164
}
163165

@@ -262,6 +264,7 @@ func logBoolConfigs() {
262264
klog.V(5).Infof("EXPOSE_COMPONENT_POWER: %t", instance.Kepler.ExposeComponentPower)
263265
klog.V(5).Infof("EXPOSE_ESTIMATED_IDLE_POWER_METRICS: %t. This only impacts when the power is estimated using pre-prained models. Estimated idle power is meaningful only when Kepler is running on bare-metal or with a single virtual machine (VM) on the node.", instance.Kepler.ExposeIdlePowerMetrics)
264266
klog.V(5).Infof("EXPERIMENTAL_BPF_SAMPLE_RATE: %d", instance.Kepler.BPFSampleRate)
267+
klog.V(5).Infof("EXCLUDE_SWAPPER_PROCESS: %t", instance.Kepler.ExcludeSwapperProcess)
265268
}
266269
}
267270

@@ -681,3 +684,8 @@ func DCGMHostEngineEndpoint() string {
681684
ensureConfigInitialized()
682685
return instance.DCGMHostEngineEndpoint
683686
}
687+
688+
func ExcludeSwapperProcess() bool {
689+
ensureConfigInitialized()
690+
return instance.Kepler.ExcludeSwapperProcess
691+
}

pkg/config/types.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ const (
9090
// MaxIRQ is the maximum number of IRQs to be monitored
9191
MaxIRQ = 10
9292
// defaultSamplePeriodSec is the time in seconds that the reader will wait before reading the metrics again
93-
defaultSamplePeriodSec = 3
94-
configDir = "/etc/kepler/kepler.config"
95-
defaultKubeConfig = ""
96-
defaultBPFSampleRate = 0
97-
defaultCPUArchOverride = ""
93+
defaultSamplePeriodSec = 3
94+
configDir = "/etc/kepler/kepler.config"
95+
defaultKubeConfig = ""
96+
defaultBPFSampleRate = 0
97+
defaultCPUArchOverride = ""
98+
defaultExcludeSwapperProcess = false
9899
// model_parameter_prefix
99100
defaultNodePlatformPowerKey = "NODE_TOTAL"
100101
defaultNodeComponentsPowerKey = "NODE_COMPONENTS"

0 commit comments

Comments
 (0)