Re: Is it possible to employ epoch to simplify managing prison lifecycle

From: Mateusz Guzik <mjguzik_at_gmail.com>
Date: Fri, 23 Dec 2022 15:27:53 UTC
On 12/23/22, Alexander V. Chernikov <melifaro@ipfw.ru> wrote:
>
>
>> On 16 Dec 2022, at 16:29, Mateusz Guzik <mjguzik@gmail.com> wrote:
>>
>> On 12/16/22, Zhenlei Huang <zlei.huang@gmail.com> wrote:
>>> Hi,
>>>
>>> While hacking `sys/kern/kern_jail.c` I got lost.
>>>
>>> There're lots of ref / unref and flags to prevent visit invalid prison
>>> while
>>> concurrent modification is possible and some refs looks weird.
>>>
>>> Is it possible to employ epoch(9) to simplify managing of prison
>>> lifecycle
>>> ?
>>>
>>
>> Some of the ref/unref cycles are probably avoidable to begin with, but
>> ultimately the thing to do here is to employ per-cpu reference
>> counting, if at all needed.
>>
>> I have a wip patch to provide such a mechanism, it may or may not land
>> this month.
> That would be nice. I’d love to convert nextops refcounting to that one.
> Do you envision similar semantics as Linux percpu_ref? I mean, does one need
> to explicitly mark “not in active use” stage?

There *something* needed to disable per-cpu operation, otherwise how
can you ever know if the count is 0, apart from going over all cpus
every time, which defeats the point.

More specifically, I have a on/off switch for said per-cpu op. This is
modeled after what I did for counters in vfs, see vfs_ref et al.

-- 
Mateusz Guzik <mjguzik gmail.com>