# Re: \[PATCH 1/1\] mm/vmstat: Protect per cpu variables with preempt disable on RT

- From: Vlastimil Babka \<hidden\>
- Date: 2021-08-06 12:39:01 
- List: linux-rt-users
- Page: https://ratatoskr.run/linux-rt-users/2021/08/1470224
- Thread: https://ratatoskr.run/linux-mm/2021/08/1469090/t.md

```text
On 8/5/21 6:00 PM, Mel Gorman wrote:
> From: Ingo Molnar <redacted>
> 
> Disable preemption on -RT for the vmstat code. On vanila the code runs
> in IRQ-off regions while on -RT it may not when stats are updated under
> a local_lock. "preempt_disable" ensures that the same resources is not
> updated in parallel due to preemption.
> 
> This patch differs from the preempt-rt version where __count_vm_event and
> __count_vm_events are also protected. The counters are explicitly "allowed
> to be to be racy" so there is no need to protect them from preemption. Only
> the accurate page stats that are updated by a read-modify-write need
> protection. This patch also differs in that a preempt_[en|dis]able_rt
> helper is not used. As vmstat is the only user of the helper, it was
> suggested that it be open-coded in vmstat.c instead of risking the helper
> being used in unnecessary contexts.
> 
> Signed-off-by: Ingo Molnar <redacted>
> Signed-off-by: Thomas Gleixner <redacted>
> Signed-off-by: Mel Gorman <redacted>

Acked-by: Vlastimil Babka <redacted>
```
