linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joakim Hernberg <jhernberg@alchemy.lu>
To: Daniel Wagner <wagi@monom.org>, John Kacur <jkacur@redhat.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	linux-rt-users <linux-rt-users@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	rostedt@goodmis.org
Subject: Re: [ANNOUNCE] 3.18.7-rt1
Date: Thu, 19 Feb 2015 10:36:01 +0100	[thread overview]
Message-ID: <20150219103601.7e40d0af@tor.valhalla.alchemy.lu> (raw)
In-Reply-To: <54E2FDD8.8090008@monom.org>

On Tue, 17 Feb 2015 09:37:44 +0100
Daniel Wagner <wagi@monom.org> wrote:

> I needed the patch below to get it running stable under load on my
> shiny box.

FWIW, this patch makes 3.18-rt survive thermal events on my laptop.

> From c517743659575932d7b7c94a08276d0cee8a2fdd Mon Sep 17 00:00:00 2001
> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
> Date: Fri, 11 Jul 2014 15:26:13 +0200
> Subject: [PATCH] thermal: Defer thermal wakups to threads
> 
> On RT the spin lock in pkg_temp_thermal_platfrom_thermal_notify will
> call schedule while we run in irq context.
> 
> [<ffffffff816850ac>] dump_stack+0x4e/0x8f
> [<ffffffff81680f7d>] __schedule_bug+0xa6/0xb4
> [<ffffffff816896b4>] __schedule+0x5b4/0x700
> [<ffffffff8168982a>] schedule+0x2a/0x90
> [<ffffffff8168a8b5>] rt_spin_lock_slowlock+0xe5/0x2d0
> [<ffffffff8168afd5>] rt_spin_lock+0x25/0x30
> [<ffffffffa03a7b75>]
> pkg_temp_thermal_platform_thermal_notify+0x45/0x134
> [x86_pkg_temp_thermal] [<ffffffff8103d4db>] ?
> therm_throt_process+0x1b/0x160 [<ffffffff8103d831>]
> intel_thermal_interrupt+0x211/0x250 [<ffffffff8103d8c1>]
> smp_thermal_interrupt+0x21/0x40 [<ffffffff8169415d>]
> thermal_interrupt+0x6d/0x80
> 
> Let's defer the work to a kthread.
> 
> Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  drivers/thermal/x86_pkg_temp_thermal.c | 49
> ++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+),
> 2 deletions(-)
> 
> diff --git a/drivers/thermal/x86_pkg_temp_thermal.c
> b/drivers/thermal/x86_pkg_temp_thermal.c index 9ea3d9d..001ba02 100644
> --- a/drivers/thermal/x86_pkg_temp_thermal.c
> +++ b/drivers/thermal/x86_pkg_temp_thermal.c
> @@ -29,6 +29,7 @@
>  #include <linux/pm.h>
>  #include <linux/thermal.h>
>  #include <linux/debugfs.h>
> +#include <linux/work-simple.h>
>  #include <asm/cpu_device_id.h>
>  #include <asm/mce.h>
>  
> @@ -352,7 +353,7 @@ static void
> pkg_temp_thermal_threshold_work_fn(struct work_struct *work) }
>  }
>  
> -static int pkg_temp_thermal_platform_thermal_notify(__u64 msr_val)
> +static void platform_thermal_notify_work(struct swork_event *event)
>  {
>  	unsigned long flags;
>  	int cpu = smp_processor_id();
> @@ -369,7 +370,7 @@ static int
> pkg_temp_thermal_platform_thermal_notify(__u64 msr_val)
> pkg_work_scheduled[phy_id]) { disable_pkg_thres_interrupt();
>  		spin_unlock_irqrestore(&pkg_work_lock, flags);
> -		return -EINVAL;
> +		return;
>  	}
>  	pkg_work_scheduled[phy_id] = 1;
>  	spin_unlock_irqrestore(&pkg_work_lock, flags);
> @@ -378,9 +379,48 @@ static int
> pkg_temp_thermal_platform_thermal_notify(__u64 msr_val)
> schedule_delayed_work_on(cpu,
> &per_cpu(pkg_temp_thermal_threshold_work, cpu),
> msecs_to_jiffies(notify_delay_ms)); +}
> +
> +#ifdef CONFIG_PREEMPT_RT_FULL
> +static struct swork_event notify_work;
> +
> +static int thermal_notify_work_init(void)
> +{
> +	int err;
> +
> +	err = swork_get();
> +	if (!err)
> +		return err;
> +
> +	INIT_SWORK(&notify_work, platform_thermal_notify_work);
> +	return 0;
> +}
> +
> +static void thermal_notify_work_cleanup(void)
> +{
> +	swork_put();
> +}
> +
> +static int pkg_temp_thermal_platform_thermal_notify(__u64 msr_val)
> +{
> +	swork_queue(&notify_work);
>  	return 0;
>  }
>  
> +#else  /* !CONFIG_PREEMPT_RT_FULL */
> +
> +static int thermal_notify_work_init(void) { return 0; }
> +
> +static int thermal_notify_work_cleanup(void) {  }
> +
> +static int pkg_temp_thermal_platform_thermal_notify(__u64 msr_val)
> +{
> +	platform_thermal_notify_work(NULL);
> +
> +	return 0;
> +}
> +#endif /* CONFIG_PREEMPT_RT_FULL */
> +
>  static int find_siblings_cpu(int cpu)
>  {
>  	int i;
> @@ -594,6 +634,10 @@ static int __init pkg_temp_thermal_init(void)
>  	for_each_online_cpu(i)
>  		if (get_core_online(i))
>  			goto err_ret;
> +
> +	if (!thermal_notify_work_init())
> +		goto err_ret;
> +
>  	__register_hotcpu_notifier(&pkg_temp_thermal_notifier);
>  	cpu_notifier_register_done();
>  
> @@ -619,6 +663,7 @@ static void __exit pkg_temp_thermal_exit(void)
>  
>  	cpu_notifier_register_begin();
>  	__unregister_hotcpu_notifier(&pkg_temp_thermal_notifier);
> +	thermal_notify_work_cleanup();
>  	mutex_lock(&phy_dev_list_mutex);
>  	list_for_each_entry_safe(phdev, n, &phy_dev_list, list) {
>  		/* Retore old MSR value for package thermal
> interrupt */



-- 

   Joakim

  reply	other threads:[~2015-02-19  9:52 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-16 11:18 [ANNOUNCE] 3.18.7-rt1 Sebastian Andrzej Siewior
2015-02-16 18:13 ` Sebastian Andrzej Siewior
2015-02-16 20:12 ` Richard Cochran
2015-02-16 20:21   ` Steven Rostedt
2015-02-17  8:37 ` Daniel Wagner
2015-02-19  9:36   ` Joakim Hernberg [this message]
2015-02-25 13:55     ` Sebastian Andrzej Siewior
2015-02-26  8:48       ` Sebastian Andrzej Siewior
2015-02-27  6:40         ` Daniel Wagner
2015-02-27  7:58           ` Sebastian Andrzej Siewior
2015-02-18 11:21 ` [patch-3.18.7-rt1] sched/context-tracking: fix PREEMPT_LAZY explosions Mike Galbraith
2015-02-18 11:27   ` [rfc patch-3.18.7-rt1] rt/nohz_full: Fix can_stop_full_tick() gripe within softirq Mike Galbraith
2015-02-19  4:50     ` Mike Galbraith
2015-02-19  6:30   ` [patch-3.18.7-rt1] sched/context-tracking: fix PREEMPT_LAZY explosions Mike Galbraith
2015-03-09 13:45   ` Sebastian Andrzej Siewior
2015-03-09 14:36     ` Mike Galbraith
2015-03-09 14:45       ` Sebastian Andrzej Siewior
2015-03-10  9:35       ` Mike Galbraith
2015-03-11  6:18         ` Mike Galbraith
2015-03-12  9:38         ` [rfc patch] rt,nohz_full: fix nohz_full for PREEMPT_RT_FULL Mike Galbraith
2015-03-12 15:09           ` Steven Rostedt
2015-03-13  2:13             ` Mike Galbraith
2015-03-13  3:03               ` Steven Rostedt
2015-03-13  4:53           ` [rfc patch v2] " Mike Galbraith
2015-03-16 20:24             ` Sebastian Andrzej Siewior
2015-03-17  1:53               ` Mike Galbraith
2015-03-17  4:45                 ` Mike Galbraith
2015-04-10 14:15             ` Sebastian Andrzej Siewior
2015-04-10 14:24               ` Mike Galbraith
2015-04-10 14:28               ` Mike Galbraith
2015-04-11 13:15               ` Mike Galbraith
2015-04-11 13:36                 ` Mike Galbraith
2015-04-11 14:22                   ` Mike Galbraith
2015-04-13  9:43                   ` Sebastian Andrzej Siewior
2015-04-13  9:41                 ` Sebastian Andrzej Siewior
2015-02-18 14:09 ` [patch-3.18.7-rt1] snd/pcm: fix snd_pcm_stream_lock*() irqs_disabled() splats Mike Galbraith
2015-02-25 14:08   ` Sebastian Andrzej Siewior
2015-02-18 15:05 ` [patch-3.18.7-rt1]sunrpc: make svc_xprt_do_enqueue() use get_cpu_light() Mike Galbraith
2015-02-25 14:14   ` Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150219103601.7e40d0af@tor.valhalla.alchemy.lu \
    --to=jhernberg@alchemy.lu \
    --cc=bigeasy@linutronix.de \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=wagi@monom.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).