All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irq_work: Don't reinvent the wheel but use existing llist API
@ 2017-10-31  1:46 Frederic Weisbecker
  2017-10-31 12:04 ` [tip:irq/core] irq/work: " tip-bot for Byungchul Park
  2017-11-10  0:17 ` [PATCH] irq_work: " Chris Wilson
  0 siblings, 2 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2017-10-31  1:46 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Byungchul Park, Frederic Weisbecker, Peter Zijlstra

From: Byungchul Park <byungchul.park@lge.com>

Although llist provides proper APIs, they are not used. Make them used.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 kernel/irq_work.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index bcf107c..e2ebe8c 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -138,11 +138,7 @@ static void irq_work_run_list(struct llist_head *list)
 		return;
 
 	llnode = llist_del_all(list);
-	while (llnode != NULL) {
-		work = llist_entry(llnode, struct irq_work, llnode);
-
-		llnode = llist_next(llnode);
-
+	llist_for_each_entry(work, llnode, llnode) {
 		/*
 		 * Clear the PENDING bit, after this point the @work
 		 * can be re-used.
-- 
2.7.4

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

* [tip:irq/core] irq/work: Don't reinvent the wheel but use existing llist API
  2017-10-31  1:46 [PATCH] irq_work: Don't reinvent the wheel but use existing llist API Frederic Weisbecker
@ 2017-10-31 12:04 ` tip-bot for Byungchul Park
  2017-11-10  0:17 ` [PATCH] irq_work: " Chris Wilson
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Byungchul Park @ 2017-10-31 12:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, frederic, byungchul.park, peterz, tglx, mingo, hpa,
	torvalds

Commit-ID:  16c0890dc66d258fdeccf7b15a133f3930b19143
Gitweb:     https://git.kernel.org/tip/16c0890dc66d258fdeccf7b15a133f3930b19143
Author:     Byungchul Park <byungchul.park@lge.com>
AuthorDate: Tue, 31 Oct 2017 02:46:54 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 31 Oct 2017 10:24:39 +0100

irq/work: Don't reinvent the wheel but use existing llist API

Use the proper llist APIs instead of open-coded variants of them.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1509414414-14987-1-git-send-email-frederic@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/irq_work.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index bcf107c..e2ebe8c 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -138,11 +138,7 @@ static void irq_work_run_list(struct llist_head *list)
 		return;
 
 	llnode = llist_del_all(list);
-	while (llnode != NULL) {
-		work = llist_entry(llnode, struct irq_work, llnode);
-
-		llnode = llist_next(llnode);
-
+	llist_for_each_entry(work, llnode, llnode) {
 		/*
 		 * Clear the PENDING bit, after this point the @work
 		 * can be re-used.

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

* Re: [PATCH] irq_work: Don't reinvent the wheel but use existing llist API
  2017-10-31  1:46 [PATCH] irq_work: Don't reinvent the wheel but use existing llist API Frederic Weisbecker
  2017-10-31 12:04 ` [tip:irq/core] irq/work: " tip-bot for Byungchul Park
@ 2017-11-10  0:17 ` Chris Wilson
  2017-11-12 12:24   ` [tip:irq/core] irq/work: Use llist_for_each_entry_safe tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2017-11-10  0:17 UTC (permalink / raw)
  To: Frederic Weisbecker, Ingo Molnar
  Cc: LKML, Byungchul Park, Frederic Weisbecker, Peter Zijlstra,
	Petri Latvala

Quoting Frederic Weisbecker (2017-10-31 01:46:54)
> From: Byungchul Park <byungchul.park@lge.com>
> 
> Although llist provides proper APIs, they are not used. Make them used.
> 
> Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> ---
>  kernel/irq_work.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/kernel/irq_work.c b/kernel/irq_work.c
> index bcf107c..e2ebe8c 100644
> --- a/kernel/irq_work.c
> +++ b/kernel/irq_work.c
> @@ -138,11 +138,7 @@ static void irq_work_run_list(struct llist_head *list)
>                 return;
>  
>         llnode = llist_del_all(list);
> -       while (llnode != NULL) {
> -               work = llist_entry(llnode, struct irq_work, llnode);
> -
> -               llnode = llist_next(llnode);
> -
> +       llist_for_each_entry(work, llnode, llnode) {
>                 /*
>                  * Clear the PENDING bit, after this point the @work
>                  * can be re-used.

I haven't seen this reported yet, but this requires
llist_for_each_entry_safe() because as mentioned work can be linked into
another cpu's runlist after the PENDING bit is cleared.
-Chris

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

* [tip:irq/core] irq/work: Use llist_for_each_entry_safe
  2017-11-10  0:17 ` [PATCH] irq_work: " Chris Wilson
@ 2017-11-12 12:24   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Thomas Gleixner @ 2017-11-12 12:24 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, petri.latvala, linux-kernel, byungchul.park, tglx, frederic,
	peterz, mingo

Commit-ID:  d00a08cf9ee986ad6689ce8c6fd176aff679c106
Gitweb:     https://git.kernel.org/tip/d00a08cf9ee986ad6689ce8c6fd176aff679c106
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 12 Nov 2017 13:02:51 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 12 Nov 2017 13:15:14 +0100

irq/work: Use llist_for_each_entry_safe

The llist_for_each_entry() loop in irq_work_run_list() is unsafe because
once the works PENDING bit is cleared it can be requeued on another CPU.

Use llist_for_each_entry_safe() instead.

Fixes: 16c0890dc66d ("irq/work: Don't reinvent the wheel but use existing llist API")
Reported-by:Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petri Latvala <petri.latvala@intel.com>
Link: http://lkml.kernel.org/r/151027307351.14762.4611888896020658384@mail.alporthouse.com
---
 kernel/irq_work.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index e2ebe8c..6647b33f 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -128,9 +128,9 @@ bool irq_work_needs_cpu(void)
 
 static void irq_work_run_list(struct llist_head *list)
 {
-	unsigned long flags;
-	struct irq_work *work;
+	struct irq_work *work, *tmp;
 	struct llist_node *llnode;
+	unsigned long flags;
 
 	BUG_ON(!irqs_disabled());
 
@@ -138,7 +138,7 @@ static void irq_work_run_list(struct llist_head *list)
 		return;
 
 	llnode = llist_del_all(list);
-	llist_for_each_entry(work, llnode, llnode) {
+	llist_for_each_entry_safe(work, tmp, llnode, llnode) {
 		/*
 		 * Clear the PENDING bit, after this point the @work
 		 * can be re-used.

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

end of thread, other threads:[~2017-11-12 12:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-31  1:46 [PATCH] irq_work: Don't reinvent the wheel but use existing llist API Frederic Weisbecker
2017-10-31 12:04 ` [tip:irq/core] irq/work: " tip-bot for Byungchul Park
2017-11-10  0:17 ` [PATCH] irq_work: " Chris Wilson
2017-11-12 12:24   ` [tip:irq/core] irq/work: Use llist_for_each_entry_safe tip-bot for Thomas Gleixner

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.