|
|
Subscribe / Log in / New account

More Rust concepts for the kernel

More Rust concepts for the kernel

Posted Sep 21, 2021 9:31 UTC (Tue) by pbonzini (subscriber, #60935)
In reply to: More Rust concepts for the kernel by roc
Parent article: More Rust concepts for the kernel

The main locking pattern that Mutexes don't model is where a single mutex protects many objects, which sometimes has better performance than extremely fine-grained locking. RCU also requires some custom smart pointers (such as https://github.com/bonzini/rust-rcu-qemu/blob/master/src/...).


to post comments

More Rust concepts for the kernel

Posted Sep 22, 2021 0:22 UTC (Wed) by roc (subscriber, #30627) [Link] (1 responses)

Normally you'd reorganize your data in that case so that the data protected by the mutex are all under one object. I guess for the kernel you can't always do that.

You may be able to use something similar to qcell to handle it --- https://docs.rs/qcell/0.4.3/qcell/index.html. Basically have a mutex that hands out an exclusively-owned access token, and the access token can be used to "lock" multiple protected data items without actually taking a lock.

More Rust concepts for the kernel

Posted Sep 22, 2021 0:23 UTC (Wed) by roc (subscriber, #30627) [Link]

I see mathstuf already suggested that, oops.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds