mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH 3/6] workqueue: Don't assume that the callback has interrupts disabled
Date: Thu, 13 Jun 2019 16:50:24 +0200	[thread overview]
Message-ID: <20190613145027.27753-4-bigeasy@linutronix.de> (raw)
In-Reply-To: <20190613145027.27753-1-bigeasy@linutronix.de>

Due to the TIMER_IRQSAFE flag, the timer callback is invoked with
disabled interrupts. On -RT the callback is invoked in softirq context
with enabled interrupts. Since the interrupts are threaded, there are
are no in_irq() users. The local_bh_disable() around the threaded
handler ensures that there is either a timer or a threaded handler
active on the CPU.

Disable interrupts before __queue_work() is invoked from the timer
callback.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 kernel/workqueue.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 601d61150b65d..a3c2959e5c4f0 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1611,9 +1611,11 @@ EXPORT_SYMBOL_GPL(queue_work_node);
 void delayed_work_timer_fn(struct timer_list *t)
 {
 	struct delayed_work *dwork = from_timer(dwork, t, timer);
+	unsigned long flags;
 
-	/* should have been called from irqsafe timer with irq already off */
+	local_irq_save(flags);
 	__queue_work(dwork->cpu, dwork->wq, &dwork->work);
+	local_irq_restore(flags);
 }
 EXPORT_SYMBOL(delayed_work_timer_fn);
 
-- 
2.20.1


  parent reply	other threads:[~2019-06-13 15:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 14:50 [PATCH 0/6] workqueue: convert to raw_spinlock_t Sebastian Andrzej Siewior
2019-06-13 14:50 ` [PATCH 1/6] workqueue: Make alloc/apply/free_workqueue_attrs() static Sebastian Andrzej Siewior
2019-06-13 14:50 ` [PATCH 2/6] workqueue: Remove GPF argument from alloc_workqueue_attrs() Sebastian Andrzej Siewior
2019-06-13 14:50 ` Sebastian Andrzej Siewior [this message]
2019-06-13 14:50 ` [PATCH 4/6] sched/swait: Add swait_event_lock_irq() Sebastian Andrzej Siewior
2019-06-13 14:50 ` [PATCH 5/6] workqueue: Use swait for wq_manager_wait Sebastian Andrzej Siewior
2019-06-13 14:50 ` [PATCH 6/6] workqueue: Convert the locks to raw type Sebastian Andrzej Siewior
2019-06-26  7:17 ` [PATCH 0/6] workqueue: convert to raw_spinlock_t Sebastian Andrzej Siewior
2019-06-26 13:49   ` Tejun Heo
2019-06-26 13:53     ` Thomas Gleixner
2019-06-26 14:01       ` Tejun Heo
2019-06-26 14:12         ` Thomas Gleixner
2019-06-26 14:18           ` Tejun Heo
2019-06-26 14:09     ` 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=20190613145027.27753-4-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.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

all inboxes | Powered by JetHome®