diff options
author | Qian Cai <cai@lca.pw> | 2020-02-25 20:58:13 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2020-03-03 23:34:51 +0100 |
commit | a534e924c58d2e7c07509521e87d059dd029dca1 (patch) | |
tree | 0e5dc4d1dc85172d654680b371e38f693c80a730 /kernel/power | |
parent | 3c87402771f2bc38ee92eb506bb58e4fc4a5b8b9 (diff) | |
download | linux-a534e924c58d2e7c07509521e87d059dd029dca1.tar.gz linux-a534e924c58d2e7c07509521e87d059dd029dca1.tar.bz2 linux-a534e924c58d2e7c07509521e87d059dd029dca1.zip |
PM: QoS: annotate data races in pm_qos_*_value()
The target_value field in struct pm_qos_constraints is used for
lockless access to the effective constraint value of a given QoS
list, so the readers of it cannot expect it to always reflect the
most recent effective constraint value. However, they can and do
expect it to be equal to a valid effective constraint value computed
at a certain time in the past (event though it may not be the most
recent one), so add READ|WRITE_ONCE() annotations around the
target_value accesses to prevent the compiler from possibly causing
that expectation to be unmet by generating code in an exceptionally
convoluted way.
Signed-off-by: Qian Cai <cai@lca.pw>
[ rjw: Changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/qos.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 32927682bcc4..db0bed2cae26 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -52,7 +52,7 @@ static DEFINE_SPINLOCK(pm_qos_lock); */ s32 pm_qos_read_value(struct pm_qos_constraints *c) { - return c->target_value; + return READ_ONCE(c->target_value); } static int pm_qos_get_value(struct pm_qos_constraints *c) @@ -75,7 +75,7 @@ static int pm_qos_get_value(struct pm_qos_constraints *c) static void pm_qos_set_value(struct pm_qos_constraints *c, s32 value) { - c->target_value = value; + WRITE_ONCE(c->target_value, value); } /** |