Skip to content

rust/kernel: chrdev: remove unnecessary pinning - #304

Closed
TheSven73 wants to merge 1 commit into
Rust-for-Linux:rustfrom
TheSven73:rust-for-linux-remove-pin
Closed

rust/kernel: chrdev: remove unnecessary pinning#304
TheSven73 wants to merge 1 commit into
Rust-for-Linux:rustfrom
TheSven73:rust-for-linux-remove-pin

Conversation

@TheSven73

Copy link
Copy Markdown
Collaborator

chrdev's Registration and RegistrationInner do not contain any
self-referential or borrowed-with-kernel structures. Therefore they
do not require pinning.

Remove all pinning. This simplifies the code greatly, and eliminates
an unsafe block, and a fallible Box allocation.

As part of this commit, also update chrdev client drivers.

Signed-off-by: Sven Van Asbroeck thesven73@gmail.com

`chrdev`'s `Registration` and `RegistrationInner` do not contain any
self-referential or borrowed-with-kernel structures. Therefore they
do not require pinning.
Remove all pinning. This simplifies the code greatly, and eliminates
an unsafe block, and a fallible `Box` allocation.
As part of this commit, also update `chrdev` client drivers.
Signed-off-by: Sven Van Asbroeck <thesven73@gmail.com>
@ksquirrel

Copy link
Copy Markdown
Member

Review of aae24e980c83:

@nbdd0121

Copy link
Copy Markdown
Member

I think we should keep the pinning, and use cdev_init instead of cdev_alloc. This removes an indirection and an allocation.

@TheSven73

Copy link
Copy Markdown
CollaboratorAuthor

I'm in the process of learning about pinning. Can folks confirm that the pinning is indeed redundant here? I'm not 100% sure myself.

If so, then pinning can be removed. Next, the question arises whether it should be removed. That's a different question altogether :)

@nbdd0121

Copy link
Copy Markdown
Member

Pinning essentially means that a stable address is wanted and the object cannot be freely moved. So miscdev requires pinning because it contains a bindings::miscdevice. chrdev does not currently requires pinning, because it only contains pointers to bindings::cdev. So yes, it can be removed.

But I think we probably want to remove this indirection, and let RegistrationInner contains bindings::cdev instead. If we do that, then pinning would be required. So I think we probably shouldn't remove pinning for now.

@TheSven73

Copy link
Copy Markdown
CollaboratorAuthor

Very simple to do - just revert #207

@nbdd0121

Copy link
Copy Markdown
Member

Ah, sorry, I am not aware of the PR.

We could make RegistrationInner itself a kobject and the parent of cdev it contains though? I am just pointing out reasons that we might want it pinned, not that we should or should not make the change.

@TheSven73

Copy link
Copy Markdown
CollaboratorAuthor

@ojeda How can I assign a "Prio: low" label to this PR?

@ojeda

Copy link
Copy Markdown
Member

Let me give you Triage permissions :)

@TheSven73

Copy link
Copy Markdown
CollaboratorAuthor

No consensus that this is worthwhile.

@TheSven73
TheSven73 deleted the rust-for-linux-remove-pin branch July 8, 2021 13:12
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@TheSven73@ksquirrel@nbdd0121@ojeda