Skip to content

RFC Eliminate IRQ Time from BPF Program Running Duration

Jianlin Lv bpf lkml oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2Enhance BPF execution timing by excluding IRQ timeinclude/linux/filter.h+22 -22 replies
2/2Export irq_time_read for BPF module usageinclude/linux/sched.h kernel/sched/core.c kernel/sched/sched.h+26 -191 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH bpf-next 0/2] Eliminate IRQ Time from BPF Program Running Duration

From: Jianlin Lv <[email protected]>

Motivation:
===========
This proposal aims to enhance the __bpf_prog_run function by eliminating IRQ time from the BPF program running duration. When a BPF program is attached to a kernel function running in user context, any interrupts that occur can lead to the BPF program's execution duration including the time spent in interrupt handling. This results in an observed increase in CPU usage attributed to eBPF.

Design:
=======
The elimination of IRQ time is built upon enabling CONFIG_IRQ_TIME_ACCOUNTING. Before a BPF program runs in user context, call irq_time_read to record current total IRQ time for the CPU. After the BPF program execution, call irq_time_read again to record the total IRQ time. The difference between these two readings gives the IRQ handling time for this BPF call. Then subtract the IRQ handling time from the total BPF processing duration.

Currently, the irq_time_read function is defined as static, preventing its use by other modules. This proposal suggests exporting irq_time_read for use by the BPF module.

TODOs:
======
- Support elimination of IRQ time for BPF trampoline.
- Add selftests to validate the functionality.

this mail is mainly to get feedback on the design and implementation approach. TODO item will be added in subsequent updates once we gather input on the proposal.

Jianlin Lv (2):
Enhance BPF execution timing by excluding IRQ time Export irq_time_read for BPF module usage

 include/linux/filter.h | 24 ++++++++++++++++++++++--
 include/linux/sched.h  |  4 ++++
 kernel/sched/core.c    | 22 ++++++++++++++++++++++
 kernel/sched/sched.h   | 19 -------------------
 4 files changed, 48 insertions(+), 21 deletions(-)
Signature · 1 line
2.34.1