linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Cartwright <julia@ni.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-rt-users@vger.kernel.org" <linux-rt-users@vger.kernel.org>,
	Steffen Trumtrar <s.trumtrar@pengutronix.de>,
	Tim Sander <tim@krieglstein.org>,
	Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH RT 2/2] watchdog, rt: prevent deferral of watchdogd wakeup
Date: Fri, 28 Sep 2018 21:03:51 +0000	[thread overview]
Message-ID: <0e02d8327aeca344096c246713033887bc490dd7.1538089180.git.julia@ni.com> (raw)
In-Reply-To: <cover.1538089179.git.julia@ni.com>

When PREEMPT_RT_FULL is enabled, all hrtimer expiry functions are
deferred for execution into the context of ktimersoftd unless otherwise
annotated.

Deferring the expiry of the hrtimer used by the watchdog core, however,
is a waste, as the callback does nothing but queue a kthread work item
and wakeup watchdogd.

It's worst then that, too: the deferral through ktimersoftd also means
that for correct behavior a user must adjust the scheduling parameters
of both watchdogd _and_ ktimersoftd, which is unnecessary and has other
side effects (like causing unrelated expiry functions to execute at
potentially elevated priority).

Instead, mark the hrtimer used by the watchdog core as being _HARD to
allow it's execution directly from hardirq context.  The work done in
this expiry function is well-bounded and minimal.

A user still must adjust the scheduling parameters of the watchdogd
to be correct w.r.t. their application needs.

Cc: Guenter Roeck <linux@roeck-us.net>
Reported-and-tested-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Reported-by: Tim Sander <tim@krieglstein.org>
Signed-off-by: Julia Cartwright <julia@ni.com>
---
 drivers/watchdog/watchdog_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index ffbdc4642ea5..9c2b3e5cebdc 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -945,7 +945,7 @@ static int watchdog_cdev_register(struct watchdog_device *wdd, dev_t devno)
 		return -ENODEV;
 
 	kthread_init_work(&wd_data->work, watchdog_ping_work);
-	hrtimer_init(&wd_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+	hrtimer_init(&wd_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
 	wd_data->timer.function = watchdog_timer_expired;
 
 	if (wdd->id == 0) {
-- 
2.18.0


  parent reply	other threads:[~2018-09-28 21:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <73in2vl5mj.fsf@pengutronix.de>
2018-09-28 21:03 ` [PATCH 0/2] Fix watchdogd wakeup deferral on RT Julia Cartwright
2018-09-28 21:03   ` [PATCH 1/2] kthread: convert worker lock to raw spinlock Julia Cartwright
2018-10-05 16:46     ` Sebastian Andrzej Siewior
2018-10-05 18:10     ` Andrea Parri
2018-10-09 10:56       ` Sebastian Andrzej Siewior
2018-09-28 21:03   ` Julia Cartwright [this message]
2018-09-28 22:38     ` [PATCH RT 2/2] watchdog, rt: prevent deferral of watchdogd wakeup kbuild test robot
2018-09-29  6:38       ` Thomas Gleixner
2018-09-29 22:13         ` Sebastian Andrzej Siewior
2018-09-30  1:41           ` [kbuild-all] " Li, Philip
2018-09-28 23:20     ` kbuild test robot
2018-09-30 14:00     ` Guenter Roeck
2018-10-05 16:52     ` 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=0e02d8327aeca344096c246713033887bc490dd7.1538089180.git.julia@ni.com \
    --to=julia@ni.com \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=s.trumtrar@pengutronix.de \
    --cc=tglx@linutronix.de \
    --cc=tim@krieglstein.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).