Skip to content

Commit

Permalink
selftests/powerpc: Do not fail with reschedule
Browse files Browse the repository at this point in the history
There are cases where the test is not expecting to have the transaction
aborted, but, the test process might have been rescheduled, either in the
OS level or by KVM (if it is running on a KVM guest machine). The process
reschedule will cause a treclaim/recheckpoint which will cause the
transaction to doom, aborting the transaction as soon as the process is
rescheduled back to the CPU. This might cause the test to fail, but this is
not a failure in essence.

If that is the case, TEXASR[FC] is indicated with either
TM_CAUSE_RESCHEDULE or TM_CAUSE_KVM_RESCHEDULE for KVM interruptions.

In this scenario, ignore these two failures and avoid the whole test to
return failure.

Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Gustavo Romero <gromero@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Breno Leitao authored and Michael Ellerman committed Sep 19, 2018
1 parent 984ecdd commit 44d947e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/testing/selftests/powerpc/tm/tm-unavailable.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,20 @@ void *tm_una_ping(void *input)
}

/* Check if we were not expecting a failure and a it occurred. */
if (!expecting_failure() && is_failure(cr_)) {
if (!expecting_failure() && is_failure(cr_) &&
!failure_is_reschedule()) {
printf("\n\tUnexpected transaction failure 0x%02lx\n\t",
failure_code());
return (void *) -1;
}

/*
* Check if TM failed due to the cause we were expecting. 0xda is a
* TM_CAUSE_FAC_UNAV cause, otherwise it's an unexpected cause.
* TM_CAUSE_FAC_UNAV cause, otherwise it's an unexpected cause, unless
* it was caused by a reschedule.
*/
if (is_failure(cr_) && !failure_is_unavailable()) {
if (is_failure(cr_) && !failure_is_unavailable() &&
!failure_is_reschedule()) {
printf("\n\tUnexpected failure cause 0x%02lx\n\t",
failure_code());
return (void *) -1;
Expand Down
9 changes: 9 additions & 0 deletions tools/testing/selftests/powerpc/tm/tm.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ static inline bool failure_is_unavailable(void)
return (failure_code() & TM_CAUSE_FAC_UNAV) == TM_CAUSE_FAC_UNAV;
}

static inline bool failure_is_reschedule(void)
{
if ((failure_code() & TM_CAUSE_RESCHED) == TM_CAUSE_RESCHED ||
(failure_code() & TM_CAUSE_KVM_RESCHED) == TM_CAUSE_KVM_RESCHED)
return true;

return false;
}

static inline bool failure_is_nesting(void)
{
return (__builtin_get_texasru() & 0x400000);
Expand Down

0 comments on commit 44d947e

Please sign in to comment.