From: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
To: Tahsin Erdogan <tahsin@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, Waiman.Long@hp.com, borntraeger@de.ibm.com,
oleg@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/spinlocks: Fix regression in spinlock contention detection
Date: Tue, 05 May 2015 16:08:22 +0530 [thread overview]
Message-ID: <55489D9E.4010003@linux.vnet.ibm.com> (raw)
In-Reply-To: <20150505091714.GF21418@twins.programming.kicks-ass.net>
On 05/05/2015 02:47 PM, Peter Zijlstra wrote:
> On Mon, May 04, 2015 at 09:15:31PM -0700, Tahsin Erdogan wrote:
>> A spinlock is regarded as contended when there is at least one waiter.
>> Currently, the code that checks whether there are any waiters rely on
>> tail value being greater than head. However, this is not true if tail
>> reaches the max value and wraps back to zero, so arch_spin_is_contended()
>> incorrectly returns 0 (not contended) when tail is smaller than head.
>>
>> The original code (before regression) handled this case by casting the
>> (tail - head) to an unsigned value. This change simply restores that
>> behavior.
>>
>> Fixes: d6abfdb20223 ("x86/spinlocks/paravirt: Fix memory corruption on
>> unlock")
>> Signed-off-by: Tahsin Erdogan <tahsin@google.com>
>> ---
>> arch/x86/include/asm/spinlock.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
>> index cf87de3..64b6117 100644
>> --- a/arch/x86/include/asm/spinlock.h
>> +++ b/arch/x86/include/asm/spinlock.h
>> @@ -169,7 +169,7 @@ static inline int arch_spin_is_contended(arch_spinlock_t *lock)
>> struct __raw_tickets tmp = READ_ONCE(lock->tickets);
>>
>> tmp.head &= ~TICKET_SLOWPATH_FLAG;
>> - return (tmp.tail - tmp.head) > TICKET_LOCK_INC;
>> + return (__ticket_t)(tmp.tail - tmp.head) > TICKET_LOCK_INC;
>
> I'm not seeing it, everything in that expression is of __ticket_t type
> (tail, head and TICKET_LOCK_INC), nothing should cause it to be cast to
> another type due to conversion rules.
>
> Or does - always cast to a signed type? Lemme go grab the C rules again.
>
> I'm not seeing it.. Please explain better, iow. your changelog fails to
> properly explain the problem.
>
Same from me here.
Did you really see a regression?
I am not seeing two unsigned value subtraction resulting in a negative
value.
================
#include <stdio.h>
#define LOCK_INC 2
int main()
{
unsigned int head = 32700, tail=2;
if ((tail - head) > LOCK_INC)
printf(" tail - head > LOCK_INC \n");
else
printf(" tail - head < LOCK_INC \n");
return 0;
}
next prev parent reply other threads:[~2015-05-05 10:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 4:15 [PATCH] x86/spinlocks: Fix regression in spinlock contention detection Tahsin Erdogan
2015-05-05 9:06 ` [tip:x86/urgent] " tip-bot for Tahsin Erdogan
2015-05-05 9:17 ` [PATCH] " Peter Zijlstra
2015-05-05 10:38 ` Raghavendra K T [this message]
2015-05-05 10:58 ` Peter Zijlstra
2015-05-05 14:10 ` Tahsin Erdogan
2015-05-05 14:30 ` Peter Zijlstra
[not found] ` <CAAeU0aPSDdDVKm=YgbYH+SWfk07rLGgEFMQoN+nt4vc1_YLHzg@mail.gmail.com>
2015-05-05 15:25 ` Raghavendra K T
2015-05-05 15:28 ` Tahsin Erdogan
2015-05-05 15:32 ` Waiman Long
2015-05-05 15:38 ` Raghavendra K T
2015-05-06 15:37 ` Raghavendra K T
2015-05-07 7:13 ` Tahsin Erdogan
2015-05-08 11:09 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55489D9E.4010003@linux.vnet.ibm.com \
--to=raghavendra.kt@linux.vnet.ibm.com \
--cc=Waiman.Long@hp.com \
--cc=borntraeger@de.ibm.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=tahsin@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.