Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3398392ybp; Sun, 6 Oct 2019 11:03:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPyvhFtu5cPchC6uNHBExawcpp3DVs5c+f9kcHoU7T9VFiMfIQmqoxNaQmaopKCynDhyed X-Received: by 2002:a05:6402:1f4:: with SMTP id i20mr25582663edy.137.1570385020271; Sun, 06 Oct 2019 11:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570385020; cv=none; d=google.com; s=arc-20160816; b=lU0EJV6wTq6SO2iIWDLYhcntmW5GVi1RqZqO0CEjbeetvXz7p6iFYzjLW42wa8KWYt vafScPFCfrZ5uHCGd9utti/OJQ7G2FLrsAhZqK5TNSNKSMmYGr/yuzOR+OMQJOzlnL1m Q0RpzKwHvLO8fi9u1octqCdxJURGlCDfOGYoRmqgVtpiQVsRaPmDG+oy91ykG4ZS0kmh irm8Xa9sQiqp2uBuXq93iQ8JJBLvonmS6PdKoEc6VNm2Ophq39GL5aL5UFGxplnxiWgm hEqCU5kuWQO1YjvdyIRiB+g9G4yz/AgV+WD0n5SEvshyfFMl3DEWvKN+9RRIfonquVXS f+eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2pEhie/9LcBiIGN+6v8REa7TIDGTpzmYAoWqhtNzGNQ=; b=vFbg1z9mfwFaM/iyEWtAiy8AuQeRukoda406f4xePOlfP6MHUvfWisQDFKkLUlvRgo e+Ea4hjsmTVCk2oDEw7nSnqAu655zgL4OkgDHsU941VFo3HcGFvIufmzpQshzdl1G+FO /EXXUzv1bIow3OtGO5FJcr3WfXR668x73hf9kgMGmbGPoDfv2n0cpKwa6GGs+SXpm4VY s5X5HsLA7rS/DwwoqVFsYYir5EzYiwNsumAOa3KaRpjphAaR0aV/VSkHdM0zV5u3msQV DVR184zrHD8HY2o3WQTRItlTs2N1K1qF1BEBQNC6v2ZmgTxlk8bIqK6XEc+aDcOtiCXo XuSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FWS2OIMt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y13si7754771ede.219.2019.10.06.11.03.16; Sun, 06 Oct 2019 11:03:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FWS2OIMt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727736AbfJFSAx (ORCPT + 99 others); Sun, 6 Oct 2019 14:00:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:53940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728696AbfJFR2S (ORCPT ); Sun, 6 Oct 2019 13:28:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1BA352087E; Sun, 6 Oct 2019 17:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570382897; bh=j20aodNB6H+UN3uqmUZyleqFIstFjxvzp7Enj8fdVcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FWS2OIMtumV6xJMmsryLfKStnXr71+x0rH4Av5NnD9WY/Wqwm7kXwRXZq6TSq/i9u sVIA19W17jkm8+wEvHQXh89LLmG7/t79OlEltfiOciAHh22sE1Au9v0gDEhNdksdaW aJh8UzoPYjxktAhPEAr1KoeI7iz/WKryl7HKx6bY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Corey Minyard , Sasha Levin Subject: [PATCH 4.19 012/106] ipmi_si: Only schedule continuously in the thread in maintenance mode Date: Sun, 6 Oct 2019 19:20:18 +0200 Message-Id: <20191006171130.485953894@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corey Minyard [ Upstream commit 340ff31ab00bca5c15915e70ad9ada3030c98cf8 ] ipmi_thread() uses back-to-back schedule() to poll for command completion which, on some machines, can push up CPU consumption and heavily tax the scheduler locks leading to noticeable overall performance degradation. This was originally added so firmware updates through IPMI would complete in a timely manner. But we can't kill the scheduler locks for that one use case. Instead, only run schedule() continuously in maintenance mode, where firmware updates should run. Signed-off-by: Corey Minyard Signed-off-by: Sasha Levin --- drivers/char/ipmi/ipmi_si_intf.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 75e5006f395a5..006d765256782 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -221,6 +221,9 @@ struct smi_info { */ bool irq_enable_broken; + /* Is the driver in maintenance mode? */ + bool in_maintenance_mode; + /* * Did we get an attention that we did not handle? */ @@ -1013,11 +1016,20 @@ static int ipmi_thread(void *data) spin_unlock_irqrestore(&(smi_info->si_lock), flags); busy_wait = ipmi_thread_busy_wait(smi_result, smi_info, &busy_until); - if (smi_result == SI_SM_CALL_WITHOUT_DELAY) + if (smi_result == SI_SM_CALL_WITHOUT_DELAY) { ; /* do nothing */ - else if (smi_result == SI_SM_CALL_WITH_DELAY && busy_wait) - schedule(); - else if (smi_result == SI_SM_IDLE) { + } else if (smi_result == SI_SM_CALL_WITH_DELAY && busy_wait) { + /* + * In maintenance mode we run as fast as + * possible to allow firmware updates to + * complete as fast as possible, but normally + * don't bang on the scheduler. + */ + if (smi_info->in_maintenance_mode) + schedule(); + else + usleep_range(100, 200); + } else if (smi_result == SI_SM_IDLE) { if (atomic_read(&smi_info->need_watch)) { schedule_timeout_interruptible(100); } else { @@ -1025,8 +1037,9 @@ static int ipmi_thread(void *data) __set_current_state(TASK_INTERRUPTIBLE); schedule(); } - } else + } else { schedule_timeout_interruptible(1); + } } return 0; } @@ -1201,6 +1214,7 @@ static void set_maintenance_mode(void *send_info, bool enable) if (!enable) atomic_set(&smi_info->req_events, 0); + smi_info->in_maintenance_mode = enable; } static void shutdown_smi(void *send_info); -- 2.20.1