Skip to contentSkip to conversation

rust: fwctl: replace `__pinned_init` with `raw_try_init`

PATCH In review Miguel Ojeda 6 participants 13 messages Aug 18 – Aug 21

Subsystems (3)
lore
Share & tools
lore

Miguel Ojeda

author maintainer
#0 lore raw

PATCH 1/1 rust: fwctl: replace `__pinned_init` with `raw_try_init`

Commit

ea7da3116015 ("rust: treewide: replace __pinned_init with raw_[try_]init")

from the pin-init tree replaced the method before removing it, but commit

e052daab94ee ("rust: introduce abstractions for fwctl")

from the fwctl tree added a new use.

Thus replace that one as well to fix this error in next-20260817:

    error[E0599]: no method named `__pinned_init` found for associated type `impl pin_init::PinInit<T, error::Error>` in the current scope
       --> rust/kernel/fwctl.rs:465:49
        |
    465 |                 match T::open(device, reg_data).__pinned_init(uctx_ptr) {
        |                                                 ^^^^^^^^^^^^^ method not found in `impl pin_init::PinInit<T, error::Error>`
---
 rust/kernel/fwctl.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/fwctl.rs +1 -1
index e6a8513a47d0..f29244fb0d1d 100644
@@ -462,7 +462,7 @@ impl<T: Operations> VTable<T> {
         // `uctx_size`.
         unsafe {
             device.with_registration_data(|device, reg_data| {
-                match T::open(device, reg_data).__pinned_init(uctx_ptr) {
+                match pin_init::raw_try_init(uctx_ptr, T::open(device, reg_data)) {
                     Ok(()) => 0,
                     Err(e) => e.to_errno(),
                 }

base-commit: e6664f2b33db9b6811eb4cec109f06cb2b4f458d --
2.55.0

maintainer
#1 lore raw
Quoted 10 lines · Miguel Ojeda

Commit

ea7da3116015 ("rust: treewide: replace __pinned_init with raw_[try_]init")

from the pin-init tree replaced the method before removing it, but commit

e052daab94ee ("rust: introduce abstractions for fwctl")

from the fwctl tree added a new use.

Quoted 7 lines

Thus replace that one as well to fix this error in next-20260817:

    error[E0599]: no method named `__pinned_init` found for associated type `impl pin_init::PinInit<T, error::Error>` in the current scope
       --> rust/kernel/fwctl.rs:465:49
        |
    465 |                 match T::open(device, reg_data).__pinned_init(uctx_ptr) {
        |                                                 ^^^^^^^^^^^^^ method not found in `impl pin_init::PinInit<T, error::Error>`

If you delete functions like this then you break everyone elses branches :|

I can't use this patch:

465 | match pin_init::raw_try_init(uctx_ptr, T::open(device, reg_data)) {
| ^^^^^^^^^^^^ not found in pin_init

Linus will have to fix this as a merge conflict.

Jason

reviewer
#2 lore raw
Quoted 13 lines · Jason Gunthorpe
Quoted 12 lines · Miguel Ojeda

Commit

ea7da3116015 ("rust: treewide: replace __pinned_init with raw_[try_]init")

from the pin-init tree replaced the method before removing it, but commit

e052daab94ee ("rust: introduce abstractions for fwctl")

from the fwctl tree added a new use.

Thus replace that one as well to fix this error in next-20260817:

Quoted 7 lines
Quoted 5 lines
    error[E0599]: no method named `__pinned_init` found for associated type `impl pin_init::PinInit<T, error::Error>` in the current scope
       --> rust/kernel/fwctl.rs:465:49
        |
    465 |                 match T::open(device, reg_data).__pinned_init(uctx_ptr) {
        |                                                 ^^^^^^^^^^^^^ method not found in `impl pin_init::PinInit<T, error::Error>`

If you delete functions like this then you break everyone elses branches :|

I'm not sure how this break everyone elses' branches? It only breaks linux-next but that's why it exists in the first place, to catch tree conflicts.

Quoted 8 lines

I can't use this patch:

465 | match pin_init::raw_try_init(uctx_ptr, T::open(device, reg_data)) {
| ^^^^^^^^^^^^ not found in pin_init

Linus will have to fix this as a merge conflict.

This patch is sent as a semantic conflict resolution so yes it should be applied by Linus.

For the removal of the function: Initially I plan to do this removal for multiple cycles. However when I apply this near rc6 there wasn't any new users introducing the usage of it so I proceed to remove it the same cycle.

If we want to do a cycle's grace period then reverting commit 1f7fa1374d3b ("rust: pin-init: remove __pinned_init method for cfg(kernel)") should be sufficient. That said, I am not sure it's worth doing.

Best,
Gary

maintainer
#3 lore raw
Quoted 6 lines · Gary Guo
Quoted 5 lines · Jason Gunthorpe
Quoted 4 lines · Miguel Ojeda

Commit

ea7da3116015 ("rust: treewide: replace __pinned_init with raw_[try_]init")

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

from the pin-init tree replaced the method before removing it, but commit

e052daab94ee ("rust: introduce abstractions for fwctl")

from the fwctl tree added a new use.

Thus replace that one as well to fix this error in next-20260817:

[E0599]: no method named __pinned_init found for associated type impl pin_init::PinInit<T, error::Error> in the current scope

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
       --> rust/kernel/fwctl.rs:465:49
        |
    465 |                 match T::open(device, reg_data).__pinned_init(uctx_ptr) {
        |                                                 ^^^^^^^^^^^^^ method not found in `impl pin_init::PinInit<T, error::Error>`

If you delete functions like this then you break everyone elses branches :|

I'm not sure how this break everyone elses' branches? It only breaks linux-next but that's why it exists in the first place, to catch tree conflicts.

linux-next is to catch missed things, you shouldn't use it to purposefully cause conflicts during the merge window..

So for example introduce your new API and do some conversions, then remove the old API down the road after the merge window is a more expected work flow.

Quoted 10 lines
Quoted 7 lines

I can't use this patch:

465 | match pin_init::raw_try_init(uctx_ptr, T::open(device, reg_data)) {
| ^^^^^^^^^^^^ not found in pin_init

Linus will have to fix this as a merge conflict.

This patch is sent as a semantic conflict resolution so yes it should be applied by Linus.

That's not really how things work. Now Miguel and I both have to send Linus a pointer to this hunk because we don't know what order he will merge the branches in, and last one to get merged needs him to put this in the merge commit.

Quoted 3 lines

If we want to do a cycle's grace period then reverting commit 1f7fa1374d3b ("rust: pin-init: remove __pinned_init method for cfg(kernel)") should be sufficient. That said, I am not sure it's worth doing.

Probably not, but it doesn't hurt to understand the expected work flow as rust grows bigger.

Jason

reviewer
#4 lore raw
Quoted 20 lines · Jason Gunthorpe
Quoted 6 lines · Gary Guo
Quoted 5 lines · Jason Gunthorpe
Quoted 4 lines · Miguel Ojeda

Commit

ea7da3116015 ("rust: treewide: replace __pinned_init with raw_[try_]init")

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

from the pin-init tree replaced the method before removing it, but commit

e052daab94ee ("rust: introduce abstractions for fwctl")

from the fwctl tree added a new use.

Thus replace that one as well to fix this error in next-20260817:

[E0599]: no method named __pinned_init found for associated type impl pin_init::PinInit<T, error::Error> in the current scope

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
       --> rust/kernel/fwctl.rs:465:49
        |
    465 |                 match T::open(device, reg_data).__pinned_init(uctx_ptr) {
        |                                                 ^^^^^^^^^^^^^ method not found in `impl pin_init::PinInit<T, error::Error>`
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

If you delete functions like this then you break everyone elses branches :|

I'm not sure how this break everyone elses' branches? It only breaks linux-next but that's why it exists in the first place, to catch tree conflicts.

linux-next is to catch missed things, you shouldn't use it to purposefully cause conflicts during the merge window..

That is an accusation that I find unacceptable. The API removal commit lands in linux-next almost 10 days before you pick the Rust fwctl series. The conflict between rust and fwctl tree doesn't exist in next-20260814, the last linux-next tag before Miguel sent the PR to Linus. How come I am purposefully causing conflicts?

Quoted 3 lines

So for example introduce your new API and do some conversions, then remove the old API down the road after the merge window is a more expected work flow.

I'd happily keep the old API for an additional cycle before removing it, if I knew that there'll be additional users. However I couldn't predict that new users will be added late in the cycle after I sent my pull request.

Best,
Gary

maintainer
#5 lore raw
In reply to Jason Gunthorpe
Quoted 6 lines · Jason Gunthorpe
Quoted 3 lines · Gary Guo

I'm not sure how this break everyone elses' branches? It only breaks linux-next but that's why it exists in the first place, to catch tree conflicts.

Quoted 6 lines

linux-next is to catch missed things, you shouldn't use it to purposefully cause conflicts during the merge window..

So for example introduce your new API and do some conversions, then remove the old API down the road after the merge window is a more expected work flow.

So are these updates that are requiring frequent patching up aren't forced as a result of some Rust language thing but rather deliberate decisions? In that case I tend to agree with Jason, I'd not expect to see changes like these coming in during the merge window without a strong reason, and with C changes like these would normally be done in a much more coordinated fashion - for example an overlap period like Jason suggests, possibly with shared branches.

I'd been under the impression that the reason this was happening a lot with Rust was something to do with how the language works.

maintainer
#6 lore raw
Quoted 2 lines · Mark Brown

I'd been under the impression that the reason this was happening a lot with Rust was something to do with how the language works.

My impression is the rust team is still learning how best to apply rust to linux. So things land and get changed around with a healthy does of compile breaking changes. In a certain sense they are building a unique kernel specific dialect of rust as they go.

It's fine, and this particular case is managable, but my main point is as rust increases in scope a more accommodating process is needed to maintain the general kernel work flow.

Jason

#10 lore raw
In reply to Mark Brown
Quoted 10 lines · Mark Brown

So are these updates that are requiring frequent patching up aren't forced as a result of some Rust language thing but rather deliberate decisions? In that case I tend to agree with Jason, I'd not expect to see changes like these coming in during the merge window without a strong reason, and with C changes like these would normally be done in a much more coordinated fashion - for example an overlap period like Jason suggests, possibly with shared branches.

I'd been under the impression that the reason this was happening a lot with Rust was something to do with how the language works.

In general that is the case, the stronger type system makes it more difficult to avoid conflicts by preserving compatible APIs (which is also one reason why I work a lot with shared signed tags).

In this specific case it is indeed what Gary already explained; the API was removed and unexpectedly gained a new user.

maintainer
#11 lore raw
Quoted 2 lines · Danilo Krummrich

In this specific case it is indeed what Gary already explained; the API was removed and unexpectedly gained a new user.

Ah, OK. That's the sort of thing that -next is intended to catch, though it does sound like a shared branch for the removal would've been helpful to cope with people wanting to add new users of the removed API. It's also a bit surprising that a new user appeared during the merge window, I guess that's a last minute addition.

#12 lore raw
In reply to Jason Gunthorpe
Quoted 2 lines · Jason Gunthorpe

Linus will have to fix this as a merge conflict.

Yeah, I also warned Linus when I sent the patch:

https://lore.kernel.org/rust-for-linux/CANiq72=XMeKaO09PhYkwHwxXO6uv0dVpcxi3tAOLzrmnvA=EgA@mail.gmail.com/

He already merged the Rust PR earlier today, so if you can remind him, even better -- though I expect he is tracking the conflicts list I gave him since we have other unrelated semantic conflicts this time around.

Thanks!

Cheers,
Miguel

#7 lore raw
In reply to Jason Gunthorpe
Quoted 9 lines · Jason Gunthorpe

My impression is the rust team is still learning how best to apply rust to linux. So things land and get changed around with a healthy does of compile breaking changes. In a certain sense they are building a unique kernel specific dialect of rust as they go.

It's fine, and this particular case is managable, but my main point is as rust increases in scope a more accommodating process is needed to maintain the general kernel work flow.

So we have done that usual dance in the past, i.e. waiting a cycle or more to move users over time etc., but in this case it seemed like we could fix essentially all at once.

In other words, we do our best to avoid annoying others too much (especially Stephen in the past, and Mark and Linus), since Rust is not too common yet.

In Gary's defense, he definitely knows how that works -- in fact, the commit where he removed the method only did it for the Linux kernel (he has other users of that library, where he didn't remove the method just yet), i.e. he was definitely thinking about it! :)

In this case, we weren't expecting more to appear, so we went with it -- I could have asked him to wait a cycle, so it is also on me, but it seemed minor (easy diff and missing it is "only" a build error in certain cases), and Linus has been OK with us having minor semantic Rust conflicts from time to time. He even tries to fix the conflicts in Rust himself, just like in C, though he asks us for the test merge / diffs, for good reason, of course.

It is also true that, with Rust, as Mark mentioned, certain bits can be a bit more painful vs. C. One more example of that that we had to deal in the past is moving items across files even if identifiers do not change name, because Rust items have paths (modules, like C++ namespaces). But at least for those we can usually use what is called a re-export to expose the same item in two places etc.

I hope that clarifies, and sorry for the trouble!

Cheers,
Miguel

maintainer
#8 lore raw
Quoted 1 line · Miguel Ojeda

I hope that clarifies, and sorry for the trouble!

It is fine, just give it some thought. Your PR has a list of conflicts, and I saw one other of these pin ones there as well.

Imagine adoption making it 10x and it won't scale. If there are things to adjust in Rust or process or whatever now is probably a good time to work on it.

You don't want to end up stuck later on where you can't do the refactorings you want to do because of unmanageable merge conflicts!

Jason

#9 lore raw
Quoted 10 lines · Jason Gunthorpe

It is fine, just give it some thought. Your PR has a list of conflicts, and I saw one other of these pin ones there as well.

Imagine adoption making it 10x and it won't scale. If there are things to adjust in Rust or process or whatever now is probably a good time to work on it.

You don't want to end up stuck later on where you can't do the refactorings you want to do because of unmanageable merge conflicts!

Semantic conflicts are fairly rare for us so far -- this cycle we happened to have two reworks going on at the same time. Normal conflicts have also been fine and not too onerous either.

Given the treewide nature of the Rust tree, I think it is bound to happen from time to time, i.e. even in years from now. Part of the idea of the tree was precisely to handle this sort of change. It is also why sometimes I close the tree late.

Of course, I agree that if it multiplies wildly, then it doesn't scale. But we have been able to handle those in different ways so far.

At the end of the day, it is about striking a good balance. For things like this instance, where we have a couple one-liner conflicts, then it can be simpler to just close the change than a staged approach that we did other times, as long as Linus and Mark are OK with it (a year or two ago I asked Linus about possibly doing this kind of rework in a different manner, but we didn't need it so far).

In fact, the only "surprise" here was really the fwctl change that arrived after the merge window had already opened. Otherwise, this cycle would have been business as usual.

Cheers,
Miguel