From patchwork Fri Sep 20 21:53:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 174171 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3035147ill; Fri, 20 Sep 2019 14:56:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsA+HZ+bAkx3y1jKcHyOICCYYp2xssNSegdt6l37HTnNksUWe4DFOEzp7tFP3IIv5fwrQY X-Received: by 2002:a17:906:1f03:: with SMTP id w3mr20843568ejj.31.1569016594227; Fri, 20 Sep 2019 14:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569016594; cv=none; d=google.com; s=arc-20160816; b=YWZZsnl3Vi7hGetaAIx2gcnJgeSzwuwL7lce3h9Bfl5gWEb/ETnDcv2hSrz8gs+Htz CZOKCv6y0AC6HhldmDfQxY6DFA9R1nHmxDa/W+lXB/nBNCympu0+eH11e3QpuKcs2xO+ z/BhRn1WAF8ZLOo9GdQjQTp4xJVzjRUV42l596/dMxjFerxuu7MZGmjt/oBholVUB+5e DOnhie5TbEMVMyCnW6snVoBQ4IzS5HpKXfzGAfmJD0i5HrV0b2ok8V5kgKuIyg2PmAGC eqnZIGxZCkM8MkvirbENung+Y1GJ3fPWgYjhhXpu6EmNQi/lyGTEibB+xE/gDx038Oa3 bVJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id; bh=oQOLzdgTPr/rpJoCLqv+QVOLRBNA+d7PfvLthpcUWXo=; b=wewi28p2pWF6NELz9iKqQGfx7+TWuLca1P0VFZB+d5f+jh4DLrog/bmKvRl0rN6RK7 lBYbRcTkOrprVXg6z6C2bPM0DDlwU3ShUCw5g5Ssh4h/aWVPoPch7h0+mz1CDAfsBPBW zgnF91CcQdUjUDY49eNWXR1vuHE0PS/AtqImLiQYGC+SSdWPTP6eMTIqHNuPWXHON/z0 hbrrAetlggFQC8+De370EY8b6yyXNihM2uaacKr5yBLUmLRkYUwZWgK9A6D1WoeBlL1M 6bTz3esrWpUdGDWr4Gj/UjjFjoxb5vXGCeHbawHb2L/siPUET/GG2eidSX9Z2k6EtcAA 3leg== ARC-Authentication-Results: i=1; mx.google.com; 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 d9si2173854edb.371.2019.09.20.14.56.34; Fri, 20 Sep 2019 14:56:34 -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; 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 S1730555AbfITV4a (ORCPT + 26 others); Fri, 20 Sep 2019 17:56:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:47046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730462AbfITV4Y (ORCPT ); Fri, 20 Sep 2019 17:56:24 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 E3C282173E; Fri, 20 Sep 2019 21:56:22 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.92) (envelope-from ) id 1iBQt4-0005Ir-1G; Fri, 20 Sep 2019 17:56:22 -0400 Message-Id: <20190920215621.921710766@goodmis.org> User-Agent: quilt/0.65 Date: Fri, 20 Sep 2019 17:53:15 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-rt-users Cc: Thomas Gleixner , Carsten Emde , Sebastian Andrzej Siewior , John Kacur , Paul Gortmaker , Julia Cartwright , Daniel Wagner , tom.zanussi@linux.intel.com, Daniel Wagner Subject: [RFC][PATCH RT 4/7] thermal: Defer thermal wakups to threads References: <20190920215311.165260719@goodmis.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Wagner [ Upstream commit ad2408dc248fe58536eef5b2b5734d8f9d3a280b ] On RT the spin lock in pkg_temp_thermal_platfrom_thermal_notify will call schedule while we run in irq context. [] dump_stack+0x4e/0x8f [] __schedule_bug+0xa6/0xb4 [] __schedule+0x5b4/0x700 [] schedule+0x2a/0x90 [] rt_spin_lock_slowlock+0xe5/0x2d0 [] rt_spin_lock+0x25/0x30 [] pkg_temp_thermal_platform_thermal_notify+0x45/0x134 [x86_pkg_temp_thermal] [] ? therm_throt_process+0x1b/0x160 [] intel_thermal_interrupt+0x211/0x250 [] smp_thermal_interrupt+0x21/0x40 [] thermal_interrupt+0x6d/0x80 Let's defer the work to a kthread. Signed-off-by: Daniel Wagner Signed-off-by: Steven Rostedt (VMware) [bigeasy: reoder init/denit position. TODO: flush swork on exit] Signed-off-by: Sebastian Andrzej Siewior --- drivers/thermal/x86_pkg_temp_thermal.c | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c index 1ef937d799e4..82f21fd4afb0 100644 --- a/drivers/thermal/x86_pkg_temp_thermal.c +++ b/drivers/thermal/x86_pkg_temp_thermal.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -329,7 +330,7 @@ static void pkg_thermal_schedule_work(int cpu, struct delayed_work *work) schedule_delayed_work_on(cpu, work, ms); } -static int pkg_thermal_notify(u64 msr_val) +static void pkg_thermal_notify_work(struct kthread_work *work) { int cpu = smp_processor_id(); struct pkg_device *pkgdev; @@ -348,8 +349,32 @@ static int pkg_thermal_notify(u64 msr_val) } spin_unlock_irqrestore(&pkg_temp_lock, flags); +} + +#ifdef CONFIG_PREEMPT_RT_FULL +static DEFINE_KTHREAD_WORK(notify_work, pkg_thermal_notify_work); + +static int pkg_thermal_notify(u64 msr_val) +{ + kthread_schedule_work(¬ify_work); + return 0; +} + +static void pkg_thermal_notify_flush(void) +{ + kthread_flush_work(¬ify_work); +} + +#else /* !CONFIG_PREEMPT_RT_FULL */ + +static void pkg_thermal_notify_flush(void) { } + +static int pkg_thermal_notify(u64 msr_val) +{ + pkg_thermal_notify_work(NULL); return 0; } +#endif /* CONFIG_PREEMPT_RT_FULL */ static int pkg_temp_thermal_device_add(unsigned int cpu) { @@ -548,6 +573,7 @@ static void __exit pkg_temp_thermal_exit(void) platform_thermal_package_rate_control = NULL; cpuhp_remove_state(pkg_thermal_hp_state); + pkg_thermal_notify_flush(); debugfs_remove_recursive(debugfs); kfree(packages); }