powerpc/cacheinfo: Warn if cache object chain becomes unordered
authorNathan Lynch <nathanl@linux.ibm.com>
Thu, 27 Jun 2019 05:15:37 +0000 (00:15 -0500)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 30 Jul 2020 12:53:48 +0000 (22:53 +1000)
This can catch cases where the device tree has gotten mishandled into
an inconsistent state at runtime, e.g. the cache nodes for both the
source and the destination are present after a migration.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190627051537.7298-5-nathanl@linux.ibm.com
arch/powerpc/kernel/cacheinfo.c

index a116d5bb6b12152274cd58a55bc612551896b497..65ab9fcebd3174fed6b2232c270bc44659013241 100644 (file)
@@ -420,6 +420,15 @@ static void link_cache_lists(struct cache *smaller, struct cache *bigger)
        }
 
        smaller->next_local = bigger;
+
+       /*
+        * The cache->next_local list sorts by level ascending:
+        * L1d -> L1i -> L2 -> L3 ...
+        */
+       WARN_ONCE((smaller->level == 1 && bigger->level > 2) ||
+                 (smaller->level > 1 && bigger->level != smaller->level + 1),
+                 "linking L%i cache %pOFP to L%i cache %pOFP; skipped a level?\n",
+                 smaller->level, smaller->ofnode, bigger->level, bigger->ofnode);
 }
 
 static void do_subsidiary_caches_debugcheck(struct cache *cache)