Re: [PATCH v3 4/5] tools/memory-model: Switch to softcoded herd7 tags

From: Akira Yokosawa
Date: Sat Sep 21 2024 - 07:28:19 EST


Hi,

On Sat, 21 Sep 2024 09:39:05 +0200, Jonas Oberhauser wrote:
> Thanks Akira for your continued eagle eyes!
> Will include in next revision.
>
> One question below.
> jonas
>
>
>
> Am 9/21/2024 um 4:44 AM schrieb Akira Yokosawa:
>> This litmus test is not compatible with klitmus7, which is much
>> stricter than herd7's C parser.
>>
>> You can have only int or int* variables in the exists clause.

I should have said:

By default, you can have only int or int* variables in the exists clause.

You can find an example where an atomic_t variable is listed in its exists
clause at:

Documentation/litmus-tests/atomic/Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus

, where the atomic_t variable is declared explicitly in the initialization
block as follows:

{
atomic_t v = ATOMIC_INIT(1);
}

>> Register variables need their declarations at the top of each Pn()
>> (classic C).
>>
>> See below for klitmus7 ready code.
>>
>> And tools/memory-model/litmus-tests/README need to mention this
>> litmus test.
>>
>> Thanks, Akira
>>
>> ---------------------------------------------
>> P0(int *x, int *y, atomic_t *z)
>> {
>> int r0;
>>
>> WRITE_ONCE(*x, 1);
>> r0 = atomic_add_unless(z,1,5);
>> WRITE_ONCE(*y, 1);
>> }
>>
>> P1(int *x, int *y)
>> {
>> int r0;
>>
>> r0 = READ_ONCE(*y);
>> if (r0 == 1)
>> WRITE_ONCE(*x, 2);
>> }
>>
>> exists (1:r0=1 /\ x=1)
>> ---------------------------------------------
>>
>
> Should z also be changed from atomic_t to int?
>

No, it should not.
Such a change would make z incompatible with atomic_add_unless().

Thanks, Akira