summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Hindborg <a.hindborg@samsung.com>2023-09-04 13:38:42 +0200
committerDanilo Krummrich <dakr@redhat.com>2023-11-22 22:01:11 +0100
commitba5544722b37a806c3c0266f56a26467d6e7e809 (patch)
treec4ed10e5be25c865e26497c9abeca2fc3fcd7574
parentf87fe7331963080f6d807b35f0497350b28152cb (diff)
rust: add num_possible_cpus
Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>
-rw-r--r--rust/helpers.c6
-rw-r--r--rust/kernel/lib.rs6
2 files changed, 12 insertions, 0 deletions
diff --git a/rust/helpers.c b/rust/helpers.c
index f300efa3009a..92b494ad66a6 100644
--- a/rust/helpers.c
+++ b/rust/helpers.c
@@ -189,6 +189,12 @@ const char *rust_helper_dev_name(const struct device *dev)
}
EXPORT_SYMBOL_GPL(rust_helper_dev_name);
+unsigned int rust_helper_num_possible_cpus(void)
+{
+ return num_possible_cpus();
+}
+EXPORT_SYMBOL_GPL(rust_helper_num_possible_cpus);
+
void rust_helper_pci_set_drvdata(struct pci_dev *pdev, void *data)
{
pci_set_drvdata(pdev, data);
diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index cc4551f27e11..05b7f6ee9fc6 100644
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@ -113,3 +113,9 @@ fn panic(info: &core::panic::PanicInfo<'_>) -> ! {
// SAFETY: FFI call.
unsafe { bindings::BUG() };
}
+
+/// Returns maximum number of CPUs that may be online on the system.
+pub fn num_possible_cpus() -> u32 {
+ // SAFETY: FFI call with no additional requirements.
+ unsafe { bindings::num_possible_cpus() }
+}