[Devel] [PATCH RHEL9 COMMIT] mm: tcache: handle not initialized tcache properly in tcache_shrink_count

Konstantin Khorenko khorenko at virtuozzo.com
Mon Oct 25 15:55:23 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.16
------>
commit eae0e0652510dd46be66a487d896a8753e5b684e
Author: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
Date:   Mon Oct 25 15:55:22 2021 +0300

    mm: tcache: handle not initialized tcache properly in tcache_shrink_count
    
    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;


More information about the Devel mailing list