* [PATCH] rust: workqueue: define built-in bh queues
@ 2025-02-21 22:35 Hamza Mahfooz
2025-02-21 22:45 ` Miguel Ojeda
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Hamza Mahfooz @ 2025-02-21 22:35 UTC (permalink / raw)
To: rust-for-linux
Cc: Hamza Mahfooz, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
We provide these methods because it lets us access these queues from
Rust without using unsafe code.
Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
---
rust/kernel/workqueue.rs | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
index 0cd100d2aefb..68ce70d94f2d 100644
--- a/rust/kernel/workqueue.rs
+++ b/rust/kernel/workqueue.rs
@@ -703,3 +703,21 @@ pub fn system_freezable_power_efficient() -> &'static Queue {
// SAFETY: `system_freezable_power_efficient_wq` is a C global, always available.
unsafe { Queue::from_raw(bindings::system_freezable_power_efficient_wq) }
}
+
+/// Returns the system bottom halves work queue (`system_bh_wq`).
+///
+/// It is similar to the one returned by [`system`] but for work items which
+/// need to run from a softirq context.
+pub fn system_bh() -> &'static Queue {
+ // SAFETY: `system_bh_wq` is a C global, always available.
+ unsafe { Queue::from_raw(bindings::system_bh_wq) }
+}
+
+/// Returns the system bottom halves high-priority work queue (`system_bh_highpri_wq`).
+///
+/// It is similar to the one returned by [`system_bh`] but for work items which
+/// require higher scheduling priority.
+pub fn system_bh_highpri() -> &'static Queue {
+ // SAFETY: `system_bh_highpri_wq` is a C global, always available.
+ unsafe { Queue::from_raw(bindings::system_bh_highpri_wq) }
+}
--
2.47.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-21 22:35 [PATCH] rust: workqueue: define built-in bh queues Hamza Mahfooz
@ 2025-02-21 22:45 ` Miguel Ojeda
2025-02-22 4:17 ` Jarkko Sakkinen
2025-02-22 4:15 ` Jarkko Sakkinen
2025-02-24 17:19 ` Tejun Heo
2 siblings, 1 reply; 11+ messages in thread
From: Miguel Ojeda @ 2025-02-21 22:45 UTC (permalink / raw)
To: Hamza Mahfooz, Tejun Heo, Lai Jiangshan
Cc: rust-for-linux, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
On Fri, Feb 21, 2025 at 11:36 PM Hamza Mahfooz
<hamzamahfooz@linux.microsoft.com> wrote:
>
> We provide these methods because it lets us access these queues from
> Rust without using unsafe code.
>
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
Cc'ing WORKQUEUE -- thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-21 22:35 [PATCH] rust: workqueue: define built-in bh queues Hamza Mahfooz
2025-02-21 22:45 ` Miguel Ojeda
@ 2025-02-22 4:15 ` Jarkko Sakkinen
2025-02-22 11:53 ` Miguel Ojeda
2025-02-24 17:19 ` Tejun Heo
2 siblings, 1 reply; 11+ messages in thread
From: Jarkko Sakkinen @ 2025-02-22 4:15 UTC (permalink / raw)
To: Hamza Mahfooz
Cc: rust-for-linux, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
On Fri, Feb 21, 2025 at 05:35:31PM -0500, Hamza Mahfooz wrote:
> We provide these methods because it lets us access these queues from
> Rust without using unsafe code.
>
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
Just getting familiar how code testing and reviews go with Rust code,
as I might put out even a driver at some point of time, so let's give
this a shot :-)
Using 1st person plural is usually almost a cardinal sin almost and is
somewhat exhausting to read. "These methods" refer to nothing and the
commit message does not educate me why the accessors are needed.
It should be IMHO language agnostic that commit message is more
important than the source code. It weights now even more than ever
before because it is also AI acid test. The current commit message
is as good as it did not exist at all.
Based on these conclusions I'd start the commit message by saying
that "Provide safe accessors to the workqueue bottom-halves."
Then add another sentence on why they are required (i.e. who will
be the caller for these).
BR, Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-21 22:45 ` Miguel Ojeda
@ 2025-02-22 4:17 ` Jarkko Sakkinen
2025-02-22 4:37 ` Jarkko Sakkinen
0 siblings, 1 reply; 11+ messages in thread
From: Jarkko Sakkinen @ 2025-02-22 4:17 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Hamza Mahfooz, Tejun Heo, Lai Jiangshan, rust-for-linux,
Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
On Fri, Feb 21, 2025 at 11:45:38PM +0100, Miguel Ojeda wrote:
> On Fri, Feb 21, 2025 at 11:36 PM Hamza Mahfooz
> <hamzamahfooz@linux.microsoft.com> wrote:
> >
> > We provide these methods because it lets us access these queues from
> > Rust without using unsafe code.
> >
> > Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
>
> Cc'ing WORKQUEUE -- thanks!
Not meaning to complain but it by practical has no commit message.
Does not meet any quality standards in that area tbh. In order to
make Rust more appealing you really should pay more attention to
this.
I learned absolutely nothing from this.
>
> Cheers,
> Miguel
>
BR, Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-22 4:17 ` Jarkko Sakkinen
@ 2025-02-22 4:37 ` Jarkko Sakkinen
2025-02-22 4:41 ` Boqun Feng
0 siblings, 1 reply; 11+ messages in thread
From: Jarkko Sakkinen @ 2025-02-22 4:37 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Hamza Mahfooz, Tejun Heo, Lai Jiangshan, rust-for-linux,
Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
On Sat, Feb 22, 2025 at 06:17:41AM +0200, Jarkko Sakkinen wrote:
> On Fri, Feb 21, 2025 at 11:45:38PM +0100, Miguel Ojeda wrote:
> > On Fri, Feb 21, 2025 at 11:36 PM Hamza Mahfooz
> > <hamzamahfooz@linux.microsoft.com> wrote:
> > >
> > > We provide these methods because it lets us access these queues from
> > > Rust without using unsafe code.
> > >
> > > Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
> >
> > Cc'ing WORKQUEUE -- thanks!
>
> Not meaning to complain but it by practical has no commit message.
oops, sorry, "... but by practical means it ..."
Anyway I hope my message was received ;-) Leaves me wonder tho why
this was queued because it apparently is not even part of a patch
set. "zero callers" should never be merged to mainline...
If however such patch is merged, the commit message should probably
address this exceptional condition.
R, Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-22 4:37 ` Jarkko Sakkinen
@ 2025-02-22 4:41 ` Boqun Feng
2025-02-22 6:04 ` Jarkko Sakkinen
0 siblings, 1 reply; 11+ messages in thread
From: Boqun Feng @ 2025-02-22 4:41 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Miguel Ojeda, Hamza Mahfooz, Tejun Heo, Lai Jiangshan,
rust-for-linux, Miguel Ojeda, Alex Gaynor, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
On Sat, Feb 22, 2025 at 06:37:06AM +0200, Jarkko Sakkinen wrote:
> On Sat, Feb 22, 2025 at 06:17:41AM +0200, Jarkko Sakkinen wrote:
> > On Fri, Feb 21, 2025 at 11:45:38PM +0100, Miguel Ojeda wrote:
> > > On Fri, Feb 21, 2025 at 11:36 PM Hamza Mahfooz
> > > <hamzamahfooz@linux.microsoft.com> wrote:
> > > >
> > > > We provide these methods because it lets us access these queues from
> > > > Rust without using unsafe code.
> > > >
> > > > Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
> > >
> > > Cc'ing WORKQUEUE -- thanks!
> >
> > Not meaning to complain but it by practical has no commit message.
>
> oops, sorry, "... but by practical means it ..."
>
> Anyway I hope my message was received ;-) Leaves me wonder tho why
> this was queued because it apparently is not even part of a patch
What do you mean by "queued"? IIUC, Miguel was just copying workqueue
maintainers, since they should be in the review process.
Thanks for your review in another email anyway!
Regards,
Boqun
> set. "zero callers" should never be merged to mainline...
>
> If however such patch is merged, the commit message should probably
> address this exceptional condition.
>
> R, Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-22 4:41 ` Boqun Feng
@ 2025-02-22 6:04 ` Jarkko Sakkinen
2025-02-22 11:57 ` Miguel Ojeda
0 siblings, 1 reply; 11+ messages in thread
From: Jarkko Sakkinen @ 2025-02-22 6:04 UTC (permalink / raw)
To: Boqun Feng
Cc: Miguel Ojeda, Hamza Mahfooz, Tejun Heo, Lai Jiangshan,
rust-for-linux, Miguel Ojeda, Alex Gaynor, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
On Fri, 2025-02-21 at 20:41 -0800, Boqun Feng wrote:
> On Sat, Feb 22, 2025 at 06:37:06AM +0200, Jarkko Sakkinen wrote:
> > On Sat, Feb 22, 2025 at 06:17:41AM +0200, Jarkko Sakkinen wrote:
> > > On Fri, Feb 21, 2025 at 11:45:38PM +0100, Miguel Ojeda wrote:
> > > > On Fri, Feb 21, 2025 at 11:36 PM Hamza Mahfooz
> > > > <hamzamahfooz@linux.microsoft.com> wrote:
> > > > >
> > > > > We provide these methods because it lets us access these
> > > > > queues from
> > > > > Rust without using unsafe code.
> > > > >
> > > > > Signed-off-by: Hamza Mahfooz
> > > > > <hamzamahfooz@linux.microsoft.com>
> > > >
> > > > Cc'ing WORKQUEUE -- thanks!
> > >
> > > Not meaning to complain but it by practical has no commit
> > > message.
> >
> > oops, sorry, "... but by practical means it ..."
> >
> > Anyway I hope my message was received ;-) Leaves me wonder tho why
> > this was queued because it apparently is not even part of a patch
>
> What do you mean by "queued"? IIUC, Miguel was just copying workqueue
> maintainers, since they should be in the review process.
>
> Thanks for your review in another email anyway!
Ah sorry! I have dyslexia (for real) and I did read that the patch
was queued :-) Thanks for correcting and please do also the next
time!
I spent also last 48h awake setting up my personal Rust development
and QA environment... [1]
Anyway, to soften my feedback a bit I'll say this: everything else was
great:
1. Code was great
2. It was commented like you'd expect.
And I don't have much to complain about code quality in any other
patches I've seen so far.
I've been silently following this list for some time and this is a
common problem that the commit messages are quite bad. Thus, I even
wrote a public post about the topic now that I had this in mind:
https://social.kernel.org/notice/ArMk27Ism4Citb90K0
There's two great arguments to improve across the board:
1. Education
2. Integrity. E.g. AI is actually acceptable for short a patch, if
you can in detail unmask the implementation (as is e.g. Windows
notepad or really anything that produces text). But AI can be also
used to engineer harmless looking changes that are actually vulns.
By being punctual in expalanations we also contribute to the
governance of our ecosystem.
I'm personally reading this list exactly for learning purposes because I
have a roadmap to Rust driver ongoing, and explanations even in trivial
things help to gather bits and pieces... So please help me to succeed
by doing just a tiny bit more effort ;-)
> Regards,
> Boqun
[1] https://codeberg.org/jarkko/linux-tpmdd-nixos
BR, Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-22 4:15 ` Jarkko Sakkinen
@ 2025-02-22 11:53 ` Miguel Ojeda
0 siblings, 0 replies; 11+ messages in thread
From: Miguel Ojeda @ 2025-02-22 11:53 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Hamza Mahfooz, rust-for-linux, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Wedson Almeida Filho,
Nell Shamrell-Harrington, Dirk Behme, Konstantin Andrikopoulos,
Danilo Krummrich, Roland Xu, linux-kernel
On Sat, Feb 22, 2025 at 5:15 AM Jarkko Sakkinen <jarkko@kernel.org> wrote:
>
> Using 1st person plural is usually almost a cardinal sin almost and is
> somewhat exhausting to read.
Using "we" is far from a "cardinal sin" -- even key maintainers use it
sometimes.
Yes, commits should be generally written using the imperative,
especially for the sentence about the actual change itself, but it is
more natural in some cases to use "we".
> "These methods" refer to nothing
"These methods" refer to the ones added in the commit -- that seems clear to me.
They are not "methods", though (that is wrong), but apart from that, I
am not sure what the issue is with those two words.
To be clear, this does not mean the commit message is good -- I agree
that it should provide more justification.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-22 6:04 ` Jarkko Sakkinen
@ 2025-02-22 11:57 ` Miguel Ojeda
2025-02-24 17:26 ` Tejun Heo
0 siblings, 1 reply; 11+ messages in thread
From: Miguel Ojeda @ 2025-02-22 11:57 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Boqun Feng, Hamza Mahfooz, Tejun Heo, Lai Jiangshan,
rust-for-linux, Miguel Ojeda, Alex Gaynor, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
On Sat, Feb 22, 2025 at 7:04 AM Jarkko Sakkinen <jarkko@kernel.org> wrote:
>
> Ah sorry! I have dyslexia (for real) and I did read that the patch
> was queued :-) Thanks for correcting and please do also the next
> time!
>
> I spent also last 48h awake setting up my personal Rust development
> and QA environment... [1]
Dyslexia and lack of sleep do not excuse yourself claiming anything
about "quality standards" of others and asking them to "really pay
more attention" as you did in the other message.
Even if you thought the patch was queued, you could have easily
checked whether it was merged or not before sending these messages.
Moreover, even if it was queued, the commit message could have been
fixed by the maintainer.
Finally, even if a maintainer applied it without fixing the message,
your message is uncalled for, both in tone and the in the fact that it
could have been a particular instance.
> I've been silently following this list for some time and this is a
> common problem that the commit messages are quite bad. Thus, I even
> wrote a public post about the topic now that I had this in mind:
>
> https://social.kernel.org/notice/ArMk27Ism4Citb90K0
This is, again, uncalled for.
We get a lot of new kernel contributors in the Rust for Linux mailing
list -- it is to be expected that their first few patches are not
great.
We do not control who posts to the mailing list, nor should we, and I
hope you are not trying to imply that the actual commit messages in
the branch are bad.
We have commit messages that are _pages_ long sometimes. We try to
follow the rules for every tag every single time. Same for tags sent
to mainline. So what are you talking about?
You suggest "Education" -- we have spent a *ton* of time teaching
newcomers how to contribute, how to write commit messages, how tags
work, etc. Not just in the mailing list, but in our Zulip and in
private too. Others can attest to this.
Moreover, I do take issue with your social media post. You claim:
"Rust kernel patches should really level up on commit messages and
not merging random code with zero callers."
We do _not_ merge random code. In fact, my message above was Cc'ing
workqueue precisely because we do not just randomly merge code.
Not just that -- if you had actually checked the Git log, you would
have seen that Tejun himself merged the bulk of the content in that
file. So it seems now you have just blamed two different subsystems
entirely.
Regarding "zero callers": that is the usual rule, yes, but it can
happen when there are expected users in the future, and in the end it
is up to the judgement of the maintainers. For instance, in this file,
there are other queues that do not have users yet.
As for the rest of your social media post, I will ignore it before I rant more.
Thank you.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-21 22:35 [PATCH] rust: workqueue: define built-in bh queues Hamza Mahfooz
2025-02-21 22:45 ` Miguel Ojeda
2025-02-22 4:15 ` Jarkko Sakkinen
@ 2025-02-24 17:19 ` Tejun Heo
2 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2025-02-24 17:19 UTC (permalink / raw)
To: Hamza Mahfooz
Cc: rust-for-linux, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
On Fri, Feb 21, 2025 at 05:35:31PM -0500, Hamza Mahfooz wrote:
> We provide these methods because it lets us access these queues from
> Rust without using unsafe code.
>
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
Acked-by: Tejun Heo <tj@kernel.org>
Please feel free to route it through rust tree. If you'd prefer it to be
routed to workqueue tree, please let me know.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] rust: workqueue: define built-in bh queues
2025-02-22 11:57 ` Miguel Ojeda
@ 2025-02-24 17:26 ` Tejun Heo
0 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2025-02-24 17:26 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Jarkko Sakkinen, Boqun Feng, Hamza Mahfooz, Lai Jiangshan,
rust-for-linux, Miguel Ojeda, Alex Gaynor, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
linux-kernel
On Sat, Feb 22, 2025 at 12:57:03PM +0100, Miguel Ojeda wrote:
...
> Moreover, I do take issue with your social media post. You claim:
>
> "Rust kernel patches should really level up on commit messages and
> not merging random code with zero callers."
>
> We do _not_ merge random code. In fact, my message above was Cc'ing
> workqueue precisely because we do not just randomly merge code.
>
> Not just that -- if you had actually checked the Git log, you would
> have seen that Tejun himself merged the bulk of the content in that
> file. So it seems now you have just blamed two different subsystems
> entirely.
>
> Regarding "zero callers": that is the usual rule, yes, but it can
> happen when there are expected users in the future, and in the end it
> is up to the judgement of the maintainers. For instance, in this file,
> there are other queues that do not have users yet.
FWIW, the commit message could be better but at the same time I'm not sure
commit message bar is any higher for C patches for something this trivial.
As for no-immediate-user policy, yes, generally true but again it's sometims
a necessity or just more convenient to merge these API patches separately -
e.g. features straddling across subsystems, straightforward prep patches and
so on. So, that's the *general* rule but rules without flexibility are often
silly things and it's not like culling these trivial wrappers afterwards is
difficult.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-02-24 17:26 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 22:35 [PATCH] rust: workqueue: define built-in bh queues Hamza Mahfooz
2025-02-21 22:45 ` Miguel Ojeda
2025-02-22 4:17 ` Jarkko Sakkinen
2025-02-22 4:37 ` Jarkko Sakkinen
2025-02-22 4:41 ` Boqun Feng
2025-02-22 6:04 ` Jarkko Sakkinen
2025-02-22 11:57 ` Miguel Ojeda
2025-02-24 17:26 ` Tejun Heo
2025-02-22 4:15 ` Jarkko Sakkinen
2025-02-22 11:53 ` Miguel Ojeda
2025-02-24 17:19 ` Tejun Heo
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).