mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/2] rust: Add read_poll_timeout
@ 2025-08-21  0:20 FUJITA Tomonori
  2025-08-21  0:20 ` [PATCH v3 1/2] rust: Add cpu_relax() helper FUJITA Tomonori
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: FUJITA Tomonori @ 2025-08-21  0:20 UTC (permalink / raw)
  To: a.hindborg, alex.gaynor, ojeda
  Cc: aliceryhl, anna-maria, bjorn3_gh, boqun.feng, dakr, frederic,
	gary, jstultz, linux-kernel, lossin, lyude, rust-for-linux,
	sboyd, tglx, tmgross, acourbot, daniel.almeida

Add a helper function to poll periodically until a condition is met or
a timeout is reached.

This patch was previously reviewed as part of another patchset [1] but
was removed to expedite merging into the mainline. Now that all the
features it depends on have been merged into the mainline, it is being
reposted as a new independent patchset.

I put this function kernel/io/poll.rs. This function is not
necessarily related to I/O though. I don't think this function
perfectly matches the existing abstraction. Suggestions for a more
appropriate place are welcome.

v3
- update the comments
v2: https://lore.kernel.org/lkml/20250817044724.3528968-1-fujita.tomonori@gmail.com/
- make cpu_relax() inline
- remove the example code to call might_sleep with a lock hold
- move kernel/time/poll.rs to kernel/io/poll.rs
- remove the Option for timeout argument
- avoid the extra variable, sleep.
- update the comment and commit message
- writing closures directly inline in the example code
v1: https://lore.kernel.org/lkml/20250811041039.3231548-1-fujita.tomonori@gmail.com/
The changes since the last posting [2] are
- removed might_sleep() change since it was already merged separately.
- split out cpu_relax() in a separate patch
- make the example code compilable
- update the code to use Clocksource (MONOTONIC)
- call might_sleep() always (even when the function doesn't sleep)
- cosmetic changes to the doc

[1] https://lore.kernel.org/lkml/20250207132623.168854-1-fujita.tomonori@gmail.com/
[2] https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/


FUJITA Tomonori (2):
  rust: Add cpu_relax() helper
  rust: Add read_poll_timeout function

 rust/helpers/helpers.c   |   1 +
 rust/helpers/processor.c |   8 +++
 rust/kernel/io.rs        |   1 +
 rust/kernel/io/poll.rs   | 104 +++++++++++++++++++++++++++++++++++++++
 rust/kernel/lib.rs       |   1 +
 rust/kernel/processor.rs |  14 ++++++
 6 files changed, 129 insertions(+)
 create mode 100644 rust/helpers/processor.c
 create mode 100644 rust/kernel/io/poll.rs
 create mode 100644 rust/kernel/processor.rs


base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-21 19:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-21  0:20 [PATCH v3 0/2] rust: Add read_poll_timeout FUJITA Tomonori
2025-08-21  0:20 ` [PATCH v3 1/2] rust: Add cpu_relax() helper FUJITA Tomonori
2025-08-21 14:41   ` Miguel Ojeda
2025-08-21  0:20 ` [PATCH v3 2/2] rust: Add read_poll_timeout function FUJITA Tomonori
2025-08-21 19:39 ` [PATCH v3 0/2] rust: Add read_poll_timeout Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®