Page MenuHomeFreeBSD

cuse: Implement hot-unload
ClosedPublic

Authored by christos on Fri, Sep 25, 11:50 AM.
Tags
None
Referenced Files
F174880929: D60022.id187862.diff
Tue, Oct 6, 6:02 PM
F174798664: D60022.diff
Tue, Oct 6, 1:45 AM
F174778150: D60022.diff
Mon, Oct 5, 10:47 PM
F174768006: D60022.diff
Mon, Oct 5, 9:06 PM
Unknown Object (File)
Mon, Oct 5, 12:29 AM
Unknown Object (File)
Sun, Oct 4, 7:20 PM
Unknown Object (File)
Sun, Oct 4, 5:24 PM
Unknown Object (File)
Sun, Oct 4, 4:59 PM
Subscribers

Details

Summary

cuse_kern_uninit() can hang on destroy_dev(), because of threads
sleeping in CUSE_IOCTL_GET_COMMAND, so wake them up before calling
destroy_dev(). Also do not allow threads to go back to sleep if the
is_closing flag has been set.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

Test Plan

Tested with virtual_oss:

root@freebsd:~ # service virtual_oss onestart
Starting virtual_oss config: dsp: hw.snd.basename_clone: 1 -> 0
done
root@freebsd:~ # ls /dev/dsp
/dev/dsp        /dev/dsp.dummy  /dev/dsp.loop   /dev/dsp0
root@freebsd:~ # kldunload cuse
root@freebsd:~ # ls /dev/dsp
/dev/dsp.dummy  /dev/dsp0
root@freebsd:~ # service virtual_oss onestop
Stopping virtual_oss config: dsp: done

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77318
Build 74201: arc lint + arc unit

Event Timeline

We have d_purge cdevsw method. It is invoked by destroy_dev(9) when it observes threads inside cdevsw methods, to release the sleep. Would it be useful for your purpose there?

In D60022#1377269, @kib wrote:

We have d_purge cdevsw method. It is invoked by destroy_dev(9) when it observes threads inside cdevsw methods, to release the sleep. Would it be useful for your purpose there?

I see only one use of d_purge in the tree. What I want is to wake up the server cv that's sleeping in CUSE_IOCTL_GET_COMMAND and set is_closing. I guess d_purge should be good, or is there something that might bite us?

In D60022#1377269, @kib wrote:

We have d_purge cdevsw method. It is invoked by destroy_dev(9) when it observes threads inside cdevsw methods, to release the sleep. Would it be useful for your purpose there?

I see only one use of d_purge in the tree. What I want is to wake up the server cv that's sleeping in CUSE_IOCTL_GET_COMMAND and set is_closing. I guess d_purge should be good, or is there something that might bite us?

Well, d_purge intent was specifically to expedite threads out of cdevsw methods on destroy_dev(). It is relatively delicate option so it was only used by the core tty infra AFAIR. So it should be good. I do not know of something that could bite (in advance).

Just a question, did you tested d_purge with the WITNESS kernel?

In D60022#1379019, @kib wrote:

Just a question, did you tested d_purge with the WITNESS kernel?

Yes, no warnings or panics.

This revision is now accepted and ready to land.Tue, Sep 29, 11:01 AM

Thanks, if you can, give D59872 a review as well and I will commit those now. :)

This revision was automatically updated to reflect the committed changes.