Re: [TECH TOPIC] Rust for Linux

Andy Lutomirski
2021-07-10T17:18:31Z

On Sat, Jul 10, 2021 at 9:43 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> On Thu, Jul 08, 2021 at 11:08:52AM +0200, Mauro Carvalho Chehab wrote:
> > Em Wed, 7 Jul 2021 20:17:08 +0300 Laurent Pinchart escreveu:
>
> > So, for instance, a regulator driver probably can use devm_* without
> > any issues, as it doesn't seem to make much sense to unbind a regulator
> > once the device was probed. On drivers like that, not using devm_*
> > would just make the probing part of the driver more complex, without
> > bringing any real benefit.
>
> Don't forget that regulators, GPIO controllers and other such core
> resources can be part of unpluggable devices.

It sounds like this type of use might be a good fit for a simple
precise garbage collector. This could be arranged in C in a
reasonably safe way (with the assistance of sparse, perhaps). Every
struct that could contain a GC pointer to a device would have a
special attribute, and the whole graph of devices could be walked as
needed to collect garbage.

Alternatively, weak references might be a good fit for this,
especially if hotplug is involved. If a device gets hot-unplugged
without warning, every subsequent attempt to follow a weak reference
to that device could be made to fail.

--Andy