Re: [PATCH 1/3] rust: implement `kernel::sync::Refcount`
From: Dirk Behme
Date: Sat Oct 05 2024 - 02:04:14 EST
Am 04.10.24 um 21:08 schrieb Gary Guo:
On Fri, 04 Oct 2024 20:51:22 +0200
Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
Hi Gary,
"Gary Guo" <gary@xxxxxxxxxxx> writes:
[...]
diff --git a/rust/helpers/refcount.c b/rust/helpers/refcount.c
index f47afc148ec3..39649443426b 100644
--- a/rust/helpers/refcount.c
+++ b/rust/helpers/refcount.c
@@ -8,11 +8,26 @@ refcount_t rust_helper_REFCOUNT_INIT(int n)
return (refcount_t)REFCOUNT_INIT(n);
}
+unsigned int rust_helper_refcount_read(refcount_t *r)
+{
+ return refcount_read(r);
+}
+EXPORT_SYMBOL_GPL(rust_helper_refcount_read);
+
+void rust_helper_refcount_set(refcount_t *r, int n)
+{
+ refcount_set(r, n);
+}
+EXPORT_SYMBOL_GPL(rust_helper_refcount_set);
BR Andreas
Helper symbol export is automatic after
e26fa546042a (rust: kbuild: auto generate helper exports)
Yes :)
What results in a question, though:
When to use exports.h and when not?
There are several users of
#include <linux/export.h>
like
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/rust/helpers/err.c
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/rust/helpers/kunit.c
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/rust/helpers/mutex.c
but some don't use it
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/rust/helpers/rbtree.c
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/rust/helpers/uaccess.c
Any rule?
Best regards
Dirk