From owner-freebsd-arch Wed Jan 9 14:40:16 2002 Delivered-To: freebsd-arch@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id 0A96837B404 for ; Wed, 9 Jan 2002 14:40:11 -0800 (PST) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020109224010.GJWZ20395.rwcrmhc52.attbi.com@InterJet.elischer.org> for ; Wed, 9 Jan 2002 22:40:10 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id OAA54379 for ; Wed, 9 Jan 2002 14:39:54 -0800 (PST) Date: Wed, 9 Jan 2002 14:39:52 -0800 (PST) From: Julian Elischer To: arch@freebsd.org Subject: priority and swapping: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The swapping code has teh following snippet in schedular() (what a misnamed function) which tries to select which swapped out process to swap back in: FOREACH_PROC_IN_SYSTEM(p) { struct ksegrp *kg; if (p->p_sflag & (PS_INMEM | PS_SWAPPING)) { continue; } mtx_lock_spin(&sched_lock); FOREACH_THREAD_IN_PROC(p, td) { /* Only consider runnable threads */ if (td->td_state == TDS_RUNQ) { kg = td->td_ksegrp; pri = p->p_swtime + kg->kg_slptime; if ((p->p_sflag & PS_SWAPINREQ) == 0) { pri -= kg->kg_nice * 8; } /* * if this ksegrp is higher priority * and there is enough space, then select * this process instead of the previous * selection. */ if (pri > ppri) { pp = p; ppri = pri; } } This is a directly 'expanded' version of what was there before the KSE changes... (basically just the 2nd FOREACH was added) nowhere in this code does it look at the actual priority of the thread (was process) priority even referenced. Instead they are creating this rather strange number derived from various timings. The original pre KSE code was: LIST_FOREACH(p, &allproc, p_list) { mtx_lock_spin(&sched_lock); if (p->p_stat == SRUN && (p->p_sflag & (PS_INMEM | PS_SWAPPING)) == 0) { pri = p->p_swtime + p->p_slptime; if ((p->p_sflag & PS_SWAPINREQ) == 0) { pri -= p->p_nice * 8; } /* * if this process is higher priority and there is * enough space, then select this process instead of * the previous selection. */ if (pri > ppri) { pp = p; ppri = pri; } } which didn't reference the priority either. What exactly is it trying to do? scheduel a process for swappin based purely on time swapped out? doesn't priority (despite the names in the code) come into it? Was it originally there in some pre-freebsd version? The code in 1.1 of the file is: for (p = (struct proc *)allproc; p != NULL; p = p->p_next) { if (p->p_stat == SRUN && (p->p_flag & P_INMEM) == 0) { pri = p->p_swtime + p->p_slptime - p->p_nice * 8; if (pri > ppri) { pp = p; ppri = pri; } } } SWAPINREQ simply disabling the effect of NICE is a bit wierd too. thoughts anyone? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message