lkml.org 
[lkml]   [2012]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [tip:x86/mm] x86/pat: Avoid contention on cpa_lock if possible
On 06/06/2012 10:24 AM, Peter Zijlstra wrote:
> On Wed, 2012-06-06 at 09:18 -0700, tip-bot for Shai Fultheim wrote:
>
>> [ I absolutely hate these locking patterns ... yet I have no better idea. Maybe the gents on Cc: ... ]
>> Signed-off-by: Ingo Molnar <mingo@kernel.org>
>
> Oh yuck, this is vile..
>
> static struct static_key scale_mp_trainwreck = STATIC_KEY_INIT_FALSE;
>
> static DEFINE_SPINLOCK(_cpa_lock);
>
> static inline void cpa_lock(void)
> {
> if (static_key_false(&scale_mp_trainwreck))
> return;
>
> spin_lock(&_cpa_lock);
> }
>
> static inline void cpa_unlock(void)
> {
> if (static_key_false(&scale_mp_trainwreck))
> return;
>
> spin_lock(&_cpa_lock);
> }
>
> And then use cpa_{,un}lock(), and the scale-mp guys can
> static_key_slow_inc(&scale_mp_trainwreck).
>

Actually, for this particular subcase I would use a synthetic CPUID bit
and use static_cpu_has().

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.



\
 
 \ /
  Last update: 2012-06-06 21:41    [from the cache]
©2003-2011 Jasper Spaans