From owner-freebsd-stable@FreeBSD.ORG Sun Mar 24 03:17:41 2013 Return-Path: Delivered-To: stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B551B1D9 for ; Sun, 24 Mar 2013 03:17:41 +0000 (UTC) (envelope-from eric@vangyzen.net) Received: from smtp.vangyzen.net (hotblack.vangyzen.net [199.48.133.146]) by mx1.freebsd.org (Postfix) with ESMTP id 9B9FF975 for ; Sun, 24 Mar 2013 03:17:41 +0000 (UTC) Received: from latitude.home.vangyzen.net (173-17-250-12.client.mchsi.com [173.17.250.12]) by smtp.vangyzen.net (Postfix) with ESMTP id 2843D56400 for ; Sat, 23 Mar 2013 22:11:21 -0500 (CDT) Message-ID: <514E6ED8.9040305@vangyzen.net> Date: Sat, 23 Mar 2013 22:11:20 -0500 From: Eric van Gyzen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: stable@FreeBSD.org Subject: [patch] IPMI KCS can drop the lock while servicing a request Content-Type: multipart/mixed; boundary="------------090905000705080902010300" X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 03:17:41 -0000 This is a multi-part message in MIME format. --------------090905000705080902010300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit At work, we discovered that our application's IPMI thread would often use a lot of CPU time. The KCS thread uses DELAY to wait for the BMC, so it can run without sleeping for a "long" time with a slow BMC. It also holds the ipmi_softc.ipmi_lock during this time. When using adaptive mutexes, an application thread that wants to operate on the ipmi_pending_requests list will also spin during this same time. We see no reason that the KCS thread needs to hold the lock while servicing a request. We've been running with the attached patch for a few months, with no ill effects. Eric --------------090905000705080902010300 Content-Type: text/x-patch; name="ipmi_kcs.c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ipmi_kcs.c.patch" diff --git a/sys/dev/ipmi/ipmi_kcs.c b/sys/dev/ipmi/ipmi_kcs.c index 1ca3298..868570d 100644 --- a/sys/dev/ipmi/ipmi_kcs.c +++ b/sys/dev/ipmi/ipmi_kcs.c @@ -456,9 +456,11 @@ kcs_loop(void *arg) IPMI_LOCK(sc); while ((req = ipmi_dequeue_request(sc)) != NULL) { + IPMI_UNLOCK(sc); ok = 0; for (i = 0; i < 3 && !ok; i++) ok = kcs_polled_request(sc, req); + IPMI_LOCK(sc); if (ok) req->ir_error = 0; else --------------090905000705080902010300--