Skip to content

High CPU usage due to frequent kallsyms reloading #1151

@bobrik

Description

@bobrik

As noted in #1019, there's a problem with elevated CPU usage when parsing kallsyms for heavy bpf users.

There's some more context in that PR from #1019 (comment) and down.

The problem seems two-fold:

  1. If there are many bpf symbols, the parsing is slowed down. There's a patch to fix this upstream from me here and an alternative from @florianl here. This takes care of slowness when reading bpf symbols, but it doesn't address the fact that the baseline is bad too:
Image
  1. If there's a significant churn in bpf symbols due to frequent loading in unloading (from bpftool prog show or anything else), just happens all the time with a 100ms pause:

case <-s.reloadSymbols:
// Just trigger reloading of symbols with small delay to batch
// potentially multiple module loads.
if nextKallsymsReload == noTimeout {
nextKallsymsReload = time.After(100 * time.Millisecond)
}

The pause helps with update coalescing, but it's still 100% of on-CPU time for ~100ms with a 100ms pause, which is a non-trivial amount.


Given that we already subscribe to bpf_ksym_add and it receives the following struct as an argument, we should have all the information to add symbols without full /proc/kallsyms re-parsing:

struct bpf_ksym {
	unsigned long		 start;
	unsigned long		 end;
	char			 name[KSYM_NAME_LEN];
	// ...
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions