From fcacce0f2f510b21930052fcc0e07103db33a5b3 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 16 Oct 2012 16:10:26 +0200 Subject: kernel: duppage cleanup remove the sched() call and retry loop from duppage() and just drop the page lock, then reacquire it after lock(&palloc). --- sys/src/9/port/page.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'sys/src/9/port/page.c') diff --git a/sys/src/9/port/page.c b/sys/src/9/port/page.c index b004152e9..e8c5b6ce0 100644 --- a/sys/src/9/port/page.c +++ b/sys/src/9/port/page.c @@ -264,29 +264,11 @@ auxpage(void) 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 @@ -295,14 +277,18 @@ retry: * 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 */ -- cgit v1.2.3