History

bpf: Add ability to pin bpf timer to calling CPU

BPF supports creating high resolution timers using bpf_timer_* helper functions. Currently, only the BPF_F_TIMER_ABS flag is supported, which specifies that the timeout should be interpreted as absolute time. It would also be useful to be able to pin that timer to a core. For example, if you wanted to make a subset of cores run without timer interrupts, and only have the timer be invoked on a single core. This patch adds support for this with a new BPF_F_TIMER_CPU_PIN flag. When specified, the HRTIMER_MODE_PINNED flag is passed to hrtimer_start(). A subsequent patch will update selftests to validate.

David Vernet committed 3 years ago

Commit d6247ec1 parent 84cb9cb3 files · +12 −1Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/bpf.h+4−0
@@ -5096,6 +5096,8 @@ union bpf_attr { · 5095 unmodified lines
50965096 * **BPF_F_TIMER_ABS**
50975097 * Start the timer in absolute expire value instead of the
50985098 * default relative one.
5099+ * **BPF_F_TIMER_CPU_PIN**
5100+ * Timer will be pinned to the CPU of the caller.
50995101 *
51005102 * Return
51015103 * 0 on success.
@@ -7309,9 +7311,11 @@ struct bpf_core_relo { · 2207 unmodified lines
73097311 * Flags to control bpf_timer_start() behaviour.
73107312 * - BPF_F_TIMER_ABS: Timeout passed is absolute time, by default it is
73117313 * relative to current time.
7314+ * - BPF_F_TIMER_CPU_PIN: Timer will be pinned to the CPU of the caller.
73127315 */
73137316 enum {
73147317 BPF_F_TIMER_ABS = (1ULL << 0),
7318+ BPF_F_TIMER_CPU_PIN = (1ULL << 1),
73157319 };
73167320
73177321 /* BPF numbers iterator state */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t