[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <57620139-92a3-4a21-56bd-5d6fff23214f@redhat.com>
Date: Fri, 19 Apr 2019 15:39:16 -0400
From: Waiman Long <longman@...hat.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>, Will Deacon <will.deacon@....com>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org, x86@...nel.org,
Davidlohr Bueso <dave@...olabs.net>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Tim Chen <tim.c.chen@...ux.intel.com>,
huang ying <huang.ying.caritas@...il.com>
Subject: Re: [PATCH v4 14/16] locking/rwsem: Guard against making count
negative
On 04/19/2019 09:15 AM, Peter Zijlstra wrote:
> On Fri, Apr 19, 2019 at 03:03:04PM +0200, Peter Zijlstra wrote:
>> On Fri, Apr 19, 2019 at 02:02:07PM +0200, Peter Zijlstra wrote:
>>> On Fri, Apr 19, 2019 at 12:26:47PM +0200, Peter Zijlstra wrote:
>>>> I thought of a horrible horrible alternative:
>>> Hurm, that's broken as heck. Let me try again.
>> So I can't make that scheme work, it all ends up wanting to have
>> cmpxchg().
>>
>> Do we have a performance comparison somewhere of xadd vs cmpxchg
>> readers? I tried looking in the old threads, but I can't seem to locate
>> it.
>>
>> We need new instructions :/ Or more clever than I can muster just now.
> In particular, an (unsigned) saturation arithmetic variant of XADD would
> be very nice to have at this point.
I just want to clear about my current scheme. There will be 16 bits
allocated for reader count. I use the MS bit for signaling that there
are too many readers. So the fast path will fail and the readers will be
put into the wait list. This effectively limit readers to 32k-1, but it
doesn't mean the actual reader count cannot go over that. As long as the
actual count is less than 64k, everything should still work perfectly.
IOW, even though we have reached the limit of 32k, we need to pile on an
additional 32k readers to really overflow the count and cause problem.
Cheers,
Longman
Powered by blists - more mailing lists