[herd] Attempt to limit the number of spurious AF updates#1730
[herd] Attempt to limit the number of spurious AF updates#1730
Conversation
|
Thanks for this Luc. This got me curious do you have an example litmus test which will show spurious updates of the AF when the AF is already set? |
34d8fa0 to
04f4a45
Compare
|
The test is rather simple: The semantic module yields two execution candidates, one of which includes a spurious update attempt The diagram does not show it but the underlying structure includes a assert that The choice of adding a spurious update or not multiplies the number of executions by two. Then, even if half of them are discarded by the solver and this process takes noticeable time in complex tests. |
The function [delay_kont] can be used to extract the value returned
by a monad (second argument below, type `'a`).
```
val delay_kont : string -> 'a t -> ('a -> 'a t -> 'b t) -> 'b t
```
The continuation function `(fun v mv -> ... )` can then examine
the returned value `v` and combine the monad `mv` independently,
which proves very convenient in many occasion.
The change performed by this commit permits affine (_i.e._ one or zero
effective occurrence), while linear usage (exactly one occurrence) was
mandatory before.
04f4a45 to
29371d1
Compare
relokin
left a comment
There was a problem hiding this comment.
Thanks for this Luc! A couple of questions/thoughts, otherwise this PR looks good to me.
herd/AArch64Sem.ml
Outdated
| | None -> true | ||
| | Some c -> Constant.is_pt c | ||
|
|
||
| let can_af0 _tag v = |
There was a problem hiding this comment.
it looks like, you introduced _tag to help debug or profile? Can you add that functionality perhaps disabled by default? Otherwise having the argument _tag and it doesn't help for functions like lift_memop which already had many arguments.
There was a problem hiding this comment.
I'll supress this argument here, but would like to keep it as an optional argument of the function lift_mem_op.
| (let b = C.variant Variant.PhantomOnLoad in | ||
| match dir with | ||
| | Dir.W -> not b && can_be_pt a && can_af0 tag v | ||
| | Dir.R -> b) in |
There was a problem hiding this comment.
Just out of curiosity, we can't do a similar check for reads, can we? For example, take the following litmus test:
AArch64 foo
Variant=vmsa
TTHM=HA
{
[PTE(x)]=(oa:PA(x));
0:X2=x;
}
P0 ;
LDR W2,[X2] ;
$> herd7 -dumpes true /tmp/foo.litmus -o /tmp
produces 4 executions, on of which has a hardware update of the AF which is obviously not needed.
There was a problem hiding this comment.
I have to check, but there should be no spurious update here.
There was a problem hiding this comment.
I have just checked, the HW update involved is not a spurious one. We cannot really get rid of it at Sem time: as a general principle the values in memory are not known at that time. In that very specific case, a global analysis could infer that having the AF flag to be zero is not possible. However, generalisation looks quite involved to me.
| (match V.as_constant v with | ||
| | Some (Constant.PteVal p) -> p.AArch64PteVal.af = 0 | ||
| | Some (Constant.PteVal p) -> | ||
| p.AArch64PteVal.valid <> 0 && p.AArch64PteVal.af = 0 |
There was a problem hiding this comment.
If you are planning to keep the 3 commits separate, this belongs to the previous commit.
There was a problem hiding this comment.
My intend is to squash the commits.
|
Thanks for your comments @relokin. In fact I now attempt a global approach in another branch. Thus I give this one the Draft status again... |
We attempt to identify the value stored by writes to page table entries. When this value has the AF flag set, there is no need to emit a spurious update. For a precise detection of this situation the stored value is now retrieved by anticipation. The case of `-variant pte2` is also optimised similarly.
931e3e5 to
5a65adc
Compare
|
Superseded by PR #1733 |
We attempt to identify the value stored by writes to page table entries. When this value has a set AF flag, there is no need to emit a spurious update. The collected information allows is not to fire spurious updates in some cases.