Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions processmanager/ebpf/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ func (impl *ebpfMapsImpl) UpdatePidPageMappingInfo(pid libpf.PID, prefix lpm.Pre

// DeletePidPageMappingInfo removes the elements specified by prefixes from eBPF map
// pid_page_to_mapping_info and returns the number of elements removed.
func (impl *ebpfMapsImpl) DeletePidPageMappingInfo(pid libpf.PID, prefixes []lpm.Prefix) (int,
func (impl *ebpfMapsImpl) DeletePidPageMappingInfo(pid libpf.PID, prefixes []lpm.Prefix) (uint64,
error,
) {
if impl.hasLPMTrieBatchOperations {
Expand All @@ -656,11 +656,11 @@ func (impl *ebpfMapsImpl) DeletePidPageMappingInfo(pid libpf.PID, prefixes []lpm
return impl.DeletePidPageMappingInfoSingle(pid, prefixes)
}

func (impl *ebpfMapsImpl) DeletePidPageMappingInfoSingle(pid libpf.PID, prefixes []lpm.Prefix) (int,
func (impl *ebpfMapsImpl) DeletePidPageMappingInfoSingle(pid libpf.PID, prefixes []lpm.Prefix) (uint64,
error,
) {
cKey := &support.PIDPage{}
var deleted int
var deleted uint64
var combinedErrors error
for _, prefix := range prefixes {
*cKey = getPIDPageFromPrefix(pid, prefix)
Expand All @@ -674,7 +674,7 @@ func (impl *ebpfMapsImpl) DeletePidPageMappingInfoSingle(pid libpf.PID, prefixes
return deleted, combinedErrors
}

func (impl *ebpfMapsImpl) DeletePidPageMappingInfoBatch(pid libpf.PID, prefixes []lpm.Prefix) (int,
func (impl *ebpfMapsImpl) DeletePidPageMappingInfoBatch(pid libpf.PID, prefixes []lpm.Prefix) (uint64,
error,
) {
// Prepare all keys based on the given prefixes.
Expand All @@ -685,7 +685,13 @@ func (impl *ebpfMapsImpl) DeletePidPageMappingInfoBatch(pid libpf.PID, prefixes

deleted, err := impl.PidPageToMappingInfo.BatchDelete(
ptrCastMarshaler[support.PIDPage](cKeys), nil)
return deleted, impl.trackMapError(metrics.IDPidPageToMappingInfoBatchDelete, err)

// BatchDelete returns a count of deleted entries, so this should never happen.
if deleted < 0 {
err = errors.Join(err, fmt.Errorf("negative batch delete count: %d", deleted))
deleted = 0
}
return uint64(deleted), impl.trackMapError(metrics.IDPidPageToMappingInfoBatchDelete, err)
}

// LookupPidPageInformation returns the fileID and bias for a given pid and page combination from
Expand Down
2 changes: 1 addition & 1 deletion processmanager/ebpfapi/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type EbpfHandler interface {

// DeletePidPageMappingInfo removes the elements specified by prefixes from eBPF map
// pid_page_to_mapping_info and returns the number of elements removed.
DeletePidPageMappingInfo(pid libpf.PID, prefixes []lpm.Prefix) (int, error)
DeletePidPageMappingInfo(pid libpf.PID, prefixes []lpm.Prefix) (uint64, error)

// CollectMetrics returns gathered errors for changes to eBPF maps.
CollectMetrics() []metrics.Metric
Expand Down
8 changes: 4 additions & 4 deletions processmanager/processinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (pm *ProcessManager) processRemovedMapping(pid libpf.PID, m *Mapping) uint6

fileID := host.FileIDFromLibpf(mf.File.Value().FileID)
pm.eim.DecRef(fileID)
return uint64(deleted)
return deleted
}

// Caller is responsible to hold pm.mu write lock to avoid race conditions.
Expand Down Expand Up @@ -456,11 +456,11 @@ func (pm *ProcessManager) processPIDExit(pid libpf.PID) {
err = errors.Join(err, fmt.Errorf("failed to delete dummy prefix for PID %d: %v",
pid, err2))
}
pm.pidPageToMappingInfoSize -= uint64(deleted)

for idx := range info.mappings {
pm.processRemovedMapping(pid, &info.mappings[idx])
deleted += pm.processRemovedMapping(pid, &info.mappings[idx])
}
pm.pidPageToMappingInfoSize -= min(pm.pidPageToMappingInfoSize, deleted)
pm.processRemovedInterpreters(pid, libpf.Set[util.OnDiskFileIdentifier]{})
}

Expand Down Expand Up @@ -651,7 +651,7 @@ func (pm *ProcessManager) SynchronizeProcess(pr process.Process) {
for _, m := range mpRemove {
numChanges += pm.processRemovedMapping(pid, m)
}
pm.pidPageToMappingInfoSize -= numChanges
pm.pidPageToMappingInfoSize -= min(pm.pidPageToMappingInfoSize, numChanges)
pm.mu.Lock()
pm.processRemovedInterpreters(pid, interpretersValid)
pm.mu.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions tools/coredump/ebpfmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ func (emc *ebpfMapsCoredump) UpdatePidPageMappingInfo(pid libpf.PID, prefix lpm.
host.FileID(fileID), bias)
}

func (emc *ebpfMapsCoredump) DeletePidPageMappingInfo(pid libpf.PID, prefixes []lpm.Prefix) (int,
func (emc *ebpfMapsCoredump) DeletePidPageMappingInfo(pid libpf.PID, prefixes []lpm.Prefix) (uint64,
error) {
var deleted int
var deleted uint64
for _, prefix := range prefixes {
if err := emc.DeletePidInterpreterMapping(pid, prefix); err != nil {
return deleted, err
Expand Down
Loading