Giter Club home page Giter Club logo

litmus's Issues

Problem running litmus tests with herd

I'm trying to run some of the litmus tests from this repo using herd7 (version 7.56) with the cat models (and corresponding bell files) also in this repo, but I'm getting problems due to unbound vars, e.g.

herd7 auto/LB-GWR+R-Dd+R-Dd+R-Oc+OB-OB.litmus -model models/alan-kernel-2016.04.28.cat -bell models/alan-kernel-2016.04.28.bell
File "./models/alan-kernel-2016.04.28.bell", line 29, characters 27-32: unbound var: Start

The other models have the same problem (always Start). I took a quick look to the herd7 source code (main branch), but could not find anything related to this kind of "events".

Any idea what the problem might be? Am I missing any flag or do I need some special version of herd7?

Release-Acquire chains

The following program has a potential related-acq pair (P0 -> P2) that can be broken by an intervening thread (P1) with a relaxed instruction

❯ cat weird-C.litmus
C weird
{}

P0(intptr_t *x, intptr_t *y)
{
	WRITE_ONCE(*x, 1);
	atomic_set_release(y, 1);
}

P1(intptr_t *x, intptr_t *y)
{
	int r0 = atomic_fetch_add_relaxed(2, y); 
}

P2(intptr_t *x, intptr_t *y)
{
    int r0 = atomic_read_acquire(y);
    int r1 = READ_ONCE(*x);
}

exists (2:r0=3 /\ 2:r1=0)

The LKMM from here allows the chain to be broken

❯ herd7 -model ../lkmm/tools/memory-model/linux-kernel.cat -macros ../lkmm/tools/memory-model/linux-kernel.def -bell ../lkmm/tools/memory-model/linux-kernel.bell weird-C.litmus -I ../lkmm/tools/memory-model/
Test weird Allowed
States 7
2:r0=0; 2:r1=0;
2:r0=0; 2:r1=1;
2:r0=1; 2:r1=1;
2:r0=2; 2:r1=0;
2:r0=2; 2:r1=1;
2:r0=3; 2:r1=0;
2:r0=3; 2:r1=1;
Ok
Witnesses
Positive: 1 Negative: 9
Condition exists (2:r0=3 /\ 2:r1=0)
Observation weird Sometimes 1 9
Time weird 0.01
Hash=f3a36a6d5313d0bcee071c2a06783c41

The chain could be fixed by making the RMW in P1 a release

❯ cat weird-C-fixed.litmus
C weird
{}

P0(intptr_t *x, intptr_t *y)
{
    WRITE_ONCE(*x, 1);
    atomic_set_release(y, 1);
}

P1(intptr_t *x, intptr_t *y)
{
    int r0 = atomic_fetch_add_release(2, y);
}

P2(intptr_t *x, intptr_t *y)
{
    int r0 = atomic_read_acquire(y);
    int r1 = READ_ONCE(*x);
}

exists (2:r0=3 /\ 2:r1=0)

❯ herd7 -model ../lkmm/tools/memory-model/linux-kernel.cat -macros ../lkmm/tools/memory-model/linux-kernel.def -bell ../lkmm/tools/memory-model/linux-kernel.bell weird-C-fixed.litmus -I ../lkmm/tools/memory-model/
Test weird Allowed
States 6
2:r0=0; 2:r1=0;
2:r0=0; 2:r1=1;
2:r0=1; 2:r1=1;
2:r0=2; 2:r1=0;
2:r0=2; 2:r1=1;
2:r0=3; 2:r1=1;
No
Witnesses
Positive: 0 Negative: 9
Condition exists (2:r0=3 /\ 2:r1=0)
Observation weird Never 0 9
Time weird 0.01
Hash=2d1ad2a445f148efe7634b8992363e5d

This behaviour would neither be observed in an ARM

❯ cat weird-ARM.litmus
AArch64 weird
{
0:X1=x; 0:X3=y;
1:X1=x; 1:X3=y;
2:X1=x; 2:X3=y;
}
P0           | P1                | P2;
MOV  W0,#1   | MOV   W0,#2       | LDAR W0, [X3];
STR  W0,[X1] | LDXR  W2,[X3]     | LDR  W2, [X1];
STLR W0,[X3] | ADD   W2,W2,W0    |;
             | STXR  W1,W2,[X3]  |;
 
exists
(2:X0=3 /\ 2:X2=0)
❯ herd7 -model cat/aarch64.cat weird-ARM.litmus
Test weird Allowed
States 6
2:X0=0; 2:X2=0;
2:X0=0; 2:X2=1;
2:X0=1; 2:X2=1;
2:X0=2; 2:X2=0;
2:X0=2; 2:X2=1;
2:X0=3; 2:X2=1;
No
Witnesses
Positive: 0 Negative: 15
Condition exists (2:X0=3 /\ 2:X2=0)
Observation weird Never 0 15
Time weird 0.01
Hash=342601047a6d69dee710e4e94d28e4fe

or PowerPC machine

❯ cat weird-PPC.litmus
PPC weird
{
0:r2=x; 0:r4=y;
1:r2=x; 1:r4=y;
2:r2=x; 2:r4=y;
}
P0            | P1			| P2		;
li   r1,1     | lwz  r3,0(r4)		| lwz r1,0(r4)	;
stw  r1,0(r2) | cmpw r3,r3		| cmpw r3,r3	;
stw  r1,0(r4) | beq  LC00		| beq  LC01	;
 	      | LC00:			| LC01: 	;
 	      | addi r3,r3,1		| isync		;
 	      | stw r3,0(r4) 		| lwz r3, 0(r2)	;
 
exists
(2:r1=3 /\ 2:r3=0)
❯ herd7 -model cat/power.cat weird-PPC.litmus
Test weird Allowed
States 6
2:r1=0; 2:r3=0;
2:r1=0; 2:r3=1;
2:r1=1; 2:r3=0;
2:r1=1; 2:r3=1;
2:r1=2; 2:r3=0;
2:r1=2; 2:r3=1;
No
Witnesses
Positive: 0 Negative: 18
Condition exists (2:r1=3 /\ 2:r3=0)
Observation weird Never 0 18
Time weird 0.01
Hash=09d4d22cf368195d3c18a8c9acf34a2c

My question is then why the LKMM allows this behaviour? Is there any weaker architecture supported by the kernel (e.g. Alpha) where this behaviour would be observable?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.