Skip to content

Commit 58ffa4a

Browse files
committed
rust: thread: Add Thread support
Signed-off-by: Boqun Feng <[email protected]>
1 parent 57c2bcf commit 58ffa4a

21 files changed

+468
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ jobs:
354354
grep '] rust_sync: Value: 10$' qemu-stdout.log
355355
grep '] rust_sync: Rust synchronisation primitives sample (exit)$' qemu-stdout.log
356356
357+
- run: |
358+
grep '] rust_thread: Rust thread APIs sample (init)$' qemu-stdout.log
359+
grep '] rust_thread: Rust thread APIs sample (exit)$' qemu-stdout.log
360+
357361
- run: |
358362
grep '] rust_chrdev: Rust character device sample (init)$' qemu-stdout.log
359363
grep '] rust_chrdev: Rust character device sample (exit)$' qemu-stdout.log

.github/workflows/kernel-arm-debug.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
17741774
CONFIG_SAMPLE_RUST_PRINT=m
17751775
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
17761776
CONFIG_SAMPLE_RUST_SYNC=m
1777+
CONFIG_SAMPLE_RUST_THREAD=m
17771778
CONFIG_SAMPLE_RUST_CHRDEV=m
17781779
CONFIG_SAMPLE_RUST_MISCDEV=m
17791780
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/kernel-arm-release.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
16981698
CONFIG_SAMPLE_RUST_PRINT=m
16991699
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
17001700
CONFIG_SAMPLE_RUST_SYNC=m
1701+
CONFIG_SAMPLE_RUST_THREAD=m
17011702
CONFIG_SAMPLE_RUST_CHRDEV=m
17021703
CONFIG_SAMPLE_RUST_MISCDEV=m
17031704
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/kernel-arm64-debug.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
14261426
CONFIG_SAMPLE_RUST_PRINT=m
14271427
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
14281428
CONFIG_SAMPLE_RUST_SYNC=m
1429+
CONFIG_SAMPLE_RUST_THREAD=m
14291430
CONFIG_SAMPLE_RUST_CHRDEV=m
14301431
CONFIG_SAMPLE_RUST_MISCDEV=m
14311432
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/kernel-arm64-release.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
13441344
CONFIG_SAMPLE_RUST_PRINT=m
13451345
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
13461346
CONFIG_SAMPLE_RUST_SYNC=m
1347+
CONFIG_SAMPLE_RUST_THREAD=m
13471348
CONFIG_SAMPLE_RUST_CHRDEV=m
13481349
CONFIG_SAMPLE_RUST_MISCDEV=m
13491350
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/kernel-ppc64le-debug.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
14861486
CONFIG_SAMPLE_RUST_PRINT=m
14871487
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
14881488
CONFIG_SAMPLE_RUST_SYNC=m
1489+
CONFIG_SAMPLE_RUST_THREAD=m
14891490
CONFIG_SAMPLE_RUST_CHRDEV=m
14901491
CONFIG_SAMPLE_RUST_MISCDEV=m
14911492
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/kernel-ppc64le-release.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
14481448
CONFIG_SAMPLE_RUST_PRINT=m
14491449
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
14501450
CONFIG_SAMPLE_RUST_SYNC=m
1451+
CONFIG_SAMPLE_RUST_THREAD=m
14511452
CONFIG_SAMPLE_RUST_CHRDEV=m
14521453
CONFIG_SAMPLE_RUST_MISCDEV=m
14531454
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/kernel-riscv64-debug.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
12801280
CONFIG_SAMPLE_RUST_PRINT=m
12811281
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
12821282
CONFIG_SAMPLE_RUST_SYNC=m
1283+
CONFIG_SAMPLE_RUST_THREAD=m
12831284
CONFIG_SAMPLE_RUST_CHRDEV=m
12841285
CONFIG_SAMPLE_RUST_MISCDEV=m
12851286
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/kernel-riscv64-release.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
11961196
CONFIG_SAMPLE_RUST_PRINT=m
11971197
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
11981198
CONFIG_SAMPLE_RUST_SYNC=m
1199+
CONFIG_SAMPLE_RUST_THREAD=m
11991200
CONFIG_SAMPLE_RUST_CHRDEV=m
12001201
CONFIG_SAMPLE_RUST_MISCDEV=m
12011202
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/kernel-x86_64-debug.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
14381438
CONFIG_SAMPLE_RUST_PRINT=m
14391439
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
14401440
CONFIG_SAMPLE_RUST_SYNC=m
1441+
CONFIG_SAMPLE_RUST_THREAD=m
14411442
CONFIG_SAMPLE_RUST_CHRDEV=m
14421443
CONFIG_SAMPLE_RUST_MISCDEV=m
14431444
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/kernel-x86_64-release.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ CONFIG_SAMPLE_RUST_MINIMAL=m
13861386
CONFIG_SAMPLE_RUST_PRINT=m
13871387
CONFIG_SAMPLE_RUST_MODULE_PARAMETERS=m
13881388
CONFIG_SAMPLE_RUST_SYNC=m
1389+
CONFIG_SAMPLE_RUST_THREAD=m
13891390
CONFIG_SAMPLE_RUST_CHRDEV=m
13901391
CONFIG_SAMPLE_RUST_MISCDEV=m
13911392
CONFIG_SAMPLE_RUST_STACK_PROBING=m

.github/workflows/qemu-init.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ busybox rmmod rust_module_parameters.ko
1212
busybox insmod rust_sync.ko
1313
busybox rmmod rust_sync.ko
1414

15+
busybox insmod rust_thread.ko
16+
busybox rmmod rust_thread.ko
17+
1518
busybox insmod rust_chrdev.ko
1619
busybox rmmod rust_chrdev.ko
1720

.github/workflows/qemu-initramfs.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ file /rust_minimal.ko samples/rust/rust_minimal.ko 0755
99
file /rust_print.ko samples/rust/rust_print.ko 0755 0 0
1010
file /rust_module_parameters.ko samples/rust/rust_module_parameters.ko 0755 0 0
1111
file /rust_sync.ko samples/rust/rust_sync.ko 0755 0 0
12+
file /rust_thread.ko samples/rust/rust_thread.ko 0755 0 0
1213
file /rust_chrdev.ko samples/rust/rust_chrdev.ko 0755 0 0
1314
file /rust_miscdev.ko samples/rust/rust_miscdev.ko 0755 0 0
1415
file /rust_stack_probing.ko samples/rust/rust_stack_probing.ko 0755 0 0

rust/helpers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/build_bug.h>
55
#include <linux/uaccess.h>
66
#include <linux/sched/signal.h>
7+
#include <linux/sched/task.h>
78
#include <linux/gfp.h>
89
#include <linux/highmem.h>
910
#include <linux/uio.h>

rust/kernel/bindings_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/cdev.h>
44
#include <linux/errname.h>
55
#include <linux/fs.h>
6+
#include <linux/kthread.h>
67
#include <linux/module.h>
78
#include <linux/random.h>
89
#include <linux/slab.h>

rust/kernel/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,6 @@ macro_rules! from_kernel_result {
490490
/// }
491491
/// }
492492
/// ```
493-
// TODO: remove `dead_code` marker once an in-kernel client is available.
494-
#[allow(dead_code)]
495493
pub(crate) fn from_kernel_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
496494
// CAST: casting a pointer to `*const c_types::c_void` is always valid.
497495
let const_ptr: *const c_types::c_void = ptr.cast();

rust/kernel/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ pub mod print;
6969
pub mod random;
7070
mod static_assert;
7171
pub mod sync;
72+
pub mod thread;
7273

7374
#[cfg(any(CONFIG_SYSCTL, doc))]
7475
#[doc(cfg(CONFIG_SYSCTL))]

0 commit comments

Comments
 (0)