Skip to content

Commit a534e92

Browse files
Qian Cairafaeljw
authored andcommitted
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 <[email protected]> [ rjw: Changelog ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 3c87402 commit a534e92

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/power/qos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static DEFINE_SPINLOCK(pm_qos_lock);
5252
*/
5353
s32 pm_qos_read_value(struct pm_qos_constraints *c)
5454
{
55-
return c->target_value;
55+
return READ_ONCE(c->target_value);
5656
}
5757

5858
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)
7575

7676
static void pm_qos_set_value(struct pm_qos_constraints *c, s32 value)
7777
{
78-
c->target_value = value;
78+
WRITE_ONCE(c->target_value, value);
7979
}
8080

8181
/**

0 commit comments

Comments
 (0)