Skip to content

Commit 9458e0a

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
authored andcommitted
flex_proportions: Disable preemption entering the write section.
The seqcount fprop_global::sequence is not associated with a lock. The write section (fprop_new_period()) is invoked from a timer and since the softirq is preemptible on PREEMPT_RT it is possible to preempt the write section which is not desited. Disable preemption around the write section on PREEMPT_RT. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c7e0b3d commit 9458e0a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/flex_proportions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ bool fprop_new_period(struct fprop_global *p, int periods)
7070
*/
7171
if (events <= 1)
7272
return false;
73+
preempt_disable_nested();
7374
write_seqcount_begin(&p->sequence);
7475
if (periods < 64)
7576
events -= events >> periods;
7677
/* Use addition to avoid losing events happening between sum and set */
7778
percpu_counter_add(&p->events, -events);
7879
p->period += periods;
7980
write_seqcount_end(&p->sequence);
81+
preempt_enable_nested();
8082

8183
return true;
8284
}

0 commit comments

Comments
 (0)