diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2025-06-09 16:44:16 +0530 |
---|---|---|
committer | Viresh Kumar <viresh.kumar@linaro.org> | 2025-06-12 10:31:28 +0530 |
commit | c7f005f70d22cd5613cac30bf6d34867189e36a9 (patch) | |
tree | ca697ecc8168ed4d9ca9315ac08ed530ac204c61 /rust/helpers | |
parent | 33db8c97b4cfa0328054fb755dfbcd6e7f3c7a9d (diff) |
rust: cpu: Add CpuId::current() to retrieve current CPU ID
Introduce `CpuId::current()`, a constructor that wraps the C function
`raw_smp_processor_id()` to retrieve the current CPU identifier without
guaranteeing stability.
This function should be used only when the caller can ensure that
the CPU ID won't change unexpectedly due to preemption or migration.
Suggested-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Diffstat (limited to 'rust/helpers')
-rw-r--r-- | rust/helpers/cpu.c | 8 | ||||
-rw-r--r-- | rust/helpers/helpers.c | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/rust/helpers/cpu.c b/rust/helpers/cpu.c new file mode 100644 index 0000000000000..824e0adb19d4c --- /dev/null +++ b/rust/helpers/cpu.c @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/smp.h> + +unsigned int rust_helper_raw_smp_processor_id(void) +{ + return raw_smp_processor_id(); +} diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c index 0f1b5d1159859..16fa9bca5949b 100644 --- a/rust/helpers/helpers.c +++ b/rust/helpers/helpers.c @@ -13,6 +13,7 @@ #include "build_assert.c" #include "build_bug.c" #include "clk.c" +#include "cpu.c" #include "cpufreq.c" #include "cpumask.c" #include "cred.c" |