Re: [PATCH v9 8/8] task: rust: rework how current is accessed
From: Alice Ryhl
Date: Fri Nov 22 2024 - 10:54:30 EST
On Fri, Nov 22, 2024 at 4:41 PM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> Introduce a new type called `CurrentTask` that lets you perform various
> operations that are only safe on the `current` task. Use the new type to
> provide a way to access the current mm without incrementing its
> refcount.
>
> With this change, you can write stuff such as
>
> let vma = current!().mm().lock_vma_under_rcu(addr);
>
> without incrementing any refcounts.
>
> Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Oh, that's awkward, I was testing this change using a config file that
was missing CONFIG_RUST=y, so it didn't compile the code at all. You
need the following imports for this to work:
diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs
index 103d235eb844..60659076997a 100644
--- a/rust/kernel/task.rs
+++ b/rust/kernel/task.rs
@@ -7,7 +7,8 @@
use crate::{
bindings,
ffi::{c_int, c_long, c_uint},
- types::{NotThreadSafe, Opaque},
+ mm::MmWithUser,
+ types::Opaque,
};
use core::{
cmp::{Eq, PartialEq},
Otherwise the code should be correct. You can fetch the tree with this fixed at:
https://github.com/Darksonn/linux/commits/b4/vma/
I'll fix it in the next version, but I will wait for review before I send that.
Alice