[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 0/3] xen/spinlock: make recursive spinlocks a dedicated type


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 15 Dec 2022 08:48:25 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g/iBnEKcX4PXMTXbAEPvf4ujyqkHLjO6VJKRa5uoNtI=; b=aDowR7bPPPMYopeRnfvkraJn2eBef1oe1vpp7MadhebeAoK4Fdejk5z6VYOQPA4A3xigfYVQosSKstYPCdwX7BiLom1RBUhXam11ycJ4y20CtaKySgVOSQL3zCeXjUiT1gBN5P+dBL++0b3ucoTcIxDSTCKxSCxQANhtabtnBkyP0HL+V45tEAE4kjQ9t7B1uiwZ+GF5U2mBJ2NfF9GcH47N+Fhl1ATuT51P86DayVDH9Ge+iB0A7807DyOTXOnhdIdikPczNECPA0i8bE9Vbq7b36kIhdbkzwTMw6/hOIIk7l0jD1oVB/uApkhnHf1juSidtO82Y+Z8d4MWb0xQBA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=blppM4ILNX01xuoAAMsgtW5pAhSRP60KXexDNVhFfaOcfyWzH6NkDi+0tK3GCehjNQB5oti87DzCKrY3WlfN/frP3j9crFH7W4TBiqxR+1pl3tamkYO9S89HJaDMKlVO/IGt3930swElhsTSfhCuSO6w0TouI77DalKik6jsG3cXJZexJjXBlYkGm4/BBr0YUwM4PZ1BqdlPcNa1HHx3zF3CPsN9v14QJkWRBXs2qqO1dghnZWeGKcYuoyCtCsPZ5IVFhxUYZjeKH/cvV0JkH3fZ3DyrkDBNjElk8uoD7dOQSNqU7Wg6WE3BEJlw1kbkkzCckGPoWh9u7whudE3o5A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>, Lukasz Hawrylko <lukasz@xxxxxxxxxxx>, Mateusz Mówka <mateusz.mowka@xxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 15 Dec 2022 07:48:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14.12.2022 17:36, Juergen Gross wrote:
> On 14.12.22 17:25, Daniel P. Smith wrote:
>> On 12/14/22 10:31, Juergen Gross wrote:
>>> On 14.12.22 16:03, Daniel P. Smith wrote:
>>>>
>>>> On 9/10/22 11:49, Juergen Gross wrote:
>>>>> Instead of being able to use normal spinlocks as recursive ones, too,
>>>>> make recursive spinlocks a special lock type.
>>>>>
>>>>> This will make the spinlock structure smaller in production builds and
>>>>> add type-safety.
>>>>
>>>> Just a little yak shaving, IMHO a spinlock is normally not expected to be 
>>>> recursive. Thus explicitly naming a spinlock as non-recursive I find to be 
>>>> redundant along with being expensive for typing. Whereas a recursive 
>>>> spinlock 
>>>> is the special instance and should have a declarative distinction. Only 
>>>> codifying the recursive type would significantly cut down on the size of 
>>>> the 
>>>> series and still provide equal type and visual clarification.
>>>
>>> A "normal" spinlock is non-recursive.
>>>
>>> A recursive spinlock in Xen can be either taken recursive, or it can be 
>>> taken
>>> non-recursive, causing further recursive attempts to spin.
>>
>> Yes, I understand the current situation.
>>
>>> So the explicit non-recursive locking applies to that special treatment of
>>> recursive spinlocks.
>>
>> I understand this, but to help clarify what I am saying is that individuals 
>> coming from outside Xen would expect is the spinlock family of calls to 
>> behave 
>> as a non-recursive spinlocks and recursive spinlock family of calls would 
>> provide the recursive behavior. Currently Xen's behavior is backwards to 
>> this, 
>> which this series continues and is a valid approach. Here spinlock and 
>> recursive 
>> spinlock family of calls are recursive and must use non-recursive spinlock 
>> family to have "normal" spinlock behavior. IMHO it would greatly simplify 
>> the 
> 
> My series doesn't change treatment of normal spinlocks. They are still used 
> via
> spin_{lock,locked,unlock}.
> 
>> code and align with the "normal" understanding of spinlocks if instead 
>> spin_{lock,locked,unlock} macros were the non-recursive calls and 
>> spin_{lock,locked,unlock}_recursive macros were the recursive calls. Then 
>> there 
>> would only be two suites of calls for spinlocks and a lot less keystrokes 
>> for 
>> need for most development.
> 
> Only the recursive spinlock type user must specify, whether a lock is meant to
> be handled as a recursive or a non-recursive lock attempt. This is similar to
> a rwlock, where the user must specify whether to lock as a reader or a writer.

While I can't come up with anything neat right away, it feels like it should be
possible to come up with some trickery to make spin_lock() usable on both lock
types, eliminating the need to ..._nonrecursive() variants visible at use sites
(they may still be necessary as helpers then). At least if a spinlock_t instance
wasn't embedded in the recursive lock struct (as I did suggest), then something
along the lines of what tgmath.h does may be possible.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.