ref: ac416fbf7156efa9aabb128322636ff576950c65
parent: 68439f169de75de87aa7b2455196a82b9c6180c0
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Oct 16 12:10:26 EDT 2012
kernel: duppage cleanup remove the sched() call and retry loop from duppage() and just drop the page lock, then reacquire it after lock(&palloc).
--- a/sys/src/9/port/page.c
+++ b/sys/src/9/port/page.c
@@ -264,30 +264,12 @@
return p;
}
-static int dupretries = 15000;
-
void
duppage(Page *p) /* Always call with p locked */
{Page *np;
int color;
- int retries;
- retries = 0;
-retry:
- /* don't dup pages that are shared or have no image */
- if(p->ref != 1 || p->image == nil || p->image->notext)
- return;
-
- if(retries++ > dupretries){- print("duppage %d, up %p\n", retries, up);- dupretries += 100;
- if(dupretries > 100000)
- panic("duppage");- uncachepage(p);
- return;
- }
-
/*
* normal lock ordering is to call
* lock(&palloc) before lock(p).
@@ -295,14 +277,18 @@
* our locks and try again. as the page
* is from the image cache, this might
* let someone else come in and grab it
- * so we check page ref above.
+ * so we check page ref below.
*/
if(!canlock(&palloc)){unlock(p);
- if(up)
- sched();
+ lock(&palloc);
lock(p);
- goto retry;
+ }
+
+ /* don't dup pages that are shared or have no image */
+ if(p->ref != 1 || p->image == nil || p->image->notext){+ unlock(&palloc);
+ return;
}
/* No freelist cache when memory is very low */
--
⑨