lkml.org 
[lkml]   [2006]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC, PATCH] avoid some atomics in open()/close() for monothreaded processes
Andrew Morton a écrit :
> Eric Dumazet <dada1@cosmosbay.com> wrote:
>> Goal : Avoid some locking/unlocking 'struct files_struct'->file_lock for mono
>> threaded processes.
>>
>> We define files_multithreaded() function .
>>
>> static inline int files_multithreaded(const struct files_struct *files)
>> {
>> return sizeof(files->file_lock) > 0 && atomic_read(&files->count) > 1;
>> }
>
> That's bascially sizeof(spinlock_t). That's architecture dependent and
> varies wildly according to the day of week.

I used sizeof(files->file_lock) instead of sizeof(spinlock_t) because I found
it more explicit , while not using ugly ifdefs.

>
> It _might_ work in all situations - probably you checked that. But I still
> wouldn't do it because it might break in the future. Let's be explicit and
> stick the appropriate ifdefs in there.
>
> I'd also consider renaming it to files_shared() - processes are
> multithreaded, not data structures.

Thanks for the feedback, I will redo the patch and test it on various
platforms before resubmit (including performance data :) )

>
> Once you're done with that we should change fget_light() and fput_light() to
> use this helper. Separate patch.

Hum... this discussion is not relevant with fget_light() unless I mistaken.

Nowadays, this function doesnt take spinlock thanks to RCU

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-03-22 08:01    [W:0.092 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site