mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
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>
This commit is contained in:
parent
44d454fcff
commit
842aedc390
4 changed files with 24 additions and 0 deletions
|
|
@ -35,6 +35,7 @@
|
|||
#include "pid_namespace.c"
|
||||
#include "platform.c"
|
||||
#include "poll.c"
|
||||
#include "processor.c"
|
||||
#include "property.c"
|
||||
#include "rbtree.c"
|
||||
#include "rcu.c"
|
||||
|
|
|
|||
8
rust/helpers/processor.c
Normal file
8
rust/helpers/processor.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <linux/processor.h>
|
||||
|
||||
void rust_helper_cpu_relax(void)
|
||||
{
|
||||
cpu_relax();
|
||||
}
|
||||
|
|
@ -111,6 +111,7 @@ pub mod pid_namespace;
|
|||
pub mod platform;
|
||||
pub mod prelude;
|
||||
pub mod print;
|
||||
pub mod processor;
|
||||
pub mod rbtree;
|
||||
pub mod regulator;
|
||||
pub mod revocable;
|
||||
|
|
|
|||
14
rust/kernel/processor.rs
Normal file
14
rust/kernel/processor.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
//! Processor related primitives.
|
||||
//!
|
||||
//! C header: [`include/linux/processor.h`](srctree/include/linux/processor.h)
|
||||
|
||||
/// Lower CPU power consumption or yield to a hyperthreaded twin processor.
|
||||
///
|
||||
/// It also happens to serve as a compiler barrier.
|
||||
#[inline]
|
||||
pub fn cpu_relax() {
|
||||
// SAFETY: Always safe to call.
|
||||
unsafe { bindings::cpu_relax() }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue