Eric Dumazet <dada1@xxxxxxxxxxxxx> 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.
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.
Once you're done with that we should change fget_light() and fput_light() to
use this helper. Separate patch.