From patchwork Tue Sep 19 02:11:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9958007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 82A7460568 for ; Tue, 19 Sep 2017 02:15:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DB9C28E40 for ; Tue, 19 Sep 2017 02:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 726FE28E41; Tue, 19 Sep 2017 02:15:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FFE928E4C for ; Tue, 19 Sep 2017 02:15:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1du80d-0000kQ-Ig; Tue, 19 Sep 2017 02:11:35 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1du80b-0000kK-NW for xen-devel@lists.xenproject.org; Tue, 19 Sep 2017 02:11:33 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 63/BD-17770-5DC70C95; Tue, 19 Sep 2017 02:11:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJIsWRWlGSWpSXmKPExsVyMbThsO6VmgO RBk1nhSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxNR+6zFvznqVi67AprA+NS7i5GLg4hgRmM Ep0T37CCOCwCU1kllu2ZwAjiSAhsZJXo+feYpYuRE8iJk5g+7wM7hJ0mce7bfFYIu0Zi3Z2vT CC2kICKxM3tq5ggxv5klDj5diYzSEJYQE/iyNEf7BC2g8TxBVfAhrIJGEi82bEXbJCIgJLEvV WTwQYxC7QySiz9oAliswioSlw6vQ6shlfAR+L7vJ9gc0QF5CRWXm6BigtKnJz5BGgmB1CvpsT 6XfoQY+Qltr+dwzyBUXgWkqpZCFWzkFQtYGRexahRnFpUllqka2Sul1SUmZ5RkpuYmaNraGCm l5taXJyYnpqTmFSsl5yfu4kRGOgMQLCDcfHawEOMkhxMSqK8aysORArxJeWnVGYkFmfEF5Xmp BYfYtTg4BCYcHbudCYplrz8vFQlCV5BYEQJCRalpqdWpGXmAGMRplSCg0dJhPdsNVCat7ggMb c4Mx0idYrRmOPCnUt/mDgO7Ln1h0kIbJKUOO9KkFIBkNKM0jy4QbAUcYlRVkqYlxHoTCGegtS i3MwSVPlXjOIcjErCvNogU3gy80rg9r0COoUJ6JSWHXtATilJREhJNTAa239O13pvc9/P/ZRs R9j6CS/vmHL0qd7a/kf12O1O1d/rp37qyGibqTCnq+iZe/qvVefWTrQ4fOzWifJ7iy1em+lsj s3QllGL41y1Vkdz1Zf3m4t187gLC5ZaJ3P+0Hz8ynf1iyKPZpb/2uGWZvIPjeWZkgSfTTaI9d 782yFdhim0omtxxGclluKMREMt5qLiRAB/ZwaEDAMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1505787092!94184929!1 X-Originating-IP: [209.85.128.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29166 invoked from network); 19 Sep 2017 02:11:32 -0000 Received: from mail-wr0-f195.google.com (HELO mail-wr0-f195.google.com) (209.85.128.195) by server-10.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 19 Sep 2017 02:11:32 -0000 Received: by mail-wr0-f195.google.com with SMTP id g50so1355960wra.3 for ; Mon, 18 Sep 2017 19:11:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:user-agent:mime-version :content-transfer-encoding; bh=MPqGN1+mnAjCA9n5Nws4MRuGYnTv2RvqOPZWOZQnybc=; b=FdJv9tTr8mn1MexVEr3A4ZJr3AADk0rEds1uKj1stic/VjWuWTGi3KFYLY0+cA0/wh HfRPfXCfe2DV/1j/HheFqUb+nmwyfqn1+9OGWa/XGT4NIc5azhxbvWhPC6MRvlmT0i1m YrJQ06XDlZMj6ZIg1jRZS8EVh2YuLrUJMvC9Fz8ntqJjNGrElK34jtrm+isxe63eQqGp 3UW5kivUM4udPSQICbtcfelJAVqY8g5vbWIc0l4dUY6qE+Muqx3znp2hPLsf8ifPMQqr N/oq2CWoQtv8akhr7OuxrZnKWaBRuvJ7pHL9kLqImhsuAALNUs2+nGvDPdU+zWhFuORO UYpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :user-agent:mime-version:content-transfer-encoding; bh=MPqGN1+mnAjCA9n5Nws4MRuGYnTv2RvqOPZWOZQnybc=; b=kDZR4Vk9WOr+9zSIu1me07GJcpJmaGrQgLoAXWLar34Nabl1iFuQcDLP8+pJpbkMj0 PmHCFTMvPGCoks3ZCsWjLUPKXcT4Oofh6rRsXWcIzH5jIhDyywD+0AwfriLpW7oTjoSg oN6tPonGbvpA/b3DSmH4hH/v4Tl6Cp01xVmve8UZqGWnc+Jwhsl+iyWYBCZJrPigRfTt AwEdZ7jhiCN7UttMSCw9wQ2rx1EJWpm3GfmmrG5SVMXFzPkaoQK9BP2RzdaMMpuKCFA6 Fu57RKRly7S3Kw5khLhD/EdqRB5MEty09TbYdtsgeg86HH2T+u2+hW+jVJbym0cugNRq H9Tw== X-Gm-Message-State: AHPjjUgZol0vG/wO57xDdjEb82MyQghhD/ZRdbAo/CGhGEKGnCr1XBJA 8wz/BtKI3kaezw== X-Google-Smtp-Source: ADKCNb5f74xrUdP/ZWdGsAJqDKKnQSsusyDbElh5vBEeKNipqE8kZoBvhcYUIARe62egdv7juscm1A== X-Received: by 10.223.160.221 with SMTP id n29mr29638365wrn.214.1505787091845; Mon, 18 Sep 2017 19:11:31 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.52]) by smtp.gmail.com with ESMTPSA id j73sm1143508wmf.15.2017.09.18.19.11.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Sep 2017 19:11:30 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Tue, 19 Sep 2017 04:11:28 +0200 Message-ID: <150578708843.32006.17195420852157192880.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Wei Liu , osstest service owner Subject: [Xen-devel] [PATCH] xen: credit2: fix spinlock irq-safety violation X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In commit ad4b3e1e9df34 ("xen: credit2: implement utilization cap") xfree() was being called (for deallocating the budget replenishment timer, during domain destruction) inside an IRQ disabled critical section. That must not happen, as it uses the mem-pool's lock, which needs to be taken with IRQ enabled. And, in fact, we crash (in debug builds): (XEN) **************************************** (XEN) Panic on CPU 0: (XEN) Xen BUG at spinlock.c:47 (XEN) **************************************** Let's, therefore, kill and deallocate the timer outside of the critical sections, when IRQs are enabled. Signed-off-by: Dario Faggioli Reviewed-by: Wei Liu Reviewed-by: Roger Pau Monné --- Cc: osstest service owner Cc: George Dunlap Cc: Wei Liu --- This was spotted by OSSTest's flight 113562: http://logs.test-lab.xenproject.org/osstest/logs/113562/ http://logs.test-lab.xenproject.org/osstest/logs/113562/test-amd64-amd64-xl-credit2/serial-godello0.log --- xen/common/sched_credit2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 32234ac..7a550db 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -2923,13 +2923,13 @@ csched2_free_domdata(const struct scheduler *ops, void *data) write_lock_irqsave(&prv->lock, flags); - kill_timer(sdom->repl_timer); - xfree(sdom->repl_timer); - list_del_init(&sdom->sdom_elem); write_unlock_irqrestore(&prv->lock, flags); + kill_timer(sdom->repl_timer); + xfree(sdom->repl_timer); + xfree(data); }