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.
Showing the changes to include/uapi (1 of 3 files). Show all
Unified · Split
| @@ -5096,6 +5096,8 @@ union bpf_attr { · 5095 unmodified lines | |||
| 5096 | * **BPF_F_TIMER_ABS** | 5096 | * **BPF_F_TIMER_ABS** |
| 5097 | * Start the timer in absolute expire value instead of the | 5097 | * Start the timer in absolute expire value instead of the |
| 5098 | * default relative one. | 5098 | * default relative one. |
| 5099 | * **BPF_F_TIMER_CPU_PIN** | ||
| 5100 | * Timer will be pinned to the CPU of the caller. | ||
| 5099 | * | 5101 | * |
| 5100 | * Return | 5102 | * Return |
| 5101 | * 0 on success. | 5103 | * 0 on success. |
| @@ -7309,9 +7311,11 @@ struct bpf_core_relo { · 2207 unmodified lines | |||
| 7309 | * Flags to control bpf_timer_start() behaviour. | 7311 | * Flags to control bpf_timer_start() behaviour. |
| 7310 | * - BPF_F_TIMER_ABS: Timeout passed is absolute time, by default it is | 7312 | * - BPF_F_TIMER_ABS: Timeout passed is absolute time, by default it is |
| 7311 | * relative to current time. | 7313 | * relative to current time. |
| 7314 | * - BPF_F_TIMER_CPU_PIN: Timer will be pinned to the CPU of the caller. | ||
| 7312 | */ | 7315 | */ |
| 7313 | enum { | 7316 | enum { |
| 7314 | BPF_F_TIMER_ABS = (1ULL << 0), | 7317 | BPF_F_TIMER_ABS = (1ULL << 0), |
| 7318 | BPF_F_TIMER_CPU_PIN = (1ULL << 1), | ||
| 7315 | }; | 7319 | }; |
| 7316 | 7320 | ||
| 7317 | /* BPF numbers iterator state */ | 7321 | /* BPF numbers iterator state */ |