Skip to contentSkip to conversation

mm-fs-fix-lru_cache_disabled-race-in-bh_lru.patch removed from -mm tree

merged Andrew Morton 1 participant 1 message Mar 25, 2022 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The patch titled
Subject: mm: fs: fix lru_cache_disabled race in bh_lru
has been removed from the -mm tree. Its filename was
mm-fs-fix-lru_cache_disabled-race-in-bh_lru.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Minchan Kim <[email protected]>
Subject: mm: fs: fix lru_cache_disabled race in bh_lru

Check lru_cache_disabled under bh_lru_lock. Otherwise, it could introduce race below and it fails to migrate pages containing buffer_head.

CPU 0 CPU 1

bh_lru_install
lru_cache_disable
lru_cache_disabled = false
atomic_inc(&lru_disable_count); invalidate_bh_lrus_cpu of CPU 0 bh_lru_lock __invalidate_bh_lrus bh_lru_unlock
bh_lru_lock
install the bh
bh_lru_unlock

WHen this race happens a CMA allocation fails, which is critical for the workload which depends on CMA.

Fixes 8cc621d2f45d ("mm: fs: invalidate BH LRU during page migration")
Cc Chris Goldsworthy <[email protected]>
Cc Marcelo Tosatti <[email protected]>
Cc John Dias <[email protected]>

---

 fs/buffer.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
fs/buffer.c renamed from fs/buffer.c~mm-fs-fix-lru_cache_disabled-race-in-bh_lru +5 -3
@@ -1235,16 +1235,18 @@ static void bh_lru_install(struct buffer
 	int i;
 
 	check_irqs_on();
+	bh_lru_lock();
+
 	/*
 	 * the refcount of buffer_head in bh_lru prevents dropping the
 	 * attached page(i.e., try_to_free_buffers) so it could cause
 	 * failing page migration.
 	 * Skip putting upcoming bh into bh_lru until migration is done.
 	 */
-	if (lru_cache_disabled())
+	if (lru_cache_disabled()) {
+		bh_lru_unlock();
 		return;
-
-	bh_lru_lock();
+	}
 
 	b = this_cpu_ptr(&bh_lrus);
 	for (i = 0; i < BH_LRU_SIZE; i++) {

_

Patches currently in -mm which might be from [email protected] are