[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
kern/120138: steal_thresh may be set a wrong value in sched_ule.c
- To: freebsd-gnats-submit_(_at_)_FreeBSD_(_dot_)_org
- Subject: kern/120138: steal_thresh may be set a wrong value in sched_ule.c
- From: KOIE Hidetaka <koie_(_at_)_suri_(_dot_)_co_(_dot_)_jp>
- Date: Wed, 30 Jan 2008 03:41:49 GMT
- Cc:
- Resent-date: Wed, 30 Jan 2008 03:50:00 GMT
- Resent-from: FreeBSD-gnats-submit_(_at_)_FreeBSD_(_dot_)_org (GNATS Filer)
- Resent-message-id: <200801300350_(_dot_)_m0U3o0Qt016941_(_at_)_freefall_(_dot_)_freebsd_(_dot_)_org>
- Resent-reply-to: FreeBSD-gnats-submit_(_at_)_FreeBSD_(_dot_)_org, KOIE Hidetaka <koie_(_at_)_suri_(_dot_)_co_(_dot_)_jp>
- Resent-to: freebsd-bugs_(_at_)_FreeBSD_(_dot_)_org
>Number: 120138
>Category: kern
>Synopsis: steal_thresh may be set a wrong value in sched_ule.c
>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: Wed Jan 30 03:50:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: KOIE Hidetaka
>Release: FreeBSD 8.0-CURRENT amd64
>Organization:
surigiken
>Environment:
System: FreeBSD guriandgura 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sat Jan 26 13:56
:29 JST 2008 koie_(_at_)_guriandgura:/usr/obj/usr/src/sys/GURIANDGURA amd64
>Description:
If mp_ncpus is not a power of 2, ffs(mp_ncpus) != floor(log2(mp_ncpu)).
But I'm not seen an irregular system,
I don't verify whether the problem occurs.
>How-To-Repeat:
#include <math.h>
#include <stdio.h>
#include <string.h>
main()
{
int i;
for (i = 1 ;i < 10;i++)
printf("%d %d %d %d\n",
i,
ffs(i)-1,
fls(i)-1,
(int)floor(log(i)/log(2)));
}
>Fix:
use fls().
Patch attached with submission follows:
--- sched_ule.c.orig 2008-01-30 12:08:11.896645510 +0900
+++ sched_ule.c 2008-01-30 12:15:32.154540563 +0900
@@ -1365,11 +1365,11 @@ sched_initticks(void *dummy)
*/
balance_interval = realstathz;
/*
- * Set steal thresh to log2(mp_ncpu) but no greater than 4. This
+ * Set steal thresh to floor(log2(mp_ncpu)) but no greater than 4. This
* prevents excess thrashing on large machines and excess idle on
* smaller machines.
*/
- steal_thresh = min(ffs(mp_ncpus) - 1, 4);
+ steal_thresh = min(fls(mp_ncpus) - 1, 4);
affinity = SCHED_AFFINITY_DEFAULT;
#endif
}
>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
freebsd-bugs_(_at_)_freebsd_(_dot_)_org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscribe_(_at_)_freebsd_(_dot_)_org"
Visit your host, monkey.org