tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Introduce curlwp_bind and curlwp_unbind for psref(9)
On Fri, Jun 17, 2016 at 12:57 PM, Matt Thomas <matt%3am-software.com@localhost> wrote:
>
>> On Jun 13, 2016, at 5:53 PM, Ryota Ozaki <ozaki-r%netbsd.org@localhost> wrote:
>>
>> On Mon, Jun 13, 2016 at 11:21 PM, Taylor R Campbell
>> <campbell+netbsd-tech-kern%mumble.net@localhost> wrote:
>>> Date: Mon, 13 Jun 2016 14:00:16 +0200
>>> From: Joerg Sonnenberger <joerg%bec.de@localhost>
>>>
>>> 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).
Home |
Main Index |
Thread Index |
Old Index