lkml.org 
[lkml]   [2018]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: fs_struct refcounting: spinlock vs atomic
From
Date
On 15.02.2018 10:14, Richard Weinberger wrote:
> On Wed, Feb 14, 2018 at 10:13 PM, Enrico Weigelt <lkml@metux.net> wrote:
>> Hi folks,
>>
>>
>> in fork.c, a spinlock is held for fs_struct refcounting, while other
>> places - eg. switch_task_namespaces uses atomic_dec_and_test() on
>> the nsproxy.
>>
>> What's the exact difference here ? Could the atomic counting also used
>> for fs_struct ?
>
> Well, the spinlock protects more than just the counter. So atomic won't do it.

Okay. Is that needed in that case ?

See unshare() syscall:

if (new_fs) {
fs = current->fs;
spin_lock(&fs->lock);
current->fs = new_fs;
if (--fs->users)
new_fs = NULL;
else
new_fs = fs;
spin_unlock(&fs->lock);
}

Seems to me, that we're just refcounting here, and once it went dont to
zero, nobody else can access it anymore.


--mtx

--
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

\
 
 \ /
  Last update: 2018-02-15 14:46    [W:0.050 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site