runtime·MSpanList_Insert(&h->large, s);
}
+static void
+forcegchelper(Note *note)
+{
+ runtime·gc(1);
+ runtime·notewakeup(note);
+}
+
// Release (part of) unused memory to OS.
// Goroutine created at startup.
// Loop forever.
uintptr released, sumreleased;
byte *env;
bool trace;
- Note note;
+ Note note, *notep;
// If we go two minutes without a garbage collection, force one to run.
forcegc = 2*60*1e9;
now = runtime·nanotime();
if(now - mstats.last_gc > forcegc) {
runtime·unlock(h);
- runtime·gc(1);
+ // The scavenger can not block other goroutines,
+ // otherwise deadlock detector can fire spuriously.
+ // GC blocks other goroutines via the runtime·worldsema.
+ runtime·noteclear(¬e);
+ notep = ¬e;
+ runtime·newproc1((byte*)forcegchelper, (byte*)¬ep, sizeof(notep), 0, runtime·MHeap_Scavenger);
+ runtime·entersyscall();
+ runtime·notesleep(¬e);
+ runtime·exitsyscall();
runtime·lock(h);
now = runtime·nanotime();
if (trace)