Re: [RFC][PATCH 0/9] File descriptor hot-unplug support

From: Tejun Heo
Date: Tue Apr 14 2009 - 04:51:44 EST


Hello, Eric.

Eric W. Biederman wrote:
> Tejun Heo <tj@xxxxxxxxxx> writes:
>> Eric W. Biederman wrote:
>>> Do you know of a case where we actually have multiple tasks accessing
>>> a file simultaneously?
>> I don't have anything at hand but multithread/process server accepting
>> on the same socket comes to mind. I don't think it would be a very
>> rare thing. If you confine the scope to character devices or sysfs,
>> it could be quite rare tho.
>
> Yes. I think I can safely exclude sockets, and not bother with
> reference counting them.
>
> The only strong evidence I have that multi-threading on a single file
> descriptor is likely to be common is that we have pread and pwrite
> syscalls. At the same time the number of races we have in struct file
> if it is accessed by multiple threads at the same time, suggests
> that at least for cases where you have an offset it doesn't happen often.
>
> I cringe when I see per cpu counters for something like files that we
> are likely to have a lot of. I keep imagining a quadratic explosion
> in data size. In practice we are likely to have a small cpu count <=
> 8-16 cpus so it is likely ok. Especially if we are only allocating 8
> bytes per cpu per file. I guess in total that is at most 128K per file.
> 8bytes*16k cpus. With the default system file-max on my systems 203871
> to 705863, it looks like we would max out at between 1M and 5M per cpu.
> Still a lot but survivable.

Not only that percpu refcnt is quite expensive to shut down too. For
modules and devices, it doesn't really matter but using it for files
on FS would be pretty scary.

> Somewhere it all falls down, but only if you max out a very rare
> very large machine, and that seems to be case with just about everything.
>
> Which all leads me to say that if we can avoid per cpu memory and not impact
> performance I want to do that.

Yeah, fully agreed there.

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