git: 9front

Download patch

ref: ebdf006e4087069501271678d6fdd9b27f7341d7
parent: df00fa14f2956fd8713151c985141c5e0464370e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Jul 13 08:53:15 EDT 2025

kernel: limit fscache to 256MB

Reclaiming pages takes too long when
we sink all our idle pages into
the fscache, yielding to lockloop prints
during relcaim.

Limit the size of the fscache to 256MB
to have more predictable behaviour.

--- a/sys/src/9/port/cache.c
+++ b/sys/src/9/port/cache.c
@@ -9,10 +9,12 @@
 {
 	NHASH		= 128,
 	NFILE		= 4093,		/* should be prime */
-	MAXCACHE	= 8*1024*1024,
-
+	MAXCACHE	= 8*MB,		/* per file */
 	MAPBITS		= 8*sizeof(ulong),
 	NBITMAP		= (PGROUND(MAXCACHE)/BY2PG + MAPBITS-1) / MAPBITS,
+
+	/* maximum number pages in fscache image */
+	TOTALPAGES	= (256*MB)/BY2PG,
 };
 
 /* devmnt.c: parallel read ahread implementation */
@@ -425,6 +427,8 @@
 				invalidate(m, offset + pn*BY2PG, len);
 				break;
 			}
+			if(fscache.pgref > TOTALPAGES)
+				pagereclaim(&fscache);
 			p = newpage(0, nil, pn*BY2PG);
 			p->daddr = cacheaddr(m, pn);
 			cachedel(&fscache, p->daddr);
--