Re: [PATCH 0/4] memcg: cleanup the memcg stats interfaces

From: Sebastian Andrzej Siewior
Date: Tue Nov 11 2025 - 03:02:13 EST


> > I mean converting these places to use spin_lock() instead of
> > spin_lock_irq().
>
> Just one thing I noticed while looking at __folio_migrate_mapping()...
>
> - xas_lock_irq() -> xas_unlock() -> local_irq_enable()
> - swap_cluster_get_and_lock_irq() -> swap_cluster_unlock() -> local_irq_enable()
>
> is wrong because spin_lock_irq() doesn't disable IRQ on PREEMPT_RT.
>
> Not 100% sure if it would be benign or lead to actual bugs that need
> to be fixed in -stable kernels.
>
> Cc'ing RT folks again :)

The tail in __folio_migrate_mapping() after xas_unlock()/
swap_cluster_unlock(), is limited to __mod_lruvec_state() based stats
updates. There is a preempt_disable_nested() in __mod_zone_page_state()
to ensure that the update happens on the same CPU and is not preempted.
On PREEMPT_RT there should be no in-IRQ updates of these counters.
The IRQ enable at the end does nothing. There might be CPU migration
between the individual stats updates.
If it remains like this, it is fine. Please don't advertise ;)

Sebastian