Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: Add cpu_relax() helper

Add cpu_relax() helper in preparation for supporting
read_poll_timeout().

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Link: https://lore.kernel.org/r/20250821002055.3654160-2-fujita.tomonori@gmail.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

FUJITA Tomonori and committed by
Danilo Krummrich
842aedc3 44d454fc

+24
+1
rust/helpers/helpers.c
··· 35 35 #include "pid_namespace.c" 36 36 #include "platform.c" 37 37 #include "poll.c" 38 + #include "processor.c" 38 39 #include "property.c" 39 40 #include "rbtree.c" 40 41 #include "rcu.c"
+8
rust/helpers/processor.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/processor.h> 4 + 5 + void rust_helper_cpu_relax(void) 6 + { 7 + cpu_relax(); 8 + }
+1
rust/kernel/lib.rs
··· 111 111 pub mod platform; 112 112 pub mod prelude; 113 113 pub mod print; 114 + pub mod processor; 114 115 pub mod rbtree; 115 116 pub mod regulator; 116 117 pub mod revocable;
+14
rust/kernel/processor.rs
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + //! Processor related primitives. 4 + //! 5 + //! C header: [`include/linux/processor.h`](srctree/include/linux/processor.h) 6 + 7 + /// Lower CPU power consumption or yield to a hyperthreaded twin processor. 8 + /// 9 + /// It also happens to serve as a compiler barrier. 10 + #[inline] 11 + pub fn cpu_relax() { 12 + // SAFETY: Always safe to call. 13 + unsafe { bindings::cpu_relax() } 14 + }