From: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
To: Tahsin Erdogan <tahsin@google.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: 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 20:55:25 +0530 [thread overview]
Message-ID: <5548E0E5.60309@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAAeU0aPSDdDVKm=YgbYH+SWfk07rLGgEFMQoN+nt4vc1_YLHzg@mail.gmail.com>
On 05/05/2015 07:33 PM, Tahsin Erdogan wrote:
> The conversion to signed happens with types shorter than int (__ticket_t
> is either u8 or u16).
>
> By changing Raghavendra's program to use unsigned short int, you can see
> the problem:
>
> ================
> #include <stdio.h>
>
> #define LOCK_INC 2
>
> int main()
> {
> unsigned short 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;
> }
>
> ================
> gcc -g -o t main.c
> ./t
> tail - head < LOCK_INC
>
> However, having just unsigned int returns the opposite result (unsigned
> int head = 32700, tail=2;)
>
Interestingly,
#include <stdio.h>
//#define LOCK_INC ((unsigned int)2) // case 1
#define LOCK_INC 2 //case 2
int main()
{
unsigned short 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;
}
case 1 works here (PeterZ's stricter version)
case 2 gives tail - head < LOCK_INC
But is it not that we have case 1 we are looking here ?
next prev parent reply other threads:[~2015-05-05 16:09 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
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 [this message]
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=5548E0E5.60309@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox