tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Dynamically allocated locks



Matt Thomas <matt%3am-software.com@localhost> wrote:
> Yes.  One / cacheline size is a dramatic waste of space.  Some  
> systems have
> 128 bytes per cacheline.  On systems with small caches or UP systems  
> it's
> extremely expensive.
> 
> Other than that its fine.  I can see not crossing a cacheline boundary,
> but only 1 / cacheline is just wrong.

As already discussed in this thread, highly contended lock, when it is not in
own cache-line, will likely cause a false-sharing on MP system. Especially in
very recent multi-core CPUs, it has serious influence for performance.

However, I agree with your concern, that UP systems should be taken into
account, and adjusting such APIs (and maybe some separate cases, where a lot
of structures may be allocated, eg. pools aligned to cache-line) to be more
optimal for UP systems would be better.

Andrew already suggested to invent a global variable, adjusted by MD code.
That looks like ideal solution for me. Also, these lock-objects are not for
wide usage, but for strict cases - I think it is worth to document this.

-- 
Best regards,
Mindaugas
www.NetBSD.org


Home | Main Index | Thread Index | Old Index