[Devel] [PATCH RH9 2/2] mm: tcache: handle not initialized tcache properly in tcache_shrink_count

Alexander Mikhalitsyn alexander.mikhalitsyn at virtuozzo.com
Mon Oct 25 15:30:39 MSK 2021


We have explicit call to shrink_tcache in do_try_to_free_pages.
In almost all cases this is safe, because at the time when this call
happens we have tcache subsystem fully initialized. But on early
boot staged it may occur that kernel is under memory preassure
in some of zones (in our case ZONE_DMA), then do_try_to_free_pages
will be called during the reclaim procedures and kernel crashes
because tcache_nodeinfo structures are not initialized.

TBD: investigate why we meet problems with ZONE_DMA in kexec'ed
kernel and fix that.

https://jira.sw.ru/browse/PSBM-135139

Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
 mm/tcache.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/tcache.c b/mm/tcache.c
index 27c2764f9c26..3c872c3bd03b 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -1194,6 +1194,9 @@ unsigned long tcache_shrink_count(struct shrinker *shrink,
 	atomic_long_t *nr_pages = &tcache_nodeinfo[sc->nid].nr_pages;
 	long ret;
 
+	if (unlikely(!tcache_nodeinfo))
+		return 0;
+
 	ret = atomic_long_read(nr_pages);
 	WARN_ON(ret < 0);
 	return ret >= 0 ? ret : 0;
-- 
2.31.1



More information about the Devel mailing list