summaryrefslogtreecommitdiff
path: root/rust/helpers.c
diff options
context:
space:
mode:
authorWedson Almeida Filho <walmeida@microsoft.com>2023-04-11 02:45:40 -0300
committerMiguel Ojeda <ojeda@kernel.org>2023-04-22 00:20:00 +0200
commit8da7a2b7432e8f043f04515895687f72cdb3e0a8 (patch)
tree8dd15c2ad5e49e92aba260bed3a9a49b7759ebc5 /rust/helpers.c
parent313c4281bc9dfa98d76a71b16a684af1c52e7751 (diff)
downloadlwn-8da7a2b7432e8f043f04515895687f72cdb3e0a8.tar.gz
lwn-8da7a2b7432e8f043f04515895687f72cdb3e0a8.zip
rust: introduce `current`
This allows Rust code to get a reference to the current task without having to increment the refcount, but still guaranteeing memory safety. Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com> Link: https://lore.kernel.org/r/20230411054543.21278-10-wedsonaf@gmail.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/helpers.c')
-rw-r--r--rust/helpers.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/rust/helpers.c b/rust/helpers.c
index 6e5b2c953d36..2cb7b82053d8 100644
--- a/rust/helpers.c
+++ b/rust/helpers.c
@@ -103,6 +103,12 @@ long rust_helper_PTR_ERR(__force const void *ptr)
}
EXPORT_SYMBOL_GPL(rust_helper_PTR_ERR);
+struct task_struct *rust_helper_get_current(void)
+{
+ return current;
+}
+EXPORT_SYMBOL_GPL(rust_helper_get_current);
+
void rust_helper_get_task_struct(struct task_struct *t)
{
get_task_struct(t);