lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 05 May 2015 21:08:38 +0530
From:	Raghavendra K T <raghavendra.kt@...ux.vnet.ibm.com>
To:	Waiman Long <waiman.long@...com>,
	Tahsin Erdogan <tahsin@...gle.com>
CC:	Peter Zijlstra <peterz@...radead.org>, tglx@...utronix.de,
	mingo@...hat.com, hpa@...or.com, x86@...nel.org,
	borntraeger@...ibm.com, oleg@...hat.com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/spinlocks: Fix regression in spinlock contention
 detection

On 05/05/2015 09:02 PM, Waiman Long wrote:
> On 05/05/2015 11:25 AM, Raghavendra K T wrote:
>> 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 ?
>>
>>
>
> __TICKET_LOCK_INC is currently ((unsigned short)2), not ((unsigned
> int)2). That makes a difference.
>

aah missed that part :). That makes sense.

Good catch Tahsin.


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ