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

From: Thomas Gleixner
Date: Thu Aug 05 2021 - 08:56:58 EST


On Wed, Aug 04 2021 at 15:23, Mel Gorman wrote:
Mel,

> On Wed, Aug 04, 2021 at 03:42:25PM +0200, Vlastimil Babka wrote:
>> The idea was not build-time, but runtime (hidden behind lockdep, VM_DEBUG or
>> whatnot), i.e.:
>>
>> <sched_expert> what that code needs is switch(item) { case foo1: case foo2:
>> lockdep_assert_irqs_disabled(); break; case bar1: case bar2:
>> lockdep_assert_preempt_disabled(); lockdep_assert_no_in_irq(); break; } or
>> something along those lines
>>
> Ok, that would potentially work. It may not even need to split the stats
> into different enums. Simply document which stats need protection from
> IRQ or preemption and use PROVE_LOCKING to check if preemption or IRQs
> are disabled depending on the kernel config. I don't think it gets rid
> of preempt_disable_rt unless the API was completely reworked with entry
> points that describe the locking requirements. That would be tricky
> because the requirements differ between kernel configurations.

Right. This won't get rid of the preempt disabling on RT, but I think we
should rather open code this

if (IS_ENABLED(CONFIG_PREEMPT_RT))
preempt_dis/enable();

instead of proliferating these helper macros which have only one user left.

Thanks,

tglx