Skip to contentSkip to conversation

bpf: update bpf_get_smp_processor_id() documentation

PATCH Superseded Matteo Croce 2 participants 2 messages Sep 14, 2021 BPF

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: update bpf_get_smp_processor_id() documentation

From: Matteo Croce <[email protected]>

Since commit 1e6c62a88215 ("bpf: Introduce sleepable BPF programs"), BPF programs can sleep if the BPF_F_SLEEPABLE flag is set. Update the documentation accordingly.

Fixes 1e6c62a88215 ("bpf: Introduce sleepable BPF programs")
---
 include/uapi/linux/bpf.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/uapi/linux/bpf.h +3 -3
index d21326558d42..5e3b2fb62d84 100644
@@ -1629,9 +1629,9 @@ union bpf_attr {
  * u32 bpf_get_smp_processor_id(void)
  * 	Description
  * 		Get the SMP (symmetric multiprocessing) processor id. Note that
- * 		all programs run with preemption disabled, which means that the
- * 		SMP processor id is stable during all the execution of the
- * 		program.
+ * 		programs run with preemption disabled unless BPF_F_SLEEPABLE is
+ * 		set, which means that the SMP processor id is stable during all
+ * 		the execution of the program.
  * 	Return
  * 		The SMP id of the processor running the program.
  *
Signature · 1 line
2.31.1
#1 lore raw
Quoted 7 lines · Matteo Croce

From: Matteo Croce <[email protected]>

Since commit 1e6c62a88215 ("bpf: Introduce sleepable BPF programs"), BPF programs can sleep if the BPF_F_SLEEPABLE flag is set. Update the documentation accordingly.

Fixes 1e6c62a88215 ("bpf: Introduce sleepable BPF programs")

I think we don't need this Fixes tag as this patch should target to bpf-next tree. There is no need to backport to bpf tree since it is just a documentation change.

Based on *current* implementation, referring to sleepable BPF program commit is not needed any more. See below for the suggested change.

Quoted 10 lines
---
  include/uapi/linux/bpf.h | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
include/uapi/linux/bpf.h +0 -0
index d21326558d42..5e3b2fb62d84 100644

include/uapi/linux/bpf.h union bpf_attr { · line 1634

Quoted 9 lines
include/uapi/linux/bpf.h +3 -3
@@ -1629,9 +1629,9 @@ union bpf_attr {
   * u32 bpf_get_smp_processor_id(void)
   * 	Description
   * 		Get the SMP (symmetric multiprocessing) processor id. Note that
- * 		all programs run with preemption disabled, which means that the
- * 		SMP processor id is stable during all the execution of the
- * 		program.
+ * 		programs run with preemption disabled unless BPF_F_SLEEPABLE is
+ * 		set, which means that the SMP processor id is stable during all
+ * 		the execution of the program.

Currently, migrate_disable() means true migration disable and preemption is possible, and BPF_F_SLEEPABLE programs are also protected by migrate_disable().

So the patch should just change "with preemption disabled" to "with migration disabled" to reflect the new implementation.

Quoted 4 lines
include/uapi/linux/bpf.h +0 -0
   * 	Return
   * 		The SMP id of the processor running the program.
   *