From owner-freebsd-bugs@FreeBSD.ORG Sat Mar 5 13:10:14 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 44D1F16A4CF for ; Sat, 5 Mar 2005 13:10:14 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0940B43D5D for ; Sat, 5 Mar 2005 13:10:14 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id j25DADVG032762 for ; Sat, 5 Mar 2005 13:10:13 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id j25DADlk032761; Sat, 5 Mar 2005 13:10:13 GMT (envelope-from gnats) Resent-Date: Sat, 5 Mar 2005 13:10:13 GMT Resent-Message-Id: <200503051310.j25DADlk032761@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Antoine Brodin Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7327816A4CE for ; Sat, 5 Mar 2005 13:06:27 +0000 (GMT) Received: from barton.dreadbsd.org (massena-4-82-67-196-50.fbx.proxad.net [82.67.196.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7E56943D3F for ; Sat, 5 Mar 2005 13:06:26 +0000 (GMT) (envelope-from antoine@massena-4-82-67-196-50.fbx.proxad.net) Received: from barton.dreadbsd.org (localhost [127.0.0.1]) by barton.dreadbsd.org (8.13.3/8.13.1) with ESMTP id j25D6N4J000990 for ; Sat, 5 Mar 2005 14:06:24 +0100 (CET) (envelope-from antoine@massena-4-82-67-196-50.fbx.proxad.net) Received: (from antoine@localhost) by barton.dreadbsd.org (8.13.3/8.13.1/Submit) id j25D6NFG000989; Sat, 5 Mar 2005 14:06:23 +0100 (CET) (envelope-from antoine) Message-Id: <200503051306.j25D6NFG000989@barton.dreadbsd.org> Date: Sat, 5 Mar 2005 14:06:23 +0100 (CET) From: Antoine Brodin To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/78444: sched_ule: doesn't keep track of the sleep time of a process X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Antoine Brodin List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Mar 2005 13:10:14 -0000 >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@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: