From 00d027966733f5dab7f5cbacbc3428fd079cff5f Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <>
Date: Fri, 15 Oct 2021 23:09:33 +0200
Subject: [PATCH 028/166] mm: page_alloc: Use migrate_disable() in

drain_local_pages_wq() disables preemption to avoid CPU migration during
CPU hotplug and can't use cpus_read_lock().

Using migrate_disable() works here, too. The scheduler won't take the
CPU offline until the task left the migrate-disable section.
The problem with disabled preemption here is that drain_local_pages()
acquires locks which are turned into sleeping locks on PREEMPT_RT and
can't be acquired with disabled preemption.

Use migrate_disable() in drain_local_pages_wq().

Signed-off-by: Sebastian Andrzej Siewior <>
 mm/page_alloc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-5.15.13-rt26/mm/page_alloc.c
@ linux-5.15.13-rt26/mm/page_alloc.c:3152 @ static void drain_local_pages_wq(struct
 	 * cpu which is alright but we also have to make sure to not move to
 	 * a different one.
-	preempt_disable();
+	migrate_disable();
-	preempt_enable();
+	migrate_enable();