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

2016-07-17 Thread Paul Goyette

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 |
+--+--++


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

2016-07-17 Thread matthew green
"Paul Goyette" writes:
> Module Name:  src
> Committed By: pgoyette
> Date: Mon Jul 18 03:50:00 UTC 2016
> 
> Modified Files:
>   src/sys/dev [pgoyette-localcount]: audio.c cgd.c fss.c ld.c md.c
>   rndpseudo.c vnd.c
>   src/sys/dev/dm [pgoyette-localcount]: device-mapper.c
>   src/sys/dev/pci [pgoyette-localcount]: pci_usrreq.c
>   src/sys/dev/scsipi [pgoyette-localcount]: cd.c sd.c
>   src/sys/dev/sysmon [pgoyette-localcount]: sysmon.c
>   src/sys/dev/usb [pgoyette-localcount]: ucom.c ulpt.c
>   src/sys/dev/wscons [pgoyette-localcount]: wskbd.c wsmouse.c
>   src/sys/kern [pgoyette-localcount]: kern_drvctl.c tty_ptm.c tty_pty.c
>   tty_tty.c
>   src/sys/net [pgoyette-localcount]: if_tap.c
>   src/sys/net/npf [pgoyette-localcount]: npf.c
>   src/sys/opencrypto [pgoyette-localcount]: cryptodev.c
>   src/sys/rump/librump/rumpvfs [pgoyette-localcount]: devnull.c rumpblk.c
> 
> 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.

thanks.


.mrg.