[patch] deadlock in vm_reserv_reclaim_contig()

Svatopluk Kraus onwahe at gmail.com
Fri Apr 10 09:11:43 UTC 2015


Hi,

my RPI-B has been stuck in vm_reserv_reclaim_contig() due to a bug
within that function. I can reproduce that easily on my two-core
pandaboard when I limit all memory in system to 128MiB and run "make
-j16 kernel-toolchain". It happens in few seconds.

The patch should be self-explanatory. The problem is that there is a
free page found in reservation which does not fulfill alignment
requirement, thus next free page should be looked for. However, due to
the bug, the same free page is found out again and again.

The patch takes into account that shift by m on n-bit arch has an
undefined behaviour if m >= n.

Svatopluk Kraus
-------------- next part --------------
Index: sys/vm/vm_reserv.c
===================================================================
--- sys/vm/vm_reserv.c	(revision 281292)
+++ sys/vm/vm_reserv.c	(working copy)
@@ -983,8 +983,12 @@
 				break;
 			} else if ((pa & (alignment - 1)) != 0 ||
 			    ((pa ^ (pa + size - 1)) & ~(boundary - 1)) != 0) {
-				/* Continue with this reservation. */
-				hi = lo;
+				/* Continue with this or next reservation. */
+				hi = lo + 1;
+				if (hi >= NBPOPMAP) {
+					hi = 0;
+					i++;
+				}
 				continue;
 			}
 			/* Find the next used page. */


More information about the freebsd-current mailing list