Skip to content

Commit

Permalink
rust: thread: Add Thread support
Browse files Browse the repository at this point in the history
Signed-off-by: Boqun Feng <[email protected]>
  • Loading branch information
fbq committed Sep 17, 2021
1 parent 57c2bcf commit 413a7b9
Show file tree
Hide file tree
Showing 20 changed files with 467 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ jobs:
grep '] rust_sync: Value: 10$' qemu-stdout.log
grep '] rust_sync: Rust synchronisation primitives sample (exit)$' qemu-stdout.log
- run: |
grep '] rust_thread: Rust thread APIs sample (init)$' qemu-stdout.log
grep '] rust_thread: Rust thread APIs sample (exit)$' qemu-stdout.log
- run: |
grep '] rust_chrdev: Rust character device sample (init)$' qemu-stdout.log
grep '] rust_chrdev: Rust character device sample (exit)$' qemu-stdout.log
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-arm-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-arm-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-arm64-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-arm64-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-ppc64le-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-ppc64le-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-riscv64-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-riscv64-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-x86_64-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-x86_64-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
CONFIG_SAMPLE_RUST_SYNC=m
CONFIG_SAMPLE_RUST_THREAD=m
CONFIG_SAMPLE_RUST_CHRDEV=m
CONFIG_SAMPLE_RUST_MISCDEV=m
CONFIG_SAMPLE_RUST_STACK_PROBING=m
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/qemu-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ busybox rmmod rust_module_parameters.ko
busybox insmod rust_sync.ko
busybox rmmod rust_sync.ko

busybox insmod rust_thread.ko
busybox rmmod rust_thread.ko

busybox insmod rust_chrdev.ko
busybox rmmod rust_chrdev.ko

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/qemu-initramfs.desc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ file /rust_minimal.ko samples/rust/rust_minimal.ko 0755
file /rust_print.ko samples/rust/rust_print.ko 0755 0 0
file /rust_module_parameters.ko samples/rust/rust_module_parameters.ko 0755 0 0
file /rust_sync.ko samples/rust/rust_sync.ko 0755 0 0
file /rust_thread.ko samples/rust/rust_thread.ko 0755 0 0
file /rust_chrdev.ko samples/rust/rust_chrdev.ko 0755 0 0
file /rust_miscdev.ko samples/rust/rust_miscdev.ko 0755 0 0
file /rust_stack_probing.ko samples/rust/rust_stack_probing.ko 0755 0 0
Expand Down
1 change: 1 addition & 0 deletions rust/kernel/bindings_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <linux/cdev.h>
#include <linux/errname.h>
#include <linux/fs.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/random.h>
#include <linux/slab.h>
Expand Down
2 changes: 0 additions & 2 deletions rust/kernel/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,6 @@ macro_rules! from_kernel_result {
/// }
/// }
/// ```
// TODO: remove `dead_code` marker once an in-kernel client is available.
#[allow(dead_code)]
pub(crate) fn from_kernel_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
// CAST: casting a pointer to `*const c_types::c_void` is always valid.
let const_ptr: *const c_types::c_void = ptr.cast();
Expand Down
1 change: 1 addition & 0 deletions rust/kernel/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub mod print;
pub mod random;
mod static_assert;
pub mod sync;
pub mod thread;

#[cfg(any(CONFIG_SYSCTL, doc))]
#[doc(cfg(CONFIG_SYSCTL))]
Expand Down
Loading

0 comments on commit 413a7b9

Please sign in to comment.