From nobody@FreeBSD.org  Sat Dec  8 19:11:48 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 028A816A418
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  8 Dec 2007 19:11:48 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id E71A213C448
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  8 Dec 2007 19:11:47 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id lB8JBcHI089568
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 8 Dec 2007 19:11:38 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id lB8JBcqH089567;
	Sat, 8 Dec 2007 19:11:38 GMT
	(envelope-from nobody)
Message-Id: <200712081911.lB8JBcqH089567@www.freebsd.org>
Date: Sat, 8 Dec 2007 19:11:38 GMT
From: Pasi Parviainen <pasi.parviainen@iki.fi>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [acpi][patch] Incorrectly determined device count in thermal zone monitoring thread.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         118497
>Category:       kern
>Synopsis:       [acpi] [patch] Incorrectly determined device count in thermal zone monitoring thread.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jhb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 08 19:20:01 UTC 2007
>Closed-Date:    Tue Jan 15 20:24:27 UTC 2008
>Last-Modified:  Tue Jan 15 20:24:27 UTC 2008
>Originator:     Pasi Parviainen
>Release:        8.0-CURRENT
>Organization:
>Environment:
FreeBSD localhost 8.0-CURRENT FreeBSD 8.0-CURRENT #10: Fri Nov 30 00:22:44 EET 2007     root@localhost:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
Following was observed on HP 6510b laptop.

For every iteration of main loop in thermal zone monitoring thread (acpi_tz_thread), there is unnecessary memory free and allocation cycle. This is caused by use of devclass_get_maxunit to determine number of devices which is different value than number of devices returned by devclass_get_devices. In observed system these values are 6 and 5 respectively (always).
>How-To-Repeat:

>Fix:
Replace devclass_get_maxunit with devclass_get_count to determine number of devices which corresponds to value returned by devclass_get_devices.

Patch attached with submission follows:

--- sys/dev/acpica/acpi_thermal.c	2007-10-21 02:23:13.000000000 +0300
+++ sys/dev/acpica/acpi_thermal.c	2007-12-08 19:57:37.000000000 +0200
@@ -874,7 +874,7 @@
 
     for (;;) {
 	/* If the number of devices has changed, re-evaluate. */
-	if (devclass_get_maxunit(acpi_tz_devclass) != devcount) {
+	if (devclass_get_count(acpi_tz_devclass) != devcount) {
 	    if (devs != NULL) {
 		free(devs, M_TEMP);
 		free(sc, M_TEMP);


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-acpi 
Responsible-Changed-By: remko 
Responsible-Changed-When: Sat Dec 8 19:21:56 UTC 2007 
Responsible-Changed-Why:  
reassign to acpi team 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118497 
State-Changed-From-To: open->patched 
State-Changed-By: jhb 
State-Changed-When: Mon Dec 31 15:56:10 UTC 2007 
State-Changed-Why:  
Fix committed to HEAD, MFCs pending. 


Responsible-Changed-From-To: freebsd-acpi->jhb 
Responsible-Changed-By: jhb 
Responsible-Changed-When: Mon Dec 31 15:56:10 UTC 2007 
Responsible-Changed-Why:  
Fix committed to HEAD, MFCs pending. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118497 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/118497: commit references a PR
Date: Mon, 31 Dec 2007 15:56:09 +0000 (UTC)

 jhb         2007-12-31 15:56:03 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/dev/acpica       acpi_thermal.c 
   Log:
   Use devclass_get_count() instead of devclass_get_maxunit() to get the
   correct number of acpi_thermalX devices.  Having this wrong caused the
   acpi_thermal thread to realloc the array of devices on each loop iteration.
   
   MFC after:      1 week
   PR:             kern/118497
   Submitted by:   Pasi Parviainen
   
   Revision  Changes    Path
   1.67      +1 -1      src/sys/dev/acpica/acpi_thermal.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: jhb 
State-Changed-When: Tue Jan 15 20:24:14 UTC 2008 
State-Changed-Why:  
Fix MFC'd. 

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