Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2993286AbbEEQKi (ORCPT ); Tue, 5 May 2015 12:10:38 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:53070 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2993415AbbEEPe5 (ORCPT ); Tue, 5 May 2015 11:34:57 -0400 Message-ID: <5548E3FE.2070303@linux.vnet.ibm.com> Date: Tue, 05 May 2015 21:08:38 +0530 From: Raghavendra K T Organization: IBM User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Waiman Long , Tahsin Erdogan CC: Peter Zijlstra , tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, borntraeger@de.ibm.com, oleg@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/spinlocks: Fix regression in spinlock contention detection References: <1430799331-20445-1-git-send-email-tahsin@google.com> <20150505091714.GF21418@twins.programming.kicks-ass.net> <55489D9E.4010003@linux.vnet.ibm.com> <20150505105812.GK21418@twins.programming.kicks-ass.net> <5548E0E5.60309@linux.vnet.ibm.com> <5548E290.8030509@hp.com> In-Reply-To: <5548E290.8030509@hp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15050515-1618-0000-0000-000002098406 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1868 Lines: 76 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 >>> >>> #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 >> >> //#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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/