From xdivac02@stud.fit.vutbr.cz  Tue Oct 12 07:33:07 2004
Return-Path: <xdivac02@stud.fit.vutbr.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1A96816A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Oct 2004 07:33:07 +0000 (GMT)
Received: from eva.fit.vutbr.cz (eva.fit.vutbr.cz [147.229.10.14])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D373E43D39
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Oct 2004 07:33:05 +0000 (GMT)
	(envelope-from xdivac02@stud.fit.vutbr.cz)
Received: from eva.fit.vutbr.cz (localhost [127.0.0.1])
	by eva.fit.vutbr.cz (8.12.11/8.12.11) with ESMTP id i9C7X2aH071740
	(version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Oct 2004 09:33:02 +0200 (CEST)
Received: (from xdivac02@localhost)
	by eva.fit.vutbr.cz (8.12.11/8.12.5/Submit) id i9C7X1wB071737;
	Tue, 12 Oct 2004 09:33:01 +0200 (CEST)
Message-Id: <200410120733.i9C7X1wB071737@eva.fit.vutbr.cz>
Date: Tue, 12 Oct 2004 09:33:01 +0200 (CEST)
From: Divacky Roman <xdivac02@stud.fit.vutbr.cz>
Reply-To: Divacky Roman <xdivac02@stud.fit.vutbr.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: small cleanup of SCHED_ULE
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         72560
>Category:       kern
>Synopsis:       [sched_ule] [patch] small cleanup of SCHED_ULE
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jeff
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 12 07:40:17 GMT 2004
>Closed-Date:    Tue Jul 04 14:04:55 GMT 2006
>Last-Modified:  Tue Jul 04 14:04:55 GMT 2006
>Originator:     Divacky Roman
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
home
>Environment:
FreeBSD witten 6.0-CURRENT FreeBSD 6.0-CURRENT #139: Sat Oct  9 12:37:22 CEST
2004     root@witten:/usr/obj/usr/src/sys/NEOLOGISM  i386


	
>Description:
Small cleanup of sched_ule.c, some things are unecessary, some juts ugly. This
patch identifies a few and (tries to) repair them.
>How-To-Repeat:
	Apply this
>Fix:
--- sched_ule.c	Wed Oct  6 00:14:02 2004
+++ /root/sched_ule.c	Sat Oct  9 14:51:35 2004
@@ -526,14 +526,12 @@
 	struct kseq_group *low;
 	struct kseq_group *ksg;
 	int cnt;
-	int i;
 
 	if (smp_started == 0)
 		goto out;
 	low = high = NULL;
-	i = random() % (ksg_maxid + 1);
 	for (cnt = 0; cnt <= ksg_maxid; cnt++) {
-		ksg = KSEQ_GROUP(i);
+		ksg = KSEQ_GROUP(cnt);
 		/*
 		 * Find the CPU with the highest load that has some
 		 * threads to transfer.
@@ -543,8 +541,6 @@
 			high = ksg;
 		if (low == NULL || ksg->ksg_load < low->ksg_load)
 			low = ksg;
-		if (++i > ksg_maxid)
-			i = 0;
 	}
 	if (low != NULL && high != NULL && high != low)
 		sched_balance_pair(LIST_FIRST(&high->ksg_members),
@@ -575,8 +571,7 @@
 
 	if (ksg->ksg_transferable == 0)
 		return;
-	low = NULL;
-	high = NULL;
+	low = high = NULL;
 	LIST_FOREACH(kseq, &ksg->ksg_members, ksq_siblings) {
 		load = kseq->ksq_load;
 		if (high == NULL || load > high->ksq_load)
@@ -625,7 +624,6 @@
 	move = min(move, transferable);
 	for (i = 0; i < move; i++)
 		kseq_move(high, KSEQ_ID(low));
-	return;
 }
 
 static void
>Release-Note:
>Audit-Trail:

From: David Schultz <das@FreeBSD.ORG>
To: Divacky Roman <xdivac02@stud.fit.vutbr.cz>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/72560: small cleanup of SCHED_ULE
Date: Thu, 14 Oct 2004 08:59:23 -0400

 On Tue, Oct 12, 2004, Divacky Roman wrote:
 > Small cleanup of sched_ule.c, some things are unecessary, some juts ugly. This
 > patch identifies a few and (tries to) repair them.
 > >How-To-Repeat:
 > 	Apply this
 > -	i = random() % (ksg_maxid + 1);
 >  	for (cnt = 0; cnt <= ksg_maxid; cnt++) {
 > -		ksg = KSEQ_GROUP(i);
 > +		ksg = KSEQ_GROUP(cnt);
 >  		/*
 >  		 * Find the CPU with the highest load that has some
 >  		 * threads to transfer.
 > @@ -543,8 +541,6 @@
 >  			high = ksg;
 >  		if (low == NULL || ksg->ksg_load < low->ksg_load)
 >  			low = ksg;
 > -		if (++i > ksg_maxid)
 > -			i = 0;
 
 If there are several CPUs with the same load, this patch would
 cause the CPU with the lowest index to always be chosen, rather
 than picking one ``randomly.''  Maybe choosing randomly when all
 else is equal isn't that important, but this seems to be a step
 backwards.
Responsible-Changed-From-To: freebsd-bugs->jeff 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Fri Nov 19 19:19:03 GMT 2004 
Responsible-Changed-Why:  
Over to ULE author. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72560 
State-Changed-From-To: open->closed 
State-Changed-By: maxim 
State-Changed-When: Tue Jul 4 14:01:21 UTC 2006 
State-Changed-Why:  
As David says sched_balance() is correct.  Other changes are just 
cosmetic. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72560 
>Unformatted:
