Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 May 2021 20:25:35 +0200
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org,  dev-commits-src-main@freebsd.org
Subject:   Re: git: b5fb9ae6872c - main - vfs: lockless writecount adjustment in set/unset text
Message-ID:  <CAGudoHHtXjkic%2BYpTQ78gv8uKh2M19qyd85qwpJaim61gkn4hw@mail.gmail.com>
In-Reply-To: <YJ67kVMW4jJV%2B3k8@kib.kiev.ua>
References:  <202105141423.14EENtDX058648@gitrepo.freebsd.org> <YJ67kVMW4jJV%2B3k8@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
Even tmpfs can go without the interlock. The code can check if it
transitioned across 0 and act accordingly and conditionally vref based
on that.

I did not check if said transition is safe without the interlock vs
other users, so I did not go for it. Arguably both exec and write
counts could be treated the same way, would have a side effect of
avoiding VI_LOCK_FLAGS(vp, MTX_DUPOK);. Maybe i'll look into it today
or tomorrow.

On 5/14/21, Konstantin Belousov <kostikbel@gmail.com> wrote:
> On Fri, May 14, 2021 at 02:23:55PM +0000, Mateusz Guzik wrote:
>> The branch main has been updated by mjg:
>>
>> URL:
>> https://cgit.FreeBSD.org/src/commit/?id=b5fb9ae6872c499f1a02bec41f48b163a73a2aaa
>>
>> commit b5fb9ae6872c499f1a02bec41f48b163a73a2aaa
>> Author:     Mateusz Guzik <mjg@FreeBSD.org>
>> AuthorDate: 2021-05-07 14:04:27 +0000
>> Commit:     Mateusz Guzik <mjg@FreeBSD.org>
>> CommitDate: 2021-05-14 14:22:21 +0000
>>
>>     vfs: lockless writecount adjustment in set/unset text
>>
>>     ... for cases where this is not the first/last exec.
>> ---
>>  sys/kern/vfs_default.c | 32 ++++++++++++++++++++++++++++++--
>>  1 file changed, 30 insertions(+), 2 deletions(-)
>>
>> diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
>> index cf224981cbe7..3518bbeaa279 100644
>> --- a/sys/kern/vfs_default.c
>> +++ b/sys/kern/vfs_default.c
>> @@ -1177,9 +1177,23 @@ vop_stdset_text(struct vop_set_text_args *ap)
>>  {
>>  	struct vnode *vp;
>>  	struct mount *mp;
>> -	int error;
>> +	int error, n;
>>
>>  	vp = ap->a_vp;
>> +
>> +	/*
>> +	 * Avoid the interlock if execs are already present.
>> +	 */
>> +	n = atomic_load_int(&vp->v_writecount);
>> +	for (;;) {
>> +		if (n > -1) {
>> +			break;
> If you split the VOP for tmpfs/non-tmpfs implementations, then
> non-tmpfs can go with the atomics only.
>


-- 
Mateusz Guzik <mjguzik gmail.com>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHHtXjkic%2BYpTQ78gv8uKh2M19qyd85qwpJaim61gkn4hw>