Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3391286ybp; Sun, 6 Oct 2019 10:54:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzypItMvVAnQW196pEZimGtvl+Qqnm8iq4gzp1l0U05wnrDV3kKhsg6vL/CXS1i4LEveK8A X-Received: by 2002:a50:ed17:: with SMTP id j23mr25260963eds.248.1570384483035; Sun, 06 Oct 2019 10:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384483; cv=none; d=google.com; s=arc-20160816; b=I699uvwli41w7ZSUCfcxZHTDNXFAIaOipSyocxupOOi4CMO5w44oAJxYQl86D376Iv fzgHmcHuBDgDpwWnSEho/8ATlkCv6Xy4/lIjyM4656R3YGa6c/csFkyFn9w245RqWC4O jvMiTS10DOdd9u3Eyrn4QZEEQTsnTB548XMtv9VrqoI5j1aXKLLA95z6SCImdbj2zRMn psGzZa/UIjTzmAM1voResmGXQZNa7QAYM8kxUUSKdKLJZSNtOqTxnMVSo9PFyXUzzKmZ HOhfnDP8wBVluT6h77gPEmlTW0WsiBaZxfC8puoY+t1MtEbQSEda1G1Y57g53V2pPTHL +cYA== 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=PwOdCinEvncXPv5Mv60GoqUq38DbZPXnrmzcepk0OpA=; b=dObxOqgk02APBafMiTabGa+pnhXH/rI0GLiewmpNEaILYYVNlGhAnpqJ4u2fgtpqg4 t1WYsuEIWdmxj1nENdSuthhnzriRWoH8HshUw1BogEweryl8TTWcyd02N6Zki8oXCrVK HMpqpfwapDZJnGMutQWZHi2byLK96iIFiOYjDvf4gFrzb8we/SmsW1VWKvMNs0jwmwAv 61bqUMgu9Wll5pn9i2n/sfmO5a9MrZudPZ/RAOUBTDVWeyjJ/rd3rKAsDz6bjGlQLboM IznF7TN2tUwKt7AZAInSTTfpWAwVLX9fvSFPiGXSq6S+LKUjYrBftkW8pOECk2Qlb19B zhmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=itIZO8Sn; 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 w18si7299078eda.445.2019.10.06.10.54.19; Sun, 06 Oct 2019 10:54:43 -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=itIZO8Sn; 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 S1730297AbfJFRge (ORCPT + 99 others); Sun, 6 Oct 2019 13:36:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:35318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728368AbfJFRga (ORCPT ); Sun, 6 Oct 2019 13:36:30 -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 DD0CB20862; Sun, 6 Oct 2019 17:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383389; bh=bvp7U6owBiuRrjazjNW9vjE9/ElqnQAHUf39IoJDf2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=itIZO8SnKSIilxUkxnj9iluaKU6pcAvqgSvETz019x2h6OGAx7JaX3JCTwPZAcHJr gRKNoW5yepEBE5cp6qiSmPv3i9LTRGcA25xalNl9oynurRzrHV6HcKnyB6ihRuR2NU p8W/Z7zzQj174P38vKefKN5lgy9WhA2MN4XdFnIs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Corey Minyard , Sasha Levin Subject: [PATCH 5.2 042/137] ipmi_si: Only schedule continuously in the thread in maintenance mode Date: Sun, 6 Oct 2019 19:20:26 +0200 Message-Id: <20191006171212.486377295@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171209.403038733@linuxfoundation.org> References: <20191006171209.403038733@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 f124a2d2bb9f5..92a89c8290aa4 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? */ @@ -1007,11 +1010,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 { @@ -1019,8 +1031,9 @@ static int ipmi_thread(void *data) __set_current_state(TASK_INTERRUPTIBLE); schedule(); } - } else + } else { schedule_timeout_interruptible(1); + } } return 0; } @@ -1198,6 +1211,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