kern/78444: sched_ule: doesn't keep track of the sleep time of a process

Antoine Brodin antoine.brodin at laposte.net
Sat Mar 5 13:10:14 GMT 2005


>Number:         78444
>Category:       kern
>Synopsis:       sched_ule: doesn't keep track of the sleep time of a process
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 05 13:10:13 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Antoine Brodin
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
none
>Environment:
System: FreeBSD barton.dreadbsd.org 6.0-CURRENT FreeBSD 6.0-CURRENT #1: Thu Mar 3 15:04:32 CET 2005 antoine at barton.dreadbsd.org:/usr/obj/usr/src/sys/BARTON i386
>Description:
When using the sched_ule scheduler, the sleep time of a process isn't
computed.
kg_slptime is zeroed during the ksegrp creation and after that, it's
never modified.
In sched_ule.c, something named kg_slptime is manipulated but it's not
the sleep time of a process: there's the macro
#define kg_slptime kg_sched->skg_slptime
It represents an history of the process's sleep and not a sleep time
and it would be bogus to use it as the sleep time.

Side effects: swapout doesn't work as intended: a process can never be
swaped out since its sleep time is 0 and is below swap_idle_threshold1.
>How-To-Repeat:
Use ps:
$ ps -o sl
 SL
  0
  0
  0
  0
  0
  0
  0
  0
  0
  0
  0
  0
>Fix:
Having a lightweight schedcpu routine running every hz ticks like in
sched_4bsd ?
The problem is that such a routine would use a O(n) algorithm and would
 penalize quite unnecessarily sched_ule.

Another idea: add a sched_slptime routine in sched_ule.c for swapout
and fill_kinfo_thread to use ?

add something like this to sched_ule.c:

%%
u_int
sched_slptime(struct ksegrp *kg)
{
	struct thread *td;
	u_int slptime = UINT_MAX;
	u_int hzticks;

	PROC_LOCK_ASSERT(kg->kg_proc, MA_OWNED);
	mtx_assert(&sched_lock, MA_OWNED);
	FOREACH_THREAD_IN_GROUP(kg, td) {
		if (td->td_slptime) {
			hzticks = ticks - td->td_slptime;			
			slptime = min(slptime, hzticks);
		} else
			return (0);
	}
	return (slptime / hz);
}
%%

add something like this to sched_4bsd.c:

%%
u_int
sched_slptime(struct ksegrp *kg)
{

	return (kg->kg_slptime);
}
%%

add something like this to sched.h:

%%
u_int sched_slptime(struct ksegrp *kg);
%%

and use sched_slptime(kg) in vm_glue.c and kern_proc.c instead of
kg->kg_slptime


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list