All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] softirq: Prevent looping on disabled tasklets
@ 2017-02-12 14:00 ` Chris Wilson
  0 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 14:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: intel-gfx, Chris Wilson, Tvrtko Ursulin, Thomas Gleixner,
	Hannes Reinecke, Jens Axboe, Bjorn Helgaas, Alexander Potapenko,
	Chen Fan, Ingo Molnar, Peter Zijlstra (Intel),
	Sebastian Andrzej Siewior, Johannes Thumshirn, Emese Revfy,
	Sagi Grimberg, Eric Dumazet, Tom Herbert, Ben Hutchings

Disabling a tasklet causes it not to run during tasklet_action, but is
put back onto the runnable tasklet list, and a new softirq raised. As
the softirq is raised from within __do_softirq() this causing
__do_softirq() to loop constantly until its timeslice expires and is
transferred to the ksoftirq thread. ksoftirq then permanently spins,
as on each action, the disabled tasklet keeps reraising the softirq.

Break this vicious cycle by moving the softirq from the action to the
final tasklet_enable().

This behaviour appears to be historic (since the first git import).
However, the looping until timeslice duration (to a max of 2ms) was
first introduced in commit c10d73671ad3 ("softirq: reduce latencies"),
with the restart limit restored in commit 34376a50fb1f ("Fix lockup
related to stop_machine being stuck in __do_softirq.")

Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
---
 include/linux/interrupt.h | 7 +++++--
 kernel/softirq.c          | 2 --
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 53144e78a369..12750f00d00d 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -613,8 +613,11 @@ static inline void tasklet_disable(struct tasklet_struct *t)
 
 static inline void tasklet_enable(struct tasklet_struct *t)
 {
-	smp_mb__before_atomic();
-	atomic_dec(&t->count);
+	if (!atomic_dec_and_test(&t->count))
+		return;
+
+	if (test_bit(TASKLET_STATE_SCHED, &t->state))
+		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);
 }
 
 extern void tasklet_kill(struct tasklet_struct *t);
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 744fa611cae0..5a359eb1a541 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -527,7 +527,6 @@ static __latent_entropy void tasklet_action(struct softirq_action *a)
 		t->next = NULL;
 		*__this_cpu_read(tasklet_vec.tail) = t;
 		__this_cpu_write(tasklet_vec.tail, &(t->next));
-		__raise_softirq_irqoff(TASKLET_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -563,7 +562,6 @@ static __latent_entropy void tasklet_hi_action(struct softirq_action *a)
 		t->next = NULL;
 		*__this_cpu_read(tasklet_hi_vec.tail) = t;
 		__this_cpu_write(tasklet_hi_vec.tail, &(t->next));
-		__raise_softirq_irqoff(HI_SOFTIRQ);
 		local_irq_enable();
 	}
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH] softirq: Prevent looping on disabled tasklets
@ 2017-02-12 14:00 ` Chris Wilson
  0 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 14:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jens Axboe, Hannes Reinecke, Sagi Grimberg,
	Peter Zijlstra (Intel),
	intel-gfx, Chen Fan, Eric Dumazet, Emese Revfy,
	Alexander Potapenko, Johannes Thumshirn, Bjorn Helgaas,
	Ben Hutchings, Thomas Gleixner, Ingo Molnar,
	Sebastian Andrzej Siewior, Tom Herbert

Disabling a tasklet causes it not to run during tasklet_action, but is
put back onto the runnable tasklet list, and a new softirq raised. As
the softirq is raised from within __do_softirq() this causing
__do_softirq() to loop constantly until its timeslice expires and is
transferred to the ksoftirq thread. ksoftirq then permanently spins,
as on each action, the disabled tasklet keeps reraising the softirq.

Break this vicious cycle by moving the softirq from the action to the
final tasklet_enable().

This behaviour appears to be historic (since the first git import).
However, the looping until timeslice duration (to a max of 2ms) was
first introduced in commit c10d73671ad3 ("softirq: reduce latencies"),
with the restart limit restored in commit 34376a50fb1f ("Fix lockup
related to stop_machine being stuck in __do_softirq.")

Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
---
 include/linux/interrupt.h | 7 +++++--
 kernel/softirq.c          | 2 --
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 53144e78a369..12750f00d00d 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -613,8 +613,11 @@ static inline void tasklet_disable(struct tasklet_struct *t)
 
 static inline void tasklet_enable(struct tasklet_struct *t)
 {
-	smp_mb__before_atomic();
-	atomic_dec(&t->count);
+	if (!atomic_dec_and_test(&t->count))
+		return;
+
+	if (test_bit(TASKLET_STATE_SCHED, &t->state))
+		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);
 }
 
 extern void tasklet_kill(struct tasklet_struct *t);
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 744fa611cae0..5a359eb1a541 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -527,7 +527,6 @@ static __latent_entropy void tasklet_action(struct softirq_action *a)
 		t->next = NULL;
 		*__this_cpu_read(tasklet_vec.tail) = t;
 		__this_cpu_write(tasklet_vec.tail, &(t->next));
-		__raise_softirq_irqoff(TASKLET_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -563,7 +562,6 @@ static __latent_entropy void tasklet_hi_action(struct softirq_action *a)
 		t->next = NULL;
 		*__this_cpu_read(tasklet_hi_vec.tail) = t;
 		__this_cpu_write(tasklet_hi_vec.tail, &(t->next));
-		__raise_softirq_irqoff(HI_SOFTIRQ);
 		local_irq_enable();
 	}
 }
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] softirq: Prevent looping on disabled tasklets
  2017-02-12 14:00 ` Chris Wilson
@ 2017-02-12 14:23   ` Chris Wilson
  -1 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 14:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: intel-gfx, Tvrtko Ursulin, Thomas Gleixner, Hannes Reinecke,
	Jens Axboe, Bjorn Helgaas, Alexander Potapenko, Chen Fan,
	Ingo Molnar, Peter Zijlstra (Intel),
	Sebastian Andrzej Siewior, Johannes Thumshirn, Emese Revfy,
	Sagi Grimberg, Eric Dumazet, Tom Herbert, Ben Hutchings

On Sun, Feb 12, 2017 at 02:00:19PM +0000, Chris Wilson wrote:
> Disabling a tasklet causes it not to run during tasklet_action, but is
> put back onto the runnable tasklet list, and a new softirq raised. As
> the softirq is raised from within __do_softirq() this causing
> __do_softirq() to loop constantly until its timeslice expires and is
> transferred to the ksoftirq thread. ksoftirq then permanently spins,
> as on each action, the disabled tasklet keeps reraising the softirq.
> 
> Break this vicious cycle by moving the softirq from the action to the
> final tasklet_enable().
> 
> This behaviour appears to be historic (since the first git import).
> However, the looping until timeslice duration (to a max of 2ms) was
> first introduced in commit c10d73671ad3 ("softirq: reduce latencies"),
> with the restart limit restored in commit 34376a50fb1f ("Fix lockup
> related to stop_machine being stuck in __do_softirq.")
> 
> Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Alexander Potapenko <glider@google.com>
> Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> Cc: Emese Revfy <re.emese@gmail.com>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Tom Herbert <therbert@google.com>
> Cc: Ben Hutchings <bhutchings@solarflare.com>
> ---
>  include/linux/interrupt.h | 7 +++++--
>  kernel/softirq.c          | 2 --
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
> index 53144e78a369..12750f00d00d 100644
> --- a/include/linux/interrupt.h
> +++ b/include/linux/interrupt.h
> @@ -613,8 +613,11 @@ static inline void tasklet_disable(struct tasklet_struct *t)
>  
>  static inline void tasklet_enable(struct tasklet_struct *t)
>  {
> -	smp_mb__before_atomic();
> -	atomic_dec(&t->count);
> +	if (!atomic_dec_and_test(&t->count))
> +		return;
> +
> +	if (test_bit(TASKLET_STATE_SCHED, &t->state))
> +		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);

raise_softirq is not exported, so let's move tasklet_enable()
out-of-line and export that.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] softirq: Prevent looping on disabled tasklets
@ 2017-02-12 14:23   ` Chris Wilson
  0 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 14:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jens Axboe, Hannes Reinecke, Sagi Grimberg,
	Peter Zijlstra (Intel),
	intel-gfx, Chen Fan, Eric Dumazet, Emese Revfy,
	Alexander Potapenko, Johannes Thumshirn, Bjorn Helgaas,
	Ben Hutchings, Thomas Gleixner, Ingo Molnar,
	Sebastian Andrzej Siewior, Tom Herbert

On Sun, Feb 12, 2017 at 02:00:19PM +0000, Chris Wilson wrote:
> Disabling a tasklet causes it not to run during tasklet_action, but is
> put back onto the runnable tasklet list, and a new softirq raised. As
> the softirq is raised from within __do_softirq() this causing
> __do_softirq() to loop constantly until its timeslice expires and is
> transferred to the ksoftirq thread. ksoftirq then permanently spins,
> as on each action, the disabled tasklet keeps reraising the softirq.
> 
> Break this vicious cycle by moving the softirq from the action to the
> final tasklet_enable().
> 
> This behaviour appears to be historic (since the first git import).
> However, the looping until timeslice duration (to a max of 2ms) was
> first introduced in commit c10d73671ad3 ("softirq: reduce latencies"),
> with the restart limit restored in commit 34376a50fb1f ("Fix lockup
> related to stop_machine being stuck in __do_softirq.")
> 
> Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Alexander Potapenko <glider@google.com>
> Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> Cc: Emese Revfy <re.emese@gmail.com>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Tom Herbert <therbert@google.com>
> Cc: Ben Hutchings <bhutchings@solarflare.com>
> ---
>  include/linux/interrupt.h | 7 +++++--
>  kernel/softirq.c          | 2 --
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
> index 53144e78a369..12750f00d00d 100644
> --- a/include/linux/interrupt.h
> +++ b/include/linux/interrupt.h
> @@ -613,8 +613,11 @@ static inline void tasklet_disable(struct tasklet_struct *t)
>  
>  static inline void tasklet_enable(struct tasklet_struct *t)
>  {
> -	smp_mb__before_atomic();
> -	atomic_dec(&t->count);
> +	if (!atomic_dec_and_test(&t->count))
> +		return;
> +
> +	if (test_bit(TASKLET_STATE_SCHED, &t->state))
> +		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);

raise_softirq is not exported, so let's move tasklet_enable()
out-of-line and export that.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2] softirq: Prevent looping on disabled tasklets
  2017-02-12 14:00 ` Chris Wilson
@ 2017-02-12 14:31   ` Chris Wilson
  -1 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 14:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: intel-gfx, Chris Wilson, Tvrtko Ursulin, Thomas Gleixner,
	Hannes Reinecke, Jens Axboe, Bjorn Helgaas, Alexander Potapenko,
	Chen Fan, Ingo Molnar, Peter Zijlstra (Intel),
	Sebastian Andrzej Siewior, Johannes Thumshirn, Emese Revfy,
	Sagi Grimberg, Eric Dumazet, Tom Herbert, Ben Hutchings

Disabling a tasklet causes it not to run during tasklet_action, but is
put back onto the runnable tasklet list, and a new softirq raised. As
the softirq is raised from within __do_softirq() this causing
__do_softirq() to loop constantly until its timeslice expires and is
transferred to the ksoftirq thread. ksoftirq then permanently spins,
as on each action, the disabled tasklet keeps reraising the softirq.

Break this vicious cycle by moving the softirq from the action to the
final tasklet_enable().

This behaviour appears to be historic (since the first git import).
However, the looping until timeslice duration (to a max of 2ms) was
first introduced in commit c10d73671ad3 ("softirq: reduce latencies"),
with the restart limit restored in commit 34376a50fb1f ("Fix lockup
related to stop_machine being stuck in __do_softirq.")

v2: Export tasklet_enable() to work with modules.

Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
---
 include/linux/interrupt.h |  7 +------
 kernel/softirq.c          | 12 ++++++++++--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 53144e78a369..a1fa88e7e509 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -611,12 +611,7 @@ static inline void tasklet_disable(struct tasklet_struct *t)
 	smp_mb();
 }
 
-static inline void tasklet_enable(struct tasklet_struct *t)
-{
-	smp_mb__before_atomic();
-	atomic_dec(&t->count);
-}
-
+extern void tasklet_enable(struct tasklet_struct *t);
 extern void tasklet_kill(struct tasklet_struct *t);
 extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
 extern void tasklet_init(struct tasklet_struct *t,
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 080eb57789c4..ab8d9aeccb46 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -535,7 +535,6 @@ static __latent_entropy void tasklet_action(struct softirq_action *a)
 		t->next = NULL;
 		*__this_cpu_read(tasklet_vec.tail) = t;
 		__this_cpu_write(tasklet_vec.tail, &(t->next));
-		__raise_softirq_irqoff(TASKLET_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -571,7 +570,6 @@ static __latent_entropy void tasklet_hi_action(struct softirq_action *a)
 		t->next = NULL;
 		*__this_cpu_read(tasklet_hi_vec.tail) = t;
 		__this_cpu_write(tasklet_hi_vec.tail, &(t->next));
-		__raise_softirq_irqoff(HI_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -587,6 +585,16 @@ void tasklet_init(struct tasklet_struct *t,
 }
 EXPORT_SYMBOL(tasklet_init);
 
+void tasklet_enable(struct tasklet_struct *t)
+{
+	if (!atomic_dec_and_test(&t->count))
+		return;
+
+	if (test_bit(TASKLET_STATE_SCHED, &t->state))
+		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);
+}
+EXPORT_SYMBOL(tasklet_enable);
+
 void tasklet_kill(struct tasklet_struct *t)
 {
 	if (in_interrupt())
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2] softirq: Prevent looping on disabled tasklets
@ 2017-02-12 14:31   ` Chris Wilson
  0 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 14:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jens Axboe, Hannes Reinecke, Sagi Grimberg,
	Peter Zijlstra (Intel),
	intel-gfx, Chen Fan, Eric Dumazet, Emese Revfy,
	Alexander Potapenko, Johannes Thumshirn, Bjorn Helgaas,
	Ben Hutchings, Thomas Gleixner, Ingo Molnar,
	Sebastian Andrzej Siewior, Tom Herbert

Disabling a tasklet causes it not to run during tasklet_action, but is
put back onto the runnable tasklet list, and a new softirq raised. As
the softirq is raised from within __do_softirq() this causing
__do_softirq() to loop constantly until its timeslice expires and is
transferred to the ksoftirq thread. ksoftirq then permanently spins,
as on each action, the disabled tasklet keeps reraising the softirq.

Break this vicious cycle by moving the softirq from the action to the
final tasklet_enable().

This behaviour appears to be historic (since the first git import).
However, the looping until timeslice duration (to a max of 2ms) was
first introduced in commit c10d73671ad3 ("softirq: reduce latencies"),
with the restart limit restored in commit 34376a50fb1f ("Fix lockup
related to stop_machine being stuck in __do_softirq.")

v2: Export tasklet_enable() to work with modules.

Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
---
 include/linux/interrupt.h |  7 +------
 kernel/softirq.c          | 12 ++++++++++--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 53144e78a369..a1fa88e7e509 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -611,12 +611,7 @@ static inline void tasklet_disable(struct tasklet_struct *t)
 	smp_mb();
 }
 
-static inline void tasklet_enable(struct tasklet_struct *t)
-{
-	smp_mb__before_atomic();
-	atomic_dec(&t->count);
-}
-
+extern void tasklet_enable(struct tasklet_struct *t);
 extern void tasklet_kill(struct tasklet_struct *t);
 extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
 extern void tasklet_init(struct tasklet_struct *t,
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 080eb57789c4..ab8d9aeccb46 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -535,7 +535,6 @@ static __latent_entropy void tasklet_action(struct softirq_action *a)
 		t->next = NULL;
 		*__this_cpu_read(tasklet_vec.tail) = t;
 		__this_cpu_write(tasklet_vec.tail, &(t->next));
-		__raise_softirq_irqoff(TASKLET_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -571,7 +570,6 @@ static __latent_entropy void tasklet_hi_action(struct softirq_action *a)
 		t->next = NULL;
 		*__this_cpu_read(tasklet_hi_vec.tail) = t;
 		__this_cpu_write(tasklet_hi_vec.tail, &(t->next));
-		__raise_softirq_irqoff(HI_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -587,6 +585,16 @@ void tasklet_init(struct tasklet_struct *t,
 }
 EXPORT_SYMBOL(tasklet_init);
 
+void tasklet_enable(struct tasklet_struct *t)
+{
+	if (!atomic_dec_and_test(&t->count))
+		return;
+
+	if (test_bit(TASKLET_STATE_SCHED, &t->state))
+		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);
+}
+EXPORT_SYMBOL(tasklet_enable);
+
 void tasklet_kill(struct tasklet_struct *t)
 {
 	if (in_interrupt())
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* ✗ Fi.CI.BAT: failure for softirq: Prevent looping on disabled tasklets
  2017-02-12 14:00 ` Chris Wilson
                   ` (2 preceding siblings ...)
  (?)
@ 2017-02-12 14:32 ` Patchwork
  -1 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2017-02-12 14:32 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: softirq: Prevent looping on disabled tasklets
URL   : https://patchwork.freedesktop.org/series/19515/
State : failure

== Summary ==

  CHECK   usr/include/linux/dvb/ (8 files)
  CHECK   usr/include/linux/android/ (1 files)
  CHECK   usr/include/linux/byteorder/ (2 files)
  CHECK   usr/include/linux/caif/ (2 files)
  CHECK   usr/include/linux/ (443 files)
  CHECK   usr/include/linux/netfilter_bridge/ (17 files)
  CHECK   usr/include/linux/spi/ (1 files)
  CHECK   usr/include/linux/iio/ (2 files)
  CHECK   usr/include/linux/netfilter_ipv4/ (9 files)
  CHECK   usr/include/linux/isdn/ (1 files)
  CHECK   usr/include/linux/hsi/ (2 files)
  CHECK   usr/include/linux/tc_ematch/ (4 files)
  CHECK   usr/include/linux/netfilter_arp/ (2 files)
  CHECK   usr/include/linux/hdlc/ (1 files)
  CHECK   usr/include/linux/wimax/ (1 files)
  CHECK   usr/include/linux/mmc/ (1 files)
  CHECK   usr/include/linux/usb/ (11 files)
  CHECK   usr/include/linux/can/ (5 files)
  CHECK   usr/include/linux/raid/ (2 files)
  CHECK   usr/include/linux/sunrpc/ (1 files)
  CHECK   usr/include/linux/netfilter/ (87 files)
  CHECK   usr/include/linux/netfilter_ipv6/ (12 files)
  CHECK   usr/include/linux/nfsd/ (5 files)
  CHECK   usr/include/linux/netfilter/ipset/ (4 files)
  CHECK   usr/include/linux/tc_act/ (14 files)
  CHECK   usr/include/asm/ (62 files)
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      vmlinux.o
  MODPOST vmlinux.o
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  CC      arch/x86/boot/a20.o
  AS      arch/x86/boot/bioscall.o
  CC      arch/x86/boot/cmdline.o
  AS      arch/x86/boot/copy.o
  HOSTCC  arch/x86/boot/mkcpustr
  CC      arch/x86/boot/cpuflags.o
  CC      arch/x86/boot/early_serial_console.o
  CC      arch/x86/boot/cpucheck.o
  CC      arch/x86/boot/main.o
  CC      arch/x86/boot/printf.o
  CC      arch/x86/boot/edd.o
  CC      arch/x86/boot/memory.o
  CC      arch/x86/boot/pm.o
  CC      arch/x86/boot/tty.o
  AS      arch/x86/boot/pmjump.o
  CC      arch/x86/boot/video.o
  CC      arch/x86/boot/video-mode.o
  CC      arch/x86/boot/version.o
  CC      arch/x86/boot/string.o
  CC      arch/x86/boot/video-vga.o
  CC      arch/x86/boot/video-vesa.o
  CC      arch/x86/boot/video-bios.o
  CC      arch/x86/boot/regs.o
  HOSTCC  arch/x86/boot/tools/build
  Building modules, stage 2.
  CPUSTR  arch/x86/boot/cpustr.h
  CC      arch/x86/boot/cpu.o
  MODPOST 99 modules
  LDS     arch/x86/boot/compressed/vmlinux.lds
  AS      arch/x86/boot/compressed/head_64.o
  VOFFSET arch/x86/boot/compressed/../voffset.h
  CC      arch/x86/boot/compressed/string.o
  CC      arch/x86/boot/compressed/cmdline.o
  HOSTCC  arch/x86/boot/compressed/mkpiggy
  CC      arch/x86/boot/compressed/cpuflags.o
  CC      arch/x86/boot/compressed/early_serial_console.o
  CC      arch/x86/boot/compressed/eboot.o
  AS      arch/x86/boot/compressed/efi_stub_64.o
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin
  CC      arch/x86/boot/compressed/error.o
  XZKERN  arch/x86/boot/compressed/vmlinux.bin.xz
ERROR: "raise_softirq" [drivers/gpu/drm/i915/i915.ko] undefined!
scripts/Makefile.modpost:91: recipe for target '__modpost' failed
make[1]: *** [__modpost] Error 1
Makefile:1196: recipe for target 'modules' failed
make: *** [modules] Error 2
make: *** Waiting for unfinished jobs....
  CC      arch/x86/boot/compressed/misc.o
  MKPIGGY arch/x86/boot/compressed/piggy.S
  AS      arch/x86/boot/compressed/piggy.o
  DATAREL arch/x86/boot/compressed/vmlinux
  LD      arch/x86/boot/compressed/vmlinux
  ZOFFSET arch/x86/boot/zoffset.h
  OBJCOPY arch/x86/boot/vmlinux.bin
  AS      arch/x86/boot/header.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  BUILD   arch/x86/boot/bzImage
Setup is 16412 bytes (padded to 16896 bytes).
System is 4854 kB
CRC e2277ba4
Kernel: arch/x86/boot/bzImage is ready  (#1)

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Intel-gfx] [PATCH] softirq: Prevent looping on disabled tasklets
  2017-02-12 14:00 ` Chris Wilson
                   ` (3 preceding siblings ...)
  (?)
@ 2017-02-12 15:04 ` kbuild test robot
  -1 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2017-02-12 15:04 UTC (permalink / raw)
  To: Chris Wilson
  Cc: kbuild-all, linux-kernel, Jens Axboe, Hannes Reinecke,
	Sagi Grimberg, Peter Zijlstra (Intel),
	intel-gfx, Chen Fan, Eric Dumazet, Emese Revfy,
	Alexander Potapenko, Johannes Thumshirn, Bjorn Helgaas,
	Ben Hutchings, Thomas Gleixner, Ingo Molnar,
	Sebastian Andrzej Siewior, Tom Herbert

[-- Attachment #1: Type: text/plain, Size: 772 bytes --]

Hi Chris,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.10-rc7 next-20170210]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/softirq-Prevent-looping-on-disabled-tasklets/20170212-220435
config: x86_64-lkp (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "raise_softirq" [net/mac80211/mac80211.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24664 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Intel-gfx] [PATCH] softirq: Prevent looping on disabled tasklets
  2017-02-12 14:00 ` Chris Wilson
@ 2017-02-12 15:16   ` kbuild test robot
  -1 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2017-02-12 15:16 UTC (permalink / raw)
  To: Chris Wilson
  Cc: kbuild-all, linux-kernel, Jens Axboe, Hannes Reinecke,
	Sagi Grimberg, Peter Zijlstra (Intel),
	intel-gfx, Chen Fan, Eric Dumazet, Emese Revfy,
	Alexander Potapenko, Johannes Thumshirn, Bjorn Helgaas,
	Ben Hutchings, Thomas Gleixner, Ingo Molnar,
	Sebastian Andrzej Siewior, Tom Herbert

[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]

Hi Chris,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.10-rc7 next-20170210]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/softirq-Prevent-looping-on-disabled-tasklets/20170212-220435
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "raise_softirq" [sound/pci/asihpi/snd-asihpi.ko] undefined!
>> ERROR: "raise_softirq" [net/mac802154/mac802154.ko] undefined!
   ERROR: "raise_softirq" [net/mac80211/mac80211.ko] undefined!
>> ERROR: "raise_softirq" [drivers/usb/atm/usbatm.ko] undefined!
>> ERROR: "raise_softirq" [drivers/net/ethernet/jme.ko] undefined!
>> ERROR: "raise_softirq" [drivers/media/pci/mantis/mantis_core.ko] undefined!
>> ERROR: "raise_softirq" [drivers/hv/hv_vmbus.ko] undefined!
>> ERROR: "raise_softirq" [drivers/firewire/firewire-ohci.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38265 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] softirq: Prevent looping on disabled tasklets
@ 2017-02-12 15:16   ` kbuild test robot
  0 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2017-02-12 15:16 UTC (permalink / raw)
  To: Chris Wilson
  Cc: Jens Axboe, Hannes Reinecke, Sagi Grimberg,
	Peter Zijlstra (Intel),
	intel-gfx, linux-kernel, Bjorn Helgaas, Eric Dumazet,
	Emese Revfy, Alexander Potapenko, kbuild-all, Johannes Thumshirn,
	Chen Fan, Ben Hutchings, Thomas Gleixner, Ingo Molnar,
	Sebastian Andrzej Siewior, Tom Herbert

[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]

Hi Chris,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.10-rc7 next-20170210]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/softirq-Prevent-looping-on-disabled-tasklets/20170212-220435
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "raise_softirq" [sound/pci/asihpi/snd-asihpi.ko] undefined!
>> ERROR: "raise_softirq" [net/mac802154/mac802154.ko] undefined!
   ERROR: "raise_softirq" [net/mac80211/mac80211.ko] undefined!
>> ERROR: "raise_softirq" [drivers/usb/atm/usbatm.ko] undefined!
>> ERROR: "raise_softirq" [drivers/net/ethernet/jme.ko] undefined!
>> ERROR: "raise_softirq" [drivers/media/pci/mantis/mantis_core.ko] undefined!
>> ERROR: "raise_softirq" [drivers/hv/hv_vmbus.ko] undefined!
>> ERROR: "raise_softirq" [drivers/firewire/firewire-ohci.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38265 bytes --]

[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 17+ messages in thread

* ✗ Fi.CI.BAT: failure for softirq: Prevent looping on disabled tasklets (rev2)
  2017-02-12 14:00 ` Chris Wilson
                   ` (5 preceding siblings ...)
  (?)
@ 2017-02-12 15:22 ` Patchwork
  -1 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2017-02-12 15:22 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: softirq: Prevent looping on disabled tasklets (rev2)
URL   : https://patchwork.freedesktop.org/series/19515/
State : failure

== Summary ==

Series 19515v2 softirq: Prevent looping on disabled tasklets
https://patchwork.freedesktop.org/api/1.0/series/19515/revisions/2/mbox/

Test core_auth:
        Subgroup basic-auth:
                pass       -> TIMEOUT    (fi-skl-6700k)
Test core_prop_blob:
        Subgroup basic:
                pass       -> INCOMPLETE (fi-skl-6700k)
Test gem_close_race:
        Subgroup basic-process:
                pass       -> TIMEOUT    (fi-skl-6700hq)
                pass       -> TIMEOUT    (fi-skl-6770hq)
        Subgroup basic-threads:
                pass       -> INCOMPLETE (fi-skl-6700hq)
                pass       -> TIMEOUT    (fi-bxt-j4205)
                pass       -> INCOMPLETE (fi-skl-6770hq) FDO#99742
                pass       -> TIMEOUT    (fi-bsw-n3050)
Test gem_cpu_reloc:
        Subgroup basic:
                pass       -> INCOMPLETE (fi-bsw-n3050)
Test gem_ctx_switch:
        Subgroup basic-default:
                pass       -> INCOMPLETE (fi-bxt-j4205)
                pass       -> TIMEOUT    (fi-bdw-5557u)
                pass       -> TIMEOUT    (fi-kbl-7500u)
        Subgroup basic-default-heavy:
                pass       -> INCOMPLETE (fi-kbl-7500u)
Test gem_exec_flush:
        Subgroup basic-batch-kernel-default-uc:
                pass       -> TIMEOUT    (fi-skl-6260u)
                pass       -> INCOMPLETE (fi-bdw-5557u)
                pass       -> TIMEOUT    (fi-bxt-t5700)
        Subgroup basic-batch-kernel-default-wb:
                pass       -> INCOMPLETE (fi-bxt-t5700)
                pass       -> INCOMPLETE (fi-skl-6260u)

FDO#99742 https://bugs.freedesktop.org/show_bug.cgi?id=99742

fi-bdw-5557u     total:51   pass:48   dwarn:0   dfail:0   fail:0   skip:1  
fi-bsw-n3050     total:13   pass:11   dwarn:0   dfail:0   fail:0   skip:0  
fi-bxt-j4205     total:21   pass:19   dwarn:0   dfail:0   fail:0   skip:0  
fi-bxt-t5700     total:52   pass:43   dwarn:0   dfail:0   fail:0   skip:7  
fi-byt-j1900     total:252  pass:225  dwarn:0   dfail:0   fail:0   skip:27 
fi-byt-n2820     total:252  pass:221  dwarn:0   dfail:0   fail:0   skip:31 
fi-hsw-4770      total:252  pass:236  dwarn:0   dfail:0   fail:0   skip:16 
fi-hsw-4770r     total:252  pass:236  dwarn:0   dfail:0   fail:0   skip:16 
fi-ilk-650       total:252  pass:202  dwarn:0   dfail:0   fail:0   skip:50 
fi-ivb-3520m     total:252  pass:234  dwarn:0   dfail:0   fail:0   skip:18 
fi-ivb-3770      total:252  pass:234  dwarn:0   dfail:0   fail:0   skip:18 
fi-kbl-7500u     total:22   pass:20   dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6260u     total:52   pass:49   dwarn:0   dfail:0   fail:0   skip:1  
fi-skl-6700hq    total:12   pass:10   dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6700k     total:2    pass:0    dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6770hq    total:12   pass:10   dwarn:0   dfail:0   fail:0   skip:0  
fi-snb-2520m     total:252  pass:224  dwarn:0   dfail:0   fail:0   skip:28 
fi-snb-2600      total:252  pass:223  dwarn:0   dfail:0   fail:0   skip:29 

f48164e93e75dbbe0bb9dac254779eeea08c0657 drm-tip: 2017y-02m-12d-11h-10m-28s UTC integration manifest
8a1a5d9 softirq: Prevent looping on disabled tasklets

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3782/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v3] softirq: Prevent looping on disabled tasklets
  2017-02-12 14:00 ` Chris Wilson
@ 2017-02-12 15:46   ` Chris Wilson
  -1 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 15:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: intel-gfx, Chris Wilson, Tvrtko Ursulin, Thomas Gleixner,
	Hannes Reinecke, Jens Axboe, Bjorn Helgaas, Alexander Potapenko,
	Chen Fan, Ingo Molnar, Peter Zijlstra (Intel),
	Sebastian Andrzej Siewior, Johannes Thumshirn, Emese Revfy,
	Sagi Grimberg, Eric Dumazet, Tom Herbert, Ben Hutchings

Disabling a tasklet causes it not to run during tasklet_action, but is
put back onto the runnable tasklet list, and a new softirq raised. As
the softirq is raised from within __do_softirq() this causing
__do_softirq() to loop constantly until its timeslice expires and is
transferred to the ksoftirq thread. ksoftirq then permanently spins,
as on each action, the disabled tasklet keeps reraising the softirq.

Break this vicious cycle by moving the softirq from the action to the
final tasklet_enable().

This behaviour appears to be historic (since the first git import).
However, the looping until timeslice duration (to a max of 2ms) was
first introduced in commit c10d73671ad3 ("softirq: reduce latencies"),
with the restart limit restored in commit 34376a50fb1f ("Fix lockup
related to stop_machine being stuck in __do_softirq.")

v2: Export tasklet_enable() to work with modules.
v3: Restore the looping over a failed tasklet_trylock()

Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
---
 include/linux/interrupt.h |  7 +------
 kernel/softirq.c          | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 53144e78a369..a1fa88e7e509 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -611,12 +611,7 @@ static inline void tasklet_disable(struct tasklet_struct *t)
 	smp_mb();
 }
 
-static inline void tasklet_enable(struct tasklet_struct *t)
-{
-	smp_mb__before_atomic();
-	atomic_dec(&t->count);
-}
-
+extern void tasklet_enable(struct tasklet_struct *t);
 extern void tasklet_kill(struct tasklet_struct *t);
 extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
 extern void tasklet_init(struct tasklet_struct *t,
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 080eb57789c4..47c8933d315e 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -516,6 +516,7 @@ static __latent_entropy void tasklet_action(struct softirq_action *a)
 
 	while (list) {
 		struct tasklet_struct *t = list;
+		bool raise_softirq = true;
 
 		list = list->next;
 
@@ -529,13 +530,15 @@ static __latent_entropy void tasklet_action(struct softirq_action *a)
 				continue;
 			}
 			tasklet_unlock(t);
+			raise_softirq = false;
 		}
 
 		local_irq_disable();
 		t->next = NULL;
 		*__this_cpu_read(tasklet_vec.tail) = t;
 		__this_cpu_write(tasklet_vec.tail, &(t->next));
-		__raise_softirq_irqoff(TASKLET_SOFTIRQ);
+		if (raise_softirq)
+			__raise_softirq_irqoff(TASKLET_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -552,6 +555,7 @@ static __latent_entropy void tasklet_hi_action(struct softirq_action *a)
 
 	while (list) {
 		struct tasklet_struct *t = list;
+		bool raise_softirq = true;
 
 		list = list->next;
 
@@ -565,13 +569,15 @@ static __latent_entropy void tasklet_hi_action(struct softirq_action *a)
 				continue;
 			}
 			tasklet_unlock(t);
+			raise_softirq = false;
 		}
 
 		local_irq_disable();
 		t->next = NULL;
 		*__this_cpu_read(tasklet_hi_vec.tail) = t;
 		__this_cpu_write(tasklet_hi_vec.tail, &(t->next));
-		__raise_softirq_irqoff(HI_SOFTIRQ);
+		if (raise_softirq)
+			__raise_softirq_irqoff(HI_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -587,6 +593,16 @@ void tasklet_init(struct tasklet_struct *t,
 }
 EXPORT_SYMBOL(tasklet_init);
 
+void tasklet_enable(struct tasklet_struct *t)
+{
+	if (!atomic_dec_and_test(&t->count))
+		return;
+
+	if (test_bit(TASKLET_STATE_SCHED, &t->state))
+		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);
+}
+EXPORT_SYMBOL(tasklet_enable);
+
 void tasklet_kill(struct tasklet_struct *t)
 {
 	if (in_interrupt())
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v3] softirq: Prevent looping on disabled tasklets
@ 2017-02-12 15:46   ` Chris Wilson
  0 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 15:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jens Axboe, Hannes Reinecke, Sagi Grimberg,
	Peter Zijlstra (Intel),
	intel-gfx, Chen Fan, Eric Dumazet, Emese Revfy,
	Alexander Potapenko, Johannes Thumshirn, Bjorn Helgaas,
	Ben Hutchings, Thomas Gleixner, Ingo Molnar,
	Sebastian Andrzej Siewior, Tom Herbert

Disabling a tasklet causes it not to run during tasklet_action, but is
put back onto the runnable tasklet list, and a new softirq raised. As
the softirq is raised from within __do_softirq() this causing
__do_softirq() to loop constantly until its timeslice expires and is
transferred to the ksoftirq thread. ksoftirq then permanently spins,
as on each action, the disabled tasklet keeps reraising the softirq.

Break this vicious cycle by moving the softirq from the action to the
final tasklet_enable().

This behaviour appears to be historic (since the first git import).
However, the looping until timeslice duration (to a max of 2ms) was
first introduced in commit c10d73671ad3 ("softirq: reduce latencies"),
with the restart limit restored in commit 34376a50fb1f ("Fix lockup
related to stop_machine being stuck in __do_softirq.")

v2: Export tasklet_enable() to work with modules.
v3: Restore the looping over a failed tasklet_trylock()

Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
---
 include/linux/interrupt.h |  7 +------
 kernel/softirq.c          | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 53144e78a369..a1fa88e7e509 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -611,12 +611,7 @@ static inline void tasklet_disable(struct tasklet_struct *t)
 	smp_mb();
 }
 
-static inline void tasklet_enable(struct tasklet_struct *t)
-{
-	smp_mb__before_atomic();
-	atomic_dec(&t->count);
-}
-
+extern void tasklet_enable(struct tasklet_struct *t);
 extern void tasklet_kill(struct tasklet_struct *t);
 extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
 extern void tasklet_init(struct tasklet_struct *t,
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 080eb57789c4..47c8933d315e 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -516,6 +516,7 @@ static __latent_entropy void tasklet_action(struct softirq_action *a)
 
 	while (list) {
 		struct tasklet_struct *t = list;
+		bool raise_softirq = true;
 
 		list = list->next;
 
@@ -529,13 +530,15 @@ static __latent_entropy void tasklet_action(struct softirq_action *a)
 				continue;
 			}
 			tasklet_unlock(t);
+			raise_softirq = false;
 		}
 
 		local_irq_disable();
 		t->next = NULL;
 		*__this_cpu_read(tasklet_vec.tail) = t;
 		__this_cpu_write(tasklet_vec.tail, &(t->next));
-		__raise_softirq_irqoff(TASKLET_SOFTIRQ);
+		if (raise_softirq)
+			__raise_softirq_irqoff(TASKLET_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -552,6 +555,7 @@ static __latent_entropy void tasklet_hi_action(struct softirq_action *a)
 
 	while (list) {
 		struct tasklet_struct *t = list;
+		bool raise_softirq = true;
 
 		list = list->next;
 
@@ -565,13 +569,15 @@ static __latent_entropy void tasklet_hi_action(struct softirq_action *a)
 				continue;
 			}
 			tasklet_unlock(t);
+			raise_softirq = false;
 		}
 
 		local_irq_disable();
 		t->next = NULL;
 		*__this_cpu_read(tasklet_hi_vec.tail) = t;
 		__this_cpu_write(tasklet_hi_vec.tail, &(t->next));
-		__raise_softirq_irqoff(HI_SOFTIRQ);
+		if (raise_softirq)
+			__raise_softirq_irqoff(HI_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -587,6 +593,16 @@ void tasklet_init(struct tasklet_struct *t,
 }
 EXPORT_SYMBOL(tasklet_init);
 
+void tasklet_enable(struct tasklet_struct *t)
+{
+	if (!atomic_dec_and_test(&t->count))
+		return;
+
+	if (test_bit(TASKLET_STATE_SCHED, &t->state))
+		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);
+}
+EXPORT_SYMBOL(tasklet_enable);
+
 void tasklet_kill(struct tasklet_struct *t)
 {
 	if (in_interrupt())
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v3] softirq: Prevent looping on disabled tasklets
  2017-02-12 15:46   ` Chris Wilson
@ 2017-02-12 16:03     ` Chris Wilson
  -1 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 16:03 UTC (permalink / raw)
  To: linux-kernel
  Cc: intel-gfx, Tvrtko Ursulin, Thomas Gleixner, Hannes Reinecke,
	Jens Axboe, Bjorn Helgaas, Alexander Potapenko, Chen Fan,
	Ingo Molnar, Peter Zijlstra (Intel),
	Sebastian Andrzej Siewior, Johannes Thumshirn, Emese Revfy,
	Sagi Grimberg, Eric Dumazet, Tom Herbert, Ben Hutchings

On Sun, Feb 12, 2017 at 03:46:09PM +0000, Chris Wilson wrote:
> +void tasklet_enable(struct tasklet_struct *t)
> +{
> +	if (!atomic_dec_and_test(&t->count))
> +		return;
> +
> +	if (test_bit(TASKLET_STATE_SCHED, &t->state))
> +		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);

And of course this can't work as raise_softirq() is local to the cpu.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v3] softirq: Prevent looping on disabled tasklets
@ 2017-02-12 16:03     ` Chris Wilson
  0 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2017-02-12 16:03 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jens Axboe, Hannes Reinecke, Sagi Grimberg,
	Peter Zijlstra (Intel),
	intel-gfx, Chen Fan, Eric Dumazet, Emese Revfy,
	Alexander Potapenko, Johannes Thumshirn, Bjorn Helgaas,
	Ben Hutchings, Thomas Gleixner, Ingo Molnar,
	Sebastian Andrzej Siewior, Tom Herbert

On Sun, Feb 12, 2017 at 03:46:09PM +0000, Chris Wilson wrote:
> +void tasklet_enable(struct tasklet_struct *t)
> +{
> +	if (!atomic_dec_and_test(&t->count))
> +		return;
> +
> +	if (test_bit(TASKLET_STATE_SCHED, &t->state))
> +		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);

And of course this can't work as raise_softirq() is local to the cpu.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 17+ messages in thread

* ✓ Fi.CI.BAT: success for softirq: Prevent looping on disabled tasklets (rev3)
  2017-02-12 14:00 ` Chris Wilson
                   ` (7 preceding siblings ...)
  (?)
@ 2017-02-12 16:22 ` Patchwork
  -1 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2017-02-12 16:22 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: softirq: Prevent looping on disabled tasklets (rev3)
URL   : https://patchwork.freedesktop.org/series/19515/
State : success

== Summary ==

Series 19515v3 softirq: Prevent looping on disabled tasklets
https://patchwork.freedesktop.org/api/1.0/series/19515/revisions/3/mbox/

fi-bdw-5557u     total:252  pass:241  dwarn:0   dfail:0   fail:0   skip:11 
fi-bsw-n3050     total:252  pass:213  dwarn:0   dfail:0   fail:0   skip:39 
fi-bxt-j4205     total:252  pass:233  dwarn:0   dfail:0   fail:0   skip:19 
fi-bxt-t5700     total:83   pass:70   dwarn:0   dfail:0   fail:0   skip:12 
fi-byt-j1900     total:252  pass:225  dwarn:0   dfail:0   fail:0   skip:27 
fi-byt-n2820     total:252  pass:221  dwarn:0   dfail:0   fail:0   skip:31 
fi-hsw-4770      total:252  pass:236  dwarn:0   dfail:0   fail:0   skip:16 
fi-hsw-4770r     total:252  pass:236  dwarn:0   dfail:0   fail:0   skip:16 
fi-ilk-650       total:252  pass:202  dwarn:0   dfail:0   fail:0   skip:50 
fi-ivb-3520m     total:252  pass:234  dwarn:0   dfail:0   fail:0   skip:18 
fi-ivb-3770      total:252  pass:234  dwarn:0   dfail:0   fail:0   skip:18 
fi-kbl-7500u     total:252  pass:234  dwarn:0   dfail:0   fail:0   skip:18 
fi-skl-6260u     total:252  pass:242  dwarn:0   dfail:0   fail:0   skip:10 
fi-skl-6700hq    total:252  pass:235  dwarn:0   dfail:0   fail:0   skip:17 
fi-skl-6700k     total:252  pass:230  dwarn:4   dfail:0   fail:0   skip:18 
fi-skl-6770hq    total:252  pass:242  dwarn:0   dfail:0   fail:0   skip:10 
fi-snb-2520m     total:252  pass:224  dwarn:0   dfail:0   fail:0   skip:28 
fi-snb-2600      total:252  pass:223  dwarn:0   dfail:0   fail:0   skip:29 

f48164e93e75dbbe0bb9dac254779eeea08c0657 drm-tip: 2017y-02m-12d-11h-10m-28s UTC integration manifest
1ffceb2 softirq: Prevent looping on disabled tasklets

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3783/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v3] softirq: Prevent looping on disabled tasklets
  2017-02-12 16:03     ` Chris Wilson
  (?)
@ 2017-02-17 11:55     ` Thomas Gleixner
  -1 siblings, 0 replies; 17+ messages in thread
From: Thomas Gleixner @ 2017-02-17 11:55 UTC (permalink / raw)
  To: Chris Wilson
  Cc: linux-kernel, intel-gfx, Tvrtko Ursulin, Hannes Reinecke,
	Jens Axboe, Bjorn Helgaas, Alexander Potapenko, Chen Fan,
	Ingo Molnar, Peter Zijlstra (Intel),
	Sebastian Andrzej Siewior, Johannes Thumshirn, Emese Revfy,
	Sagi Grimberg, Eric Dumazet, Tom Herbert, Ben Hutchings

On Sun, 12 Feb 2017, Chris Wilson wrote:

> On Sun, Feb 12, 2017 at 03:46:09PM +0000, Chris Wilson wrote:
> > +void tasklet_enable(struct tasklet_struct *t)
> > +{
> > +	if (!atomic_dec_and_test(&t->count))
> > +		return;
> > +
> > +	if (test_bit(TASKLET_STATE_SCHED, &t->state))
> > +		raise_softirq(HI_SOFTIRQ | TASKLET_SOFTIRQ);
> 
> And of course this can't work as raise_softirq() is local to the cpu.

Indeed. tasklets are a horror by design. We rather should make them go away.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-02-17 11:56 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-12 14:00 [PATCH] softirq: Prevent looping on disabled tasklets Chris Wilson
2017-02-12 14:00 ` Chris Wilson
2017-02-12 14:23 ` Chris Wilson
2017-02-12 14:23   ` Chris Wilson
2017-02-12 14:31 ` [PATCH v2] " Chris Wilson
2017-02-12 14:31   ` Chris Wilson
2017-02-12 14:32 ` ✗ Fi.CI.BAT: failure for " Patchwork
2017-02-12 15:04 ` [Intel-gfx] [PATCH] " kbuild test robot
2017-02-12 15:16 ` kbuild test robot
2017-02-12 15:16   ` kbuild test robot
2017-02-12 15:22 ` ✗ Fi.CI.BAT: failure for softirq: Prevent looping on disabled tasklets (rev2) Patchwork
2017-02-12 15:46 ` [PATCH v3] softirq: Prevent looping on disabled tasklets Chris Wilson
2017-02-12 15:46   ` Chris Wilson
2017-02-12 16:03   ` Chris Wilson
2017-02-12 16:03     ` Chris Wilson
2017-02-17 11:55     ` Thomas Gleixner
2017-02-12 16:22 ` ✓ Fi.CI.BAT: success for softirq: Prevent looping on disabled tasklets (rev3) Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.