On Fri, Jun 17, 2016 at 12:57 PM, Matt Thomas <m...@3am-software.com> wrote: > >> On Jun 13, 2016, at 5:53 PM, Ryota Ozaki <ozak...@netbsd.org> wrote: >> >> On Mon, Jun 13, 2016 at 11:21 PM, Taylor R Campbell >> <campbell+netbsd-tech-k...@mumble.net> wrote: >>> Date: Mon, 13 Jun 2016 14:00:16 +0200 >>> From: Joerg Sonnenberger <jo...@bec.de> >>> >>> On Mon, Jun 13, 2016 at 07:36:31PM +0900, Ryota Ozaki wrote: >>>> Currently we do it by open-coding in each place, >>>> but we should provide some API to simplify codes. >>>> riastradh@ suggested curlwp_bind and curlwp_unbind >>>> some time ago (*1) and this patch (*2) just follows >>>> the idea. >>> >>> The primary question for me is whether nesting should be allowed or not. >>> That would mean a reference count behind the flag. >>> >>> This `reference count' gets stored on the stack. The caller does: >>> >>> int bound = curlwp_bind(); >>> >>> ... psref_wotsit ... >>> >>> curlwp_unbind(bound); >>> >>> If it was already bound, bound = 1 and curlwp_unbind does nothing; if >>> it was not already bound, bound = 0 and curlwp_unbind unbinds it. >>> >>> Perhaps the name should be `curlwp_bound_restore' or something else to >>> emphasize this, but I haven't come up with one that I like better on >>> aesthetic grounds. >> >> - curlwp_bind and curlwp_unbind >> - curlwp_bound_set and curlwp_bound_restore >> - curlwp_bound and curlwp_boundx >> >> Any other ideas? :) > > Since we already use preempt_disable() to force an lwp to stick to a cpu, > doesn't that solve the problem? If need be, we can enforce nonpreemptable > lwp's don't migrate.
+1 LP_BOUND (and LP_INTR) looks like a property, rather than a state, which is set only once when a kthread is created. (Except the one in panic(9); but usually "let's not do this after a panic" is done by sprinkling if (panicstr != NULL) ...) I'm thinking of if there are cases where preempt-disabled threads have to be migratable, but can't think of any (yet).