[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <158929421751.390.2633100555064287266.tip-bot2@tip-bot2>
Date: Tue, 12 May 2020 14:36:57 -0000
From: "tip-bot2 for Will Deacon" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Will Deacon <will@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Akinobu Mita <akinobu.mita@...il.com>, x86 <x86@...nel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: [tip: locking/kcsan] fault_inject: Don't rely on "return value" from
WRITE_ONCE()
The following commit has been merged into the locking/kcsan branch of tip:
Commit-ID: 9a7cb2d8d6b959fc11a34668b1523f745ae5f714
Gitweb: https://git.kernel.org/tip/9a7cb2d8d6b959fc11a34668b1523f745ae5f714
Author: Will Deacon <will@...nel.org>
AuthorDate: Mon, 11 May 2020 21:41:40 +01:00
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitterDate: Tue, 12 May 2020 11:04:12 +02:00
fault_inject: Don't rely on "return value" from WRITE_ONCE()
It's a bit weird that WRITE_ONCE() evaluates to the value it stores and
it's also different to smp_store_release(), which can't be used this
way.
In preparation for preventing this in WRITE_ONCE(), change the fault
injection code to use a local variable instead.
Signed-off-by: Will Deacon <will@...nel.org>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: Akinobu Mita <akinobu.mita@...il.com>
Link: https://lkml.kernel.org/r/20200511204150.27858-9-will@kernel.org
---
lib/fault-inject.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index 8186ca8..ce12621 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -106,7 +106,9 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
unsigned int fail_nth = READ_ONCE(current->fail_nth);
if (fail_nth) {
- if (!WRITE_ONCE(current->fail_nth, fail_nth - 1))
+ fail_nth--;
+ WRITE_ONCE(current->fail_nth, fail_nth);
+ if (!fail_nth)
goto fail;
return false;
Powered by blists - more mailing lists