From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25355 invoked by alias); 6 Jul 2012 19:42:04 -0000 Received: (qmail 25340 invoked by uid 22791); 6 Jul 2012 19:42:03 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Jul 2012 19:41:50 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SnEPW-0004oy-0i from Tom_deVries@mentor.com ; Fri, 06 Jul 2012 12:41:50 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 6 Jul 2012 12:40:59 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Fri, 6 Jul 2012 20:41:47 +0100 Message-ID: <4FF73F75.6060303@mentor.com> Date: Fri, 06 Jul 2012 19:42:00 -0000 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Chris Metcalf CC: Maxim Kuvyrkov , "Joseph S. Myers" , GLIBC Devel , , Tom de Vries Subject: Re: [PATCH] Optimize libc_lock_lock for MIPS XLP. References: <4FD9DB74.8080905@tilera.com> <40CBC472-71CC-4FF3-A452-073B76701215@codesourcery.com> <4FDAA190.3050706@tilera.com> <15EB7E17-5692-4221-A1B1-FC16EA236BFF@codesourcery.com> <4FEC94AF.40301@tilera.com> In-Reply-To: <4FEC94AF.40301@tilera.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00016.txt.bz2 On 28/06/12 19:30, Chris Metcalf wrote: > On 6/27/2012 5:45 PM, Maxim Kuvyrkov wrote: >> On 15/06/2012, at 2:49 PM, Maxim Kuvyrkov wrote: >> >>>> On 15/06/2012, at 2:44 PM, Chris Metcalf wrote: >>>> >>>>>> On 6/14/2012 9:20 PM, Maxim Kuvyrkov wrote: >>>> ... >>>>>>>> As I read it, in case of a contended lock __lll_lock_wait will reset the value of the lock to "2" before calling lll_futex_wait(). I agree that there is a timing window in which the other threads will see a value of the lock greater than "2", but the value will not get as high as hundreds or billions as it will be constantly reset to "2" in atomic_exchange in lll_lock_wait(). >>>>>>>> >>>>>>>> I do not see how threads will get into a busywait state, though. Would you please elaborate on that? >>>>>> >>>>>> You are correct. I was thinking the that the while loop had a cmpxchg, but >>>>>> since it's just a straight-up exchange, the flow will be something like: >>>>>> >>>>>> - Fail to initially call lll_futex_wait() if the lock is contended >>>>>> - Fall through to while loop >>>>>> - Spin as long as the lock is contended enough that *futex > 2 >>>>>> - Enter futex_wait >>>>>> >>>>>> So a little busy under high contention, but probably settles out reasonably >>>>>> well. >>>> >> Attached is an improved patch that also optimizes __libc_lock_trylock using XLP's atomic instructions. >> >> The patch also removes unnecessary indirection step represented by new macros lll_add_lock, which is then used to define __libc_lock_lock, and defines __libc_lock_lock and __libc_lock_trylock directly in lowlevellock.h . This makes changes outside of ports/ trivial. >> >> Tested on MIPS XLP with no regressions. OK to apply for 2.17? > > It looks OK to me. I would want someone else to sign off on it before > applying to 2.17. > Chris, I cannot sign off on this, but I reviewed the current patch as well and it looks ok to me too. Thanks, - Tom