* [GIT PULL] Rust `hrtimer` support for v6.15
@ 2025-03-13 13:09 Andreas Hindborg
2025-03-21 12:10 ` Andreas Hindborg
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Hindborg @ 2025-03-13 13:09 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
Hi Miguel,
Please pull the Rust support for hrtimer for v6.15.
This initial support allows for intrusive use of timers without
allocating when starting a timer. We support `Pin<Box<T>>`, `Arc<T>`,
`Pin<&T>` and `Pin<&mut T>` pointer types for working with these
intrusive timers. We support at most one `HrTimer` field in a struct for
use with this API.
For now, the primary users will be the Rust null block driver, `rnull`,
and the Rust kernel mode setting driver `rkvms`. I expect us to add more
features to the API as the demands from users grow.
The PR also includes two changes for the core rust and rust/alloc
subsytems that are dependencies of the hrtimer Rust API: `Arc::as_ptr`
and `Box::into_pin`. The alloc change was Ack'd by Danilo.
The commits were in linux-next since next-20250313.
The following changes since commit a64dcfb451e254085a7daee5fe51bf22959d52d3:
Linux 6.14-rc2 (2025-02-09 12:45:03 -0800)
are available in the Git repository at:
https://github.com/rust-for-linux/linux.git tags/rust-hrtimer-for-v6.15
for you to fetch changes up to 15a3c03ca02b6caec995de178904ab8c637d584c:
rust: hrtimer: add maintainer entry (2025-03-11 21:00:43 +0100)
Best regards,
Andreas Hindborg
----------------------------------------------------------------
Rust hrtimer API for v6.15
Introduce Rust support for the `hrtimer` subsystem:
- Add a way to use the `hrtimer` subsystem from Rust. Rust code can now set up
intrusive timers without allocating when starting the timer.
- Add support for `Pin<Box<_>>`, `Arc<_>`, `Pin<&_>` and `Pin<&mut _>` as
pointer types for use with timer callbacks.
- Add support for setting clock source and timer mode.
`kernel` crate:
- Add `Arc::as_ptr` for converting an `Arc` to a raw pointer. This is a
dependency for the `hrtimer` API.
- Add `Box::into_pin` for converting a `Box<_>` into a `Pin<Box<_>>` to align
with Rust `alloc`. This is a dependency for the `hrtimer` API.
----------------------------------------------------------------
Andreas Hindborg (13):
rust: hrtimer: introduce hrtimer support
rust: sync: add `Arc::as_ptr`
rust: hrtimer: implement `HrTimerPointer` for `Arc`
rust: hrtimer: allow timer restart from timer handler
rust: hrtimer: add `UnsafeHrTimerPointer`
rust: hrtimer: add `hrtimer::ScopedHrTimerPointer`
rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin<&T>`
rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin<&mut T>`
rust: alloc: add `Box::into_pin`
rust: hrtimer: implement `HrTimerPointer` for `Pin<Box<T>>`
rust: hrtimer: add `HrTimerMode`
rust: hrtimer: add clocksource selection through `ClockId`
rust: hrtimer: add maintainer entry
MAINTAINERS | 15 ++
rust/kernel/alloc/kbox.rs | 6 +
rust/kernel/sync/arc.rs | 13 +-
rust/kernel/time.rs | 68 +++++
rust/kernel/time/hrtimer.rs | 517 ++++++++++++++++++++++++++++++++++++
rust/kernel/time/hrtimer/arc.rs | 100 +++++++
rust/kernel/time/hrtimer/pin.rs | 104 ++++++++
rust/kernel/time/hrtimer/pin_mut.rs | 108 ++++++++
rust/kernel/time/hrtimer/tbox.rs | 120 +++++++++
9 files changed, 1049 insertions(+), 2 deletions(-)
create mode 100644 rust/kernel/time/hrtimer.rs
create mode 100644 rust/kernel/time/hrtimer/arc.rs
create mode 100644 rust/kernel/time/hrtimer/pin.rs
create mode 100644 rust/kernel/time/hrtimer/pin_mut.rs
create mode 100644 rust/kernel/time/hrtimer/tbox.rs
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [GIT PULL] Rust `hrtimer` support for v6.15
2025-03-13 13:09 [GIT PULL] Rust `hrtimer` support for v6.15 Andreas Hindborg
@ 2025-03-21 12:10 ` Andreas Hindborg
2025-03-22 11:15 ` Andreas Hindborg
2025-03-25 20:03 ` Miguel Ojeda
0 siblings, 2 replies; 6+ messages in thread
From: Andreas Hindborg @ 2025-03-21 12:10 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel, rust-for-linux@vger.kernel.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi Miguel,
Andreas Hindborg <a.hindborg@kernel.org> writes:
> Hi Miguel,
>
> Please pull the Rust support for hrtimer for v6.15.
>
> This initial support allows for intrusive use of timers without
> allocating when starting a timer. We support `Pin<Box<T>>`, `Arc<T>`,
> `Pin<&T>` and `Pin<&mut T>` pointer types for working with these
> intrusive timers. We support at most one `HrTimer` field in a struct for
> use with this API.
>
> For now, the primary users will be the Rust null block driver, `rnull`,
> and the Rust kernel mode setting driver `rkvms`. I expect us to add more
> features to the API as the demands from users grow.
>
> The PR also includes two changes for the core rust and rust/alloc
> subsytems that are dependencies of the hrtimer Rust API: `Arc::as_ptr`
> and `Box::into_pin`. The alloc change was Ack'd by Danilo.
>
> The commits were in linux-next since next-20250313.
Please find an updated pull request below.
As discussed, I fixed the UB you fund in:
rust: hrtimer: allow timer restart from timer handler
by casting to `u32` when assigning enum values. The commits below this
commit are unchanged, the later commits were replayed on top of the
changed commit.
The following changes since commit a64dcfb451e254085a7daee5fe51bf22959d52d3:
Linux 6.14-rc2 (2025-02-09 12:45:03 -0800)
are available in the Git repository at:
https://github.com/rust-for-linux/linux.git tags/rust-hrtimer-for-v6.15-v2
for you to fetch changes up to ac4f9157e8d7f6a9793209a693cb3e3a6f840983:
rust: hrtimer: add maintainer entry (2025-03-21 12:56:38 +0100)
Best regards,
Andreas Hindborg
- ----------------------------------------------------------------
Rust hrtimer API for v6.15
Introduce Rust support for the `hrtimer` subsystem:
- Add a way to use the `hrtimer` subsystem from Rust. Rust code can now set up
intrusive timers without allocating when starting the timer.
- Add support for `Pin<Box<_>>`, `Arc<_>`, `Pin<&_>` and `Pin<&mut _>` as
pointer types for use with timer callbacks.
- Add support for setting clock source and timer mode.
`kernel` crate:
- Add `Arc::as_ptr` for converting an `Arc` to a raw pointer. This is a
dependency for the `hrtimer` API.
- Add `Box::into_pin` for converting a `Box<_>` into a `Pin<Box<_>>` to align
with Rust `alloc`. This is a dependency for the `hrtimer` API.
- ----------------------------------------------------------------
Andreas Hindborg (13):
rust: hrtimer: introduce hrtimer support
rust: sync: add `Arc::as_ptr`
rust: hrtimer: implement `HrTimerPointer` for `Arc`
rust: hrtimer: allow timer restart from timer handler
rust: hrtimer: add `UnsafeHrTimerPointer`
rust: hrtimer: add `hrtimer::ScopedHrTimerPointer`
rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin<&T>`
rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin<&mut T>`
rust: alloc: add `Box::into_pin`
rust: hrtimer: implement `HrTimerPointer` for `Pin<Box<T>>`
rust: hrtimer: add `HrTimerMode`
rust: hrtimer: add clocksource selection through `ClockId`
rust: hrtimer: add maintainer entry
MAINTAINERS | 15 ++
rust/kernel/alloc/kbox.rs | 6 +
rust/kernel/sync/arc.rs | 13 +-
rust/kernel/time.rs | 68 +++++
rust/kernel/time/hrtimer.rs | 517 ++++++++++++++++++++++++++++++++++++
rust/kernel/time/hrtimer/arc.rs | 100 +++++++
rust/kernel/time/hrtimer/pin.rs | 104 ++++++++
rust/kernel/time/hrtimer/pin_mut.rs | 108 ++++++++
rust/kernel/time/hrtimer/tbox.rs | 120 +++++++++
9 files changed, 1049 insertions(+), 2 deletions(-)
create mode 100644 rust/kernel/time/hrtimer.rs
create mode 100644 rust/kernel/time/hrtimer/arc.rs
create mode 100644 rust/kernel/time/hrtimer/pin.rs
create mode 100644 rust/kernel/time/hrtimer/pin_mut.rs
create mode 100644 rust/kernel/time/hrtimer/tbox.rs
-----BEGIN PGP SIGNATURE-----
iQJKBAEBCAA0FiEEEsH5R1a/fCoV1sAS4bgaPnkoY3cFAmfdVykWHGEuaGluZGJv
cmdAa2VybmVsLm9yZwAKCRDhuBo+eShjd18rD/0UMWTrZZRm/KPD2V9oZzoT/yYy
cM9nANXm7FXJJMUaqzKv0rzKl7bxqo6wJwaNJPFBCSkVEKAQhuJo35+REiXTr7nU
8UnTUtNWl8nhX9q1+fMmQqTwZpYGlydTFn0cjyFtqQe9ahPhfCR/iF+kvb/VtR/s
3ow8v93epAXy01/4fwcWW7Iozu5GqvTyyz4H8n+6B8UNVSgQp+lo4sylfl27EtQn
7i/hrAQYaLv765UrxYsQVNyxL2qU3XXKOlDKr0KY9GFXuMVSwm765rbobGNXeD4Q
kEZ9BU70ebS29ZHHsTncUN0AuiE22iwL/dMdZaSvyjMrD4WgH3oLbtVIuRjLQNJ1
D4hCryTc5gHvRHJ6ZYZJNv4dqRJ0CJ0GqdR3g19Yi6U8S8GD5HK7QGz84RusiM33
6LoKEO/XauPPaHP/ZlyDIJmuwrKRz+t9SNiEMmDFtl6UjPq/N4ghqG4zsG3wRbWq
VBFDKP3nxaOOKTXSF0D7yGec4eENuo6EuGswoXoS4OvC0c9i8KwKBkutoLVw1c4l
OYrwDeloyAP6V/cKbVgvxKeq3j/MKiBfYsuJBV3iQe8L7r0qoLQrCtM+dzWTRaxT
IVkKSBnRReVyVNsatf4jmBBwN1eAeNaWUCYy+w8AdCLoGggchjSNizW+FqorR3KQ
u6wfok7Z9QtTDT4HOA==
=B5KA
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [GIT PULL] Rust `hrtimer` support for v6.15
2025-03-21 12:10 ` Andreas Hindborg
@ 2025-03-22 11:15 ` Andreas Hindborg
2025-03-25 23:22 ` Miguel Ojeda
2025-03-25 23:24 ` Miguel Ojeda
2025-03-25 20:03 ` Miguel Ojeda
1 sibling, 2 replies; 6+ messages in thread
From: Andreas Hindborg @ 2025-03-22 11:15 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel, rust-for-linux@vger.kernel.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi Miguel,
Andreas Hindborg <a.hindborg@kernel.org> writes:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Hi Miguel,
>
> Andreas Hindborg <a.hindborg@kernel.org> writes:
>
>> Hi Miguel,
>>
>> Please pull the Rust support for hrtimer for v6.15.
>>
>> This initial support allows for intrusive use of timers without
>> allocating when starting a timer. We support `Pin<Box<T>>`, `Arc<T>`,
>> `Pin<&T>` and `Pin<&mut T>` pointer types for working with these
>> intrusive timers. We support at most one `HrTimer` field in a struct for
>> use with this API.
>>
>> For now, the primary users will be the Rust null block driver, `rnull`,
>> and the Rust kernel mode setting driver `rkvms`. I expect us to add more
>> features to the API as the demands from users grow.
>>
>> The PR also includes two changes for the core rust and rust/alloc
>> subsytems that are dependencies of the hrtimer Rust API: `Arc::as_ptr`
>> and `Box::into_pin`. The alloc change was Ack'd by Danilo.
>>
>> The commits were in linux-next since next-20250313.
>
> Please find an updated pull request below.
>
> As discussed, I fixed the UB you fund in:
>
> rust: hrtimer: allow timer restart from timer handler
>
> by casting to `u32` when assigning enum values. The commits below this
> commit are unchanged, the later commits were replayed on top of the
> changed commit.
I'm sorry, but I have to do another update. My usual workflow missed a
clippy warning because it depends on clippy warnings being treated as
errors when building with `W=e`. I forgot that is not upstream yet.
I added `#[allow(clippy::unnecessary_cast)]` to silence clippy in the
cases where the types match for `HrTimerRestart`.
The following changes since commit a64dcfb451e254085a7daee5fe51bf22959d52d3:
Linux 6.14-rc2 (2025-02-09 12:45:03 -0800)
are available in the Git repository at:
https://github.com/rust-for-linux/linux.git tags/rust-hrtimer-for-v6.15-v3
for you to fetch changes up to 142d93914b8575753f56f0c3571bd81f214b7418:
rust: hrtimer: add maintainer entry (2025-03-22 12:08:54 +0100)
Best regards,
Andreas Hindborg
- ----------------------------------------------------------------
Rust hrtimer API for v6.15
Introduce Rust support for the `hrtimer` subsystem:
- Add a way to use the `hrtimer` subsystem from Rust. Rust code can now set up
intrusive timers without allocating when starting the timer.
- Add support for `Pin<Box<_>>`, `Arc<_>`, `Pin<&_>` and `Pin<&mut _>` as
pointer types for use with timer callbacks.
- Add support for setting clock source and timer mode.
`kernel` crate:
- Add `Arc::as_ptr` for converting an `Arc` to a raw pointer. This is a
dependency for the `hrtimer` API.
- Add `Box::into_pin` for converting a `Box<_>` into a `Pin<Box<_>>` to align
with Rust `alloc`. This is a dependency for the `hrtimer` API.
- ----------------------------------------------------------------
Andreas Hindborg (13):
rust: hrtimer: introduce hrtimer support
rust: sync: add `Arc::as_ptr`
rust: hrtimer: implement `HrTimerPointer` for `Arc`
rust: hrtimer: allow timer restart from timer handler
rust: hrtimer: add `UnsafeHrTimerPointer`
rust: hrtimer: add `hrtimer::ScopedHrTimerPointer`
rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin<&T>`
rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin<&mut T>`
rust: alloc: add `Box::into_pin`
rust: hrtimer: implement `HrTimerPointer` for `Pin<Box<T>>`
rust: hrtimer: add `HrTimerMode`
rust: hrtimer: add clocksource selection through `ClockId`
rust: hrtimer: add maintainer entry
MAINTAINERS | 15 ++
rust/kernel/alloc/kbox.rs | 6 +
rust/kernel/sync/arc.rs | 13 +-
rust/kernel/time.rs | 68 +++++
rust/kernel/time/hrtimer.rs | 519 ++++++++++++++++++++++++++++++++++++
rust/kernel/time/hrtimer/arc.rs | 100 +++++++
rust/kernel/time/hrtimer/pin.rs | 104 ++++++++
rust/kernel/time/hrtimer/pin_mut.rs | 108 ++++++++
rust/kernel/time/hrtimer/tbox.rs | 120 +++++++++
9 files changed, 1051 insertions(+), 2 deletions(-)
create mode 100644 rust/kernel/time/hrtimer.rs
create mode 100644 rust/kernel/time/hrtimer/arc.rs
create mode 100644 rust/kernel/time/hrtimer/pin.rs
create mode 100644 rust/kernel/time/hrtimer/pin_mut.rs
create mode 100644 rust/kernel/time/hrtimer/tbox.rs
-----BEGIN PGP SIGNATURE-----
iQJKBAEBCAA0FiEEEsH5R1a/fCoV1sAS4bgaPnkoY3cFAmfem+kWHGEuaGluZGJv
cmdAa2VybmVsLm9yZwAKCRDhuBo+eShjd81tD/94J4FDlaOlfz/WMkbxQo2B3lef
XztcyQ6G3zPfyMOZ50ZrbvQPyHtnKPxjD0rjfuCCQnzmcKs0fqUxcBKXpvRusi0Q
dC3f8fBT7n+8wvU6eOO/gzR0pblvu4yepardP/MSPaTH4pBF0xgaRFqM3S8syejY
elHnw1y9mSH7EbSJFJvVIodXLE0MXifb5FicN5iawQ27IeBCdZDoQa0x/tLBsYpY
8CkAqsWUUU424dvGrKjcsUjfLYJXiXfDQmuLi5tReVpoWF8g47DmbnLv+s/4r87S
fOLaNyzn81tStYze0+DaEOpkXID6y64EyfwmXGV09CRJAE432tbBxRzouKTvDZxt
gO9VPBGtoN7tm6bzobQuCTXsLlrNCIh36Ju952uR1fjgQ8uNg15qPgZdRi++K2Rq
KX7LEQTONpkfm0brPj4mZQjOwU2iQRdytwQrE15mMjqvAjQuZLDyYuPmyCiz6YeQ
LdbC7oJC0n9LX23H97mTHiuq3AXZzskt5twrL9a4ol3mBSPopyiGM78/qIoqXI5k
Vz4pu8pxwm6VEyHeShWBFTi+Xw2mlSE7q2JiBEug2IZAY9qI8yrKj29rFvYw1JlE
v/ur2emLJtWsCudzr0eNgjoQqHC/aRu41LtAfJA1rJzwdRwrod6zE0plvWTNVkTG
zDTqNl4OVmIifTK9Kg==
=CxhJ
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [GIT PULL] Rust `hrtimer` support for v6.15
2025-03-22 11:15 ` Andreas Hindborg
@ 2025-03-25 23:22 ` Miguel Ojeda
2025-03-25 23:24 ` Miguel Ojeda
1 sibling, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2025-03-25 23:22 UTC (permalink / raw)
To: Andreas Hindborg
Cc: Miguel Ojeda, Anna-Maria Behnsen, Frederic Weisbecker,
Thomas Gleixner, linux-kernel, rust-for-linux@vger.kernel.org
On Sat, Mar 22, 2025 at 12:16 PM Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
> I'm sorry, but I have to do another update. My usual workflow missed a
> clippy warning because it depends on clippy warnings being treated as
> errors when building with `W=e`. I forgot that is not upstream yet.
No worries at all :)
All seems fine in the latest -next, which is also free from other
issues we had in the past few days.
I don't think you need to sign the message itself -- it is rare, but
it does not hurt.
Congratulations on your first PR!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] Rust `hrtimer` support for v6.15
2025-03-22 11:15 ` Andreas Hindborg
2025-03-25 23:22 ` Miguel Ojeda
@ 2025-03-25 23:24 ` Miguel Ojeda
1 sibling, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2025-03-25 23:24 UTC (permalink / raw)
To: Andreas Hindborg
Cc: Miguel Ojeda, Anna-Maria Behnsen, Frederic Weisbecker,
Thomas Gleixner, linux-kernel, rust-for-linux@vger.kernel.org
On Sat, Mar 22, 2025 at 12:16 PM Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
> https://github.com/rust-for-linux/linux.git tags/rust-hrtimer-for-v6.15-v3
Merged into `rust-next` -- thank you!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] Rust `hrtimer` support for v6.15
2025-03-21 12:10 ` Andreas Hindborg
2025-03-22 11:15 ` Andreas Hindborg
@ 2025-03-25 20:03 ` Miguel Ojeda
1 sibling, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2025-03-25 20:03 UTC (permalink / raw)
To: Andreas Hindborg
Cc: Miguel Ojeda, Anna-Maria Behnsen, Frederic Weisbecker,
Thomas Gleixner, linux-kernel, rust-for-linux@vger.kernel.org
On Fri, Mar 21, 2025 at 1:14 PM Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
> As discussed, I fixed the UB you fund in:
>
> rust: hrtimer: allow timer restart from timer handler
>
> by casting to `u32` when assigning enum values. The commits below this
> commit are unchanged, the later commits were replayed on top of the
> changed commit.
I reduced it and filled an issue upstream:
https://github.com/rust-lang/rust-bindgen/issues/3179
And I sent a potential patch to deal with this cleanly in a single
place (as long as the C headers allow for it, which in your case it
does), please see:
https://lore.kernel.org/rust-for-linux/20250325184309.97170-1-ojeda@kernel.org/
By the way, it wasn't UB, no? i.e. the UB one was the parsing patch on
the modules series, which we discussed roughly at the same time.
I hope that helps!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-03-25 23:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13 13:09 [GIT PULL] Rust `hrtimer` support for v6.15 Andreas Hindborg
2025-03-21 12:10 ` Andreas Hindborg
2025-03-22 11:15 ` Andreas Hindborg
2025-03-25 23:22 ` Miguel Ojeda
2025-03-25 23:24 ` Miguel Ojeda
2025-03-25 20:03 ` Miguel Ojeda
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.