Project

General

Profile

Actions

Bug #1773

closed

patch: Add variable sleep time to vm_zeroidle

Added by vsrinivas over 14 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

--- vm_zeroidle.c.orig 2010-05-26 15:09:26 -0700
+++ vm_zeroidle.c 2010-05-26 15:12:50 -0700
@ -90,6 +90,9 @
STATE_RELEASE_PAGE
};

#define DEFAULT_SLEEP_TIME (hz / 10)
#define LONG_SLEEP_TIME (hz * 10)
+
static int zero_state;

/*
@ -112,6 +115,20 @
return (1);
}

/*
* vm_pagezero should sleep for a long time when idlezero is disabled or when
+ * there is an excess of zeroed pages.
+ */
static int
+vm_page_zero_time(void)
{
+ if (idlezero_enable == 0)
+ return (LONG_SLEEP_TIME);
+ if (vm_page_zero_count >= ZIDLE_HI(vmstats.v_free_count))
+ return (LONG_SLEEP_TIME);
+ return (DEFAULT_SLEEP_TIME);
}

static void
vm_pagezero(void __unused *arg) {
@ -120,6 +137,7 @
enum zeroidle_state state = STATE_IDLE;
char *pg = NULL;
int npages = 0;
+ int sleep_time;
int i = 0;

/*
@ -132,6 +150,7 @
rel_mplock();
lwkt_setpri_self(TDPRI_IDLE_WORK);
lwkt_setcpu_self(globaldata_find(ncpus - 1));
+ sleep_time = DEFAULT_SLEEP_TIME;
/*
 * Loop forever
@ -142,9 +161,10 @
/* * Wait for work.
/
- tsleep(&zero_state, 0, "pgzero", hz / 10);
+ tsleep(&zero_state, 0, "pgzero", sleep_time);
if (vm_page_zero_check())
npages = idlezero_rate / 10;
+ sleep_time = vm_page_zero_time();
if (npages)
state = STATE_GET_PAGE; /
Fallthrough */
break;
@ -198,7 +218,8 @
}
break;
}
- lwkt_switch();
+ if (lwkt_check_resched(curthread))
+ lwkt_switch();
}
}

=================================

The patch above should cause vm_zeroidle to sleep for longer periods of time (hz
  • 10) when it is disabled or when there are a lot of pages. Longer sleep times
    would be better when there're no pages to zero.

It also conditionalizes the lwkt_switch(); I think this is worth doing, since
lwkt_check_resched() is cheaper than lwkt_switch(). This may or may not be worth
doing.

-- vs

Actions #1

Updated by vsrinivas over 14 years ago

Now available in my git tree, branch zerothread.

Actions #2

Updated by vsrinivas over 14 years ago

Resolved by commit 62b382d3e9fa0f3a1df838b9fd83b1a00ba80782.

Actions

Also available in: Atom PDF