Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

re: CVS commit: [pgoyette-localcount] src/sys



On Mon, 18 Jul 2016, matthew green wrote:

Log Message:
Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.

can you explain why every driver needs to be modified for localcount?

naively, it seems like a rather odd thing to require changes to every
devsw driver.

The localcount(9) mechanism is being (or, going to be) used by devsw_detach() to ensure that there are no active uses. Without this, the driver can be detached while other uses are in-flight.

It would have been much easier if devsw_attach() could have magically allocated the localcount on behalf of the drivers, but that wouldn't work because the {b,c}devsw structures are marked const throughout the kernel.

Note that the localcount is only allocated when the driver is being built as a module (including rump component/module). Built-in drivers will not incur any additional overhead.

There are currently "timing windows" (albeit short ones) in all of these drivers where the device can be deallocated and data structure memory re-used by "other things". Strange things can happen.

There are other timing windows, too. A driver's code/module currently can be removed from the autoconf tree while the code is still using its data structures - pointers to the driver's softc are an especially vulnerable issue. The autoconf() stuff is also being adapted to use localcount(9) to prevent this. (And a more-ambitious driver roto-till will be needed to implement the autoconf use-case.)

One final note: as of this moment, the "localcount" mechanism is only a proof-of-concept. I have no plans to merge this into main-line without significant discussion. (And, since he designed and did the initial implementation, I'd hope the Taylor takes a big part in those discussions!)

Hope this addresses your concerns. If not, I know you'll follow up with more questions!


+------------------+--------------------------+------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+


Home | Main Index | Thread Index | Old Index