[PATCHv2 2/4] tools/memory-model: Define applicable tags on operation in tools/...

Jonas Oberhauser posted 4 patches 1 year, 8 months ago
There is a newer version of this series
[PATCHv2 2/4] tools/memory-model: Define applicable tags on operation in tools/...
Posted by Jonas Oberhauser 1 year, 8 months ago
Herd7 transforms reads, writes, and read-modify-writes by eliminating
'acquire tags from writes, 'release tags from reads, and 'acquire,
'release, and 'mb tags from failed read-modify-writes. We emulate this
behavior by redefining Acquire, Release, and Mb sets in linux-kernel.bell
to explicitly exclude those combinations.

Herd7 furthermore adds 'noreturn tag to certain reads. Currently herd7
does not allow specifying the 'noreturn tag manually, but such manual
declaration (e.g., through a syntax __atomic_op{noreturn}) would add
invalid 'noreturn tags to writes; in preparation, we already also exclude
this combination.

Signed-off-by: Jonas Oberhauser <jonas.oberhauser@huaweicloud.com>
---
 tools/memory-model/linux-kernel.bell | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/memory-model/linux-kernel.bell b/tools/memory-model/linux-kernel.bell
index dba6b5b6dee0..2f49993644ed 100644
--- a/tools/memory-model/linux-kernel.bell
+++ b/tools/memory-model/linux-kernel.bell
@@ -36,6 +36,13 @@ enum Barriers = 'wmb (*smp_wmb*) ||
 		'after-srcu-read-unlock (*smp_mb__after_srcu_read_unlock*)
 instructions F[Barriers]
 
+(* Remove impossible tags, such as Acquire on a store or failed RMW *)
+let FailedRMW = RMW \ (domain(rmw) | range(rmw))
+let Acquire = Acquire \ W \ FailedRMW
+let Release = Release \ R \ FailedRMW
+let Mb = Mb \ FailedRMW
+let Noreturn = Noreturn \ W
+
 (* SRCU *)
 enum SRCU = 'srcu-lock || 'srcu-unlock || 'sync-srcu
 instructions SRCU[SRCU]
-- 
2.34.1
Re: [PATCHv2 2/4] tools/memory-model: Define applicable tags on operation in tools/...
Posted by Boqun Feng 1 year, 8 months ago
On Tue, Jun 04, 2024 at 06:04:09PM +0200, Jonas Oberhauser wrote:
> Herd7 transforms reads, writes, and read-modify-writes by eliminating
> 'acquire tags from writes, 'release tags from reads, and 'acquire,
> 'release, and 'mb tags from failed read-modify-writes. We emulate this
> behavior by redefining Acquire, Release, and Mb sets in linux-kernel.bell
> to explicitly exclude those combinations.
> 
> Herd7 furthermore adds 'noreturn tag to certain reads. Currently herd7
> does not allow specifying the 'noreturn tag manually, but such manual
> declaration (e.g., through a syntax __atomic_op{noreturn}) would add
> invalid 'noreturn tags to writes; in preparation, we already also exclude
> this combination.
> 
> Signed-off-by: Jonas Oberhauser <jonas.oberhauser@huaweicloud.com>
> ---
>  tools/memory-model/linux-kernel.bell | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/tools/memory-model/linux-kernel.bell b/tools/memory-model/linux-kernel.bell
> index dba6b5b6dee0..2f49993644ed 100644
> --- a/tools/memory-model/linux-kernel.bell
> +++ b/tools/memory-model/linux-kernel.bell
> @@ -36,6 +36,13 @@ enum Barriers = 'wmb (*smp_wmb*) ||
>  		'after-srcu-read-unlock (*smp_mb__after_srcu_read_unlock*)
>  instructions F[Barriers]
>  
> +(* Remove impossible tags, such as Acquire on a store or failed RMW *)

This comment needs a bit help, "failed RMW"s still exist, they just
don't provide ordering. How about:

(*
 * Filter out syntactic annotations that don't provide the corresponding
 * semantic ordering, such as Acquire on a store or Mb on a failed RMW.
 *)

?

Regards,
Boqun

> +let FailedRMW = RMW \ (domain(rmw) | range(rmw))
> +let Acquire = Acquire \ W \ FailedRMW
> +let Release = Release \ R \ FailedRMW
> +let Mb = Mb \ FailedRMW
> +let Noreturn = Noreturn \ W
> +
>  (* SRCU *)
>  enum SRCU = 'srcu-lock || 'srcu-unlock || 'sync-srcu
>  instructions SRCU[SRCU]
> -- 
> 2.34.1
>
Re: [PATCHv2 2/4] tools/memory-model: Define applicable tags on operation in tools/...
Posted by Jonas Oberhauser 1 year, 8 months ago

Am 6/5/2024 um 6:25 AM schrieb Boqun Feng:
> On Tue, Jun 04, 2024 at 06:04:09PM +0200, Jonas Oberhauser wrote:
>> Herd7 transforms reads, writes, and read-modify-writes by eliminating
>> 'acquire tags from writes, 'release tags from reads, and 'acquire,
>> 'release, and 'mb tags from failed read-modify-writes. We emulate this
>> behavior by redefining Acquire, Release, and Mb sets in linux-kernel.bell
>> to explicitly exclude those combinations.
>>
>> Herd7 furthermore adds 'noreturn tag to certain reads. Currently herd7
>> does not allow specifying the 'noreturn tag manually, but such manual
>> declaration (e.g., through a syntax __atomic_op{noreturn}) would add
>> invalid 'noreturn tags to writes; in preparation, we already also exclude
>> this combination.
>>
>> Signed-off-by: Jonas Oberhauser <jonas.oberhauser@huaweicloud.com>
>> ---
>>   tools/memory-model/linux-kernel.bell | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/tools/memory-model/linux-kernel.bell b/tools/memory-model/linux-kernel.bell
>> index dba6b5b6dee0..2f49993644ed 100644
>> --- a/tools/memory-model/linux-kernel.bell
>> +++ b/tools/memory-model/linux-kernel.bell
>> @@ -36,6 +36,13 @@ enum Barriers = 'wmb (*smp_wmb*) ||
>>   		'after-srcu-read-unlock (*smp_mb__after_srcu_read_unlock*)
>>   instructions F[Barriers]
>>   
>> +(* Remove impossible tags, such as Acquire on a store or failed RMW *)
> 
> This comment needs a bit help, "failed RMW"s still exist, they just
> don't provide ordering. How about:


Oh, I see how the comment can be misread. A smaller fix would be

"Acquire on a store or on a failed RMW"

but I actually like your longer explanation better, so I think I'll go 
with that.

> 
> (*
>   * Filter out syntactic annotations that don't provide the corresponding
>   * semantic ordering, such as Acquire on a store or Mb on a failed RMW.
>   *)
> 
> ?
> 
> Regards,
> Boqun
> 
>> +let FailedRMW = RMW \ (domain(rmw) | range(rmw))
>> +let Acquire = Acquire \ W \ FailedRMW
>> +let Release = Release \ R \ FailedRMW
>> +let Mb = Mb \ FailedRMW
>> +let Noreturn = Noreturn \ W
>> +
>>   (* SRCU *)
>>   enum SRCU = 'srcu-lock || 'srcu-unlock || 'sync-srcu
>>   instructions SRCU[SRCU]
>> -- 
>> 2.34.1
>>