* [PATCH] rust: xarray: optimize lock functions with inline attribute
@ 2025-08-16 9:45 凌福义
2025-08-16 9:58 ` Greg KH
0 siblings, 1 reply; 8+ messages in thread
From: 凌福义 @ 2025-08-16 9:45 UTC (permalink / raw)
To: rust-for-linux
[-- Attachment #1: Type: text/html, Size: 1697 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: xarray: optimize lock functions with inline attribute
2025-08-16 9:45 [PATCH] rust: xarray: optimize lock functions with inline attribute 凌福义
@ 2025-08-16 9:58 ` Greg KH
0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2025-08-16 9:58 UTC (permalink / raw)
To: 凌福义; +Cc: rust-for-linux
On Sat, Aug 16, 2025 at 05:45:01PM +0800, 凌福义 wrote:
> The XArray lock and try_lock functions are simple wrappers around
> the C functions xa_lock and xa_trylock. These Rust functions don't
> add significant logic beyond the unsafe FFI calls and safety guarantees.
>
> Mark them as inline to avoid unnecessary function call overhead in
> hot paths where XArray locking is frequent, such as in page cache
> operations and other kernel data structure management.
>
> This follows the same optimization pattern as other Rust kernel
> modules where simple C function wrappers are marked inline to
> improve performance.
>
> Signed-off-by: lingfuyi <lingfuyi@kylinos.cn>
> ---
> rust/kernel/xarray.rs | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
> index a49d6db28845..c96589f92927 100644
> --- a/rust/kernel/xarray.rs
> +++ b/rust/kernel/xarray.rs
> @@ -119,6 +119,7 @@ fn iter(&self) -> impl Iterator<Item = NonNull<c_void>> +
> '_ {
> }
>
> /// Attempts to lock the [`XArray`] for exclusive access.
> + #[inline]
> pub fn try_lock(&self) -> Option<Guard<'_, T>> {
> // SAFETY: `self.xa` is always valid by the type invariant.
> if (unsafe { bindings::xa_trylock(self.xa.get()) } != 0) {
> @@ -132,6 +133,7 @@ pub fn try_lock(&self) -> Option<Guard<'_, T>> {
> }
>
> /// Locks the [`XArray`] for exclusive access.
> + #[inline]
> pub fn lock(&self) -> Guard<'_, T> {
> // SAFETY: `self.xa` is always valid by the type invariant.
> unsafe { bindings::xa_lock(self.xa.get()) };
> --
> 2.34.1
>
>
>
>
>
>
> ----
>
>
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
and can not be applied. Please read the file,
Documentation/process/email-clients.rst in order to fix this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] rust: xarray: optimize lock functions with inline attribute
@ 2025-08-18 1:16 lingfuyi
2025-08-20 3:33 ` Elle Rhumsaa
0 siblings, 1 reply; 8+ messages in thread
From: lingfuyi @ 2025-08-18 1:16 UTC (permalink / raw)
To: rust-for-linux; +Cc: lingfuyi
From: lingfuyi <lingfuyi@kylinos.cn>
The XArray lock and try_lock functions are simple wrappers around
the C functions xa_lock and xa_trylock. These Rust functions don't
add significant logic beyond the unsafe FFI calls and safety guarantees.
Mark them as inline to avoid unnecessary function call overhead in
hot paths where XArray locking is frequent, such as in page cache
operations and other kernel data structure management.
This follows the same optimization pattern as other Rust kernel
modules where simple C function wrappers are marked inline to
improve performance.
Signed-off-by: lingfuyi <lingfuyi@kylinos.cn>
---
rust/kernel/xarray.rs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
index a49d6db28845..c96589f92927 100644
--- a/rust/kernel/xarray.rs
+++ b/rust/kernel/xarray.rs
@@ -119,6 +119,7 @@ fn iter(&self) -> impl Iterator<Item = NonNull<c_void>> + '_ {
}
/// Attempts to lock the [`XArray`] for exclusive access.
+ #[inline]
pub fn try_lock(&self) -> Option<Guard<'_, T>> {
// SAFETY: `self.xa` is always valid by the type invariant.
if (unsafe { bindings::xa_trylock(self.xa.get()) } != 0) {
@@ -132,6 +133,7 @@ pub fn try_lock(&self) -> Option<Guard<'_, T>> {
}
/// Locks the [`XArray`] for exclusive access.
+ #[inline]
pub fn lock(&self) -> Guard<'_, T> {
// SAFETY: `self.xa` is always valid by the type invariant.
unsafe { bindings::xa_lock(self.xa.get()) };
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] rust: xarray: optimize lock functions with inline attribute
@ 2025-08-18 1:26 lingfuyi
2025-08-18 8:04 ` Alice Ryhl
2025-08-18 8:05 ` Miguel Ojeda
0 siblings, 2 replies; 8+ messages in thread
From: lingfuyi @ 2025-08-18 1:26 UTC (permalink / raw)
To: Tamir Duberstein, Andreas Hindborg
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux, linux-kernel, lingfuyi
From: lingfuyi <lingfuyi@kylinos.cn>
The XArray lock and try_lock functions are simple wrappers around
the C functions xa_lock and xa_trylock. These Rust functions don't
add significant logic beyond the unsafe FFI calls and safety guarantees.
Mark them as inline to avoid unnecessary function call overhead in
hot paths where XArray locking is frequent, such as in page cache
operations and other kernel data structure management.
This follows the same optimization pattern as other Rust kernel
modules where simple C function wrappers are marked inline to
improve performance.
Signed-off-by: lingfuyi <lingfuyi@kylinos.cn>
---
rust/kernel/xarray.rs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
index a49d6db28845..c96589f92927 100644
--- a/rust/kernel/xarray.rs
+++ b/rust/kernel/xarray.rs
@@ -119,6 +119,7 @@ fn iter(&self) -> impl Iterator<Item = NonNull<c_void>> + '_ {
}
/// Attempts to lock the [`XArray`] for exclusive access.
+ #[inline]
pub fn try_lock(&self) -> Option<Guard<'_, T>> {
// SAFETY: `self.xa` is always valid by the type invariant.
if (unsafe { bindings::xa_trylock(self.xa.get()) } != 0) {
@@ -132,6 +133,7 @@ pub fn try_lock(&self) -> Option<Guard<'_, T>> {
}
/// Locks the [`XArray`] for exclusive access.
+ #[inline]
pub fn lock(&self) -> Guard<'_, T> {
// SAFETY: `self.xa` is always valid by the type invariant.
unsafe { bindings::xa_lock(self.xa.get()) };
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: xarray: optimize lock functions with inline attribute
2025-08-18 1:26 lingfuyi
@ 2025-08-18 8:04 ` Alice Ryhl
2025-08-18 8:05 ` Miguel Ojeda
1 sibling, 0 replies; 8+ messages in thread
From: Alice Ryhl @ 2025-08-18 8:04 UTC (permalink / raw)
To: lingfuyi
Cc: Tamir Duberstein, Andreas Hindborg, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
lingfuyi
On Mon, Aug 18, 2025 at 3:27 AM <lingfuyi@126.com> wrote:
>
> From: lingfuyi <lingfuyi@kylinos.cn>
>
> The XArray lock and try_lock functions are simple wrappers around
> the C functions xa_lock and xa_trylock. These Rust functions don't
> add significant logic beyond the unsafe FFI calls and safety guarantees.
>
> Mark them as inline to avoid unnecessary function call overhead in
> hot paths where XArray locking is frequent, such as in page cache
> operations and other kernel data structure management.
>
> This follows the same optimization pattern as other Rust kernel
> modules where simple C function wrappers are marked inline to
> improve performance.
>
> Signed-off-by: lingfuyi <lingfuyi@kylinos.cn>
Thanks for the patch. Please see the Developer’s Certificate of Origin 1.1
https://docs.kernel.org/process/submitting-patches.html#developer-s-certificate-of-origin-1-1
You need to use a known identity such as your real name to submit
patches to the kernel. Anonymous contributions aren't possible.
Also please include a version number in the email subject when sending
a new version of a patch.
Alice
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: xarray: optimize lock functions with inline attribute
2025-08-18 1:26 lingfuyi
2025-08-18 8:04 ` Alice Ryhl
@ 2025-08-18 8:05 ` Miguel Ojeda
2025-08-18 8:10 ` Miguel Ojeda
1 sibling, 1 reply; 8+ messages in thread
From: Miguel Ojeda @ 2025-08-18 8:05 UTC (permalink / raw)
To: lingfuyi
Cc: Tamir Duberstein, Andreas Hindborg, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Alice Ryhl, Trevor Gross, Danilo Krummrich, rust-for-linux,
linux-kernel, lingfuyi
On Mon, Aug 18, 2025 at 3:27 AM <lingfuyi@126.com> wrote:
>
> Signed-off-by: lingfuyi <lingfuyi@kylinos.cn>
The kernel requires using a "known identity" (typically meaning the
full/real name) -- please see
https://docs.kernel.org/process/submitting-patches.html#developer-s-certificate-of-origin-1-1
Also, please do not resend patches with the same title -- you should
increase the version number if you do so (or, in this case, if you
just wanted to Cc people, you can do that replying to the patch,
saying who you are Cc'ing).
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: xarray: optimize lock functions with inline attribute
2025-08-18 8:05 ` Miguel Ojeda
@ 2025-08-18 8:10 ` Miguel Ojeda
0 siblings, 0 replies; 8+ messages in thread
From: Miguel Ojeda @ 2025-08-18 8:10 UTC (permalink / raw)
To: lingfuyi
Cc: Tamir Duberstein, Andreas Hindborg, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Alice Ryhl, Trevor Gross, Danilo Krummrich, rust-for-linux,
linux-kernel, lingfuyi
On Mon, Aug 18, 2025 at 10:05 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> The kernel requires using a "known identity" (typically meaning the
> full/real name) -- please see
> https://docs.kernel.org/process/submitting-patches.html#developer-s-certificate-of-origin-1-1
>
> Also, please do not resend patches with the same title -- you should
> increase the version number if you do so (or, in this case, if you
> just wanted to Cc people, you can do that replying to the patch,
> saying who you are Cc'ing).
By the way, the From header, generally, should match that too
(otherwise the "From" line gets added in the body, here because you
use a different domain).
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: xarray: optimize lock functions with inline attribute
2025-08-18 1:16 lingfuyi
@ 2025-08-20 3:33 ` Elle Rhumsaa
0 siblings, 0 replies; 8+ messages in thread
From: Elle Rhumsaa @ 2025-08-20 3:33 UTC (permalink / raw)
To: lingfuyi; +Cc: rust-for-linux, lingfuyi
On Mon, Aug 18, 2025 at 01:16:12AM +0000, lingfuyi@126.com wrote:
> From: lingfuyi <lingfuyi@kylinos.cn>
>
> The XArray lock and try_lock functions are simple wrappers around
> the C functions xa_lock and xa_trylock. These Rust functions don't
> add significant logic beyond the unsafe FFI calls and safety guarantees.
>
> Mark them as inline to avoid unnecessary function call overhead in
> hot paths where XArray locking is frequent, such as in page cache
> operations and other kernel data structure management.
>
> This follows the same optimization pattern as other Rust kernel
> modules where simple C function wrappers are marked inline to
> improve performance.
>
> Signed-off-by: lingfuyi <lingfuyi@kylinos.cn>
> ---
> rust/kernel/xarray.rs | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
> index a49d6db28845..c96589f92927 100644
> --- a/rust/kernel/xarray.rs
> +++ b/rust/kernel/xarray.rs
> @@ -119,6 +119,7 @@ fn iter(&self) -> impl Iterator<Item = NonNull<c_void>> + '_ {
> }
>
> /// Attempts to lock the [`XArray`] for exclusive access.
> + #[inline]
> pub fn try_lock(&self) -> Option<Guard<'_, T>> {
> // SAFETY: `self.xa` is always valid by the type invariant.
> if (unsafe { bindings::xa_trylock(self.xa.get()) } != 0) {
> @@ -132,6 +133,7 @@ pub fn try_lock(&self) -> Option<Guard<'_, T>> {
> }
>
> /// Locks the [`XArray`] for exclusive access.
> + #[inline]
> pub fn lock(&self) -> Guard<'_, T> {
> // SAFETY: `self.xa` is always valid by the type invariant.
> unsafe { bindings::xa_lock(self.xa.get()) };
> --
> 2.34.1
Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-08-20 3:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-16 9:45 [PATCH] rust: xarray: optimize lock functions with inline attribute 凌福义
2025-08-16 9:58 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2025-08-18 1:16 lingfuyi
2025-08-20 3:33 ` Elle Rhumsaa
2025-08-18 1:26 lingfuyi
2025-08-18 8:04 ` Alice Ryhl
2025-08-18 8:05 ` Miguel Ojeda
2025-08-18 8:10 ` Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).