mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] [RFC]IRQ CORE: irq_work_queue function return value not used.
@ 2012-10-31 14:02 anish kumar
  2012-10-31 14:09 ` Pallala, Ramakrishna
  2012-10-31 14:15 ` Steven Rostedt
  0 siblings, 2 replies; 4+ messages in thread
From: anish kumar @ 2012-10-31 14:02 UTC (permalink / raw)
  To: rostedt, linux-kernel, peterz, akpm, paul.gortmaker, tglx, mingo,
	fweisbec
  Cc: anish kumar

From: anish kumar <anish198519851985@gmail.com>

As no one is using the return value of irq_work_queue function
it is better to just make it void.

This patch is just a way to understand if there is some future
plan to use it but in any case please let me know the reason.
---
 kernel/irq_work.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index 1588e3b..4a9a44c 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -32,21 +32,21 @@ static DEFINE_PER_CPU(struct llist_head, irq_work_list);
 /*
  * Claim the entry so that no one else will poke at it.
  */
-static bool irq_work_claim(struct irq_work *work)
+static void irq_work_claim(struct irq_work *work)
 {
 	unsigned long flags, nflags;
 
 	for (;;) {
 		flags = work->flags;
 		if (flags & IRQ_WORK_PENDING)
-			return false;
+			return;
 		nflags = flags | IRQ_WORK_FLAGS;
 		if (cmpxchg(&work->flags, flags, nflags) == flags)
 			break;
 		cpu_relax();
 	}
 
-	return true;
+	return;
 }
 
 void __weak arch_irq_work_raise(void)
@@ -79,15 +79,14 @@ static void __irq_work_queue(struct irq_work *work)
  *
  * Can be re-enqueued while the callback is still in progress.
  */
-bool irq_work_queue(struct irq_work *work)
+void irq_work_queue(struct irq_work *work)
 {
-	if (!irq_work_claim(work)) {
-		/*
-		 * Already enqueued, can't do!
-		 */
-		return false;
-	}
-
+	/*
+	 * This function either will claim the entry to queue
+	 * the work or if the work is already queued and is in
+	 * pending state then it will simply return.
+	 */
+	irq_work_claim(work)
 	__irq_work_queue(work);
 	return true;
 }
-- 
1.7.1


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

* RE: [PATCH] [RFC]IRQ CORE: irq_work_queue function return value not used.
  2012-10-31 14:02 [PATCH] [RFC]IRQ CORE: irq_work_queue function return value not used anish kumar
@ 2012-10-31 14:09 ` Pallala, Ramakrishna
  2012-10-31 14:15 ` Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: Pallala, Ramakrishna @ 2012-10-31 14:09 UTC (permalink / raw)
  To: anish kumar, rostedt, linux-kernel, peterz, akpm, paul.gortmaker,
	tglx, mingo, fweisbec


> -bool irq_work_queue(struct irq_work *work)
> +void irq_work_queue(struct irq_work *work)
>  {
> -	if (!irq_work_claim(work)) {
> -		/*
> -		 * Already enqueued, can't do!
> -		 */
> -		return false;
> -	}
> -
> +	/*
> +	 * This function either will claim the entry to queue
> +	 * the work or if the work is already queued and is in
> +	 * pending state then it will simply return.
> +	 */
> +	irq_work_claim(work)
>  	__irq_work_queue(work);
>  	return true;
>  }
You can remove the last return statement.

Thanks,
Ram

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

* Re: [PATCH] [RFC]IRQ CORE: irq_work_queue function return value not used.
  2012-10-31 14:02 [PATCH] [RFC]IRQ CORE: irq_work_queue function return value not used anish kumar
  2012-10-31 14:09 ` Pallala, Ramakrishna
@ 2012-10-31 14:15 ` Steven Rostedt
  2012-10-31 14:36   ` anish kumar
  1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2012-10-31 14:15 UTC (permalink / raw)
  To: anish kumar
  Cc: linux-kernel, peterz, akpm, paul.gortmaker, tglx, mingo, fweisbec

On Wed, 2012-10-31 at 23:02 +0900, anish kumar wrote:
> From: anish kumar <anish198519851985@gmail.com>
> 
> As no one is using the return value of irq_work_queue function
> it is better to just make it void.
> 
> This patch is just a way to understand if there is some future
> plan to use it but in any case please let me know the reason.
> ---
>  kernel/irq_work.c |   21 ++++++++++-----------
>  1 files changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/kernel/irq_work.c b/kernel/irq_work.c
> index 1588e3b..4a9a44c 100644
> --- a/kernel/irq_work.c
> +++ b/kernel/irq_work.c
> @@ -32,21 +32,21 @@ static DEFINE_PER_CPU(struct llist_head, irq_work_list);
>  /*
>   * Claim the entry so that no one else will poke at it.
>   */
> -static bool irq_work_claim(struct irq_work *work)
> +static void irq_work_claim(struct irq_work *work)
>  {
>  	unsigned long flags, nflags;
>  
>  	for (;;) {
>  		flags = work->flags;
>  		if (flags & IRQ_WORK_PENDING)
> -			return false;
> +			return;
>  		nflags = flags | IRQ_WORK_FLAGS;
>  		if (cmpxchg(&work->flags, flags, nflags) == flags)
>  			break;
>  		cpu_relax();
>  	}
>  
> -	return true;
> +	return;
>  }
>  
>  void __weak arch_irq_work_raise(void)
> @@ -79,15 +79,14 @@ static void __irq_work_queue(struct irq_work *work)
>   *
>   * Can be re-enqueued while the callback is still in progress.
>   */
> -bool irq_work_queue(struct irq_work *work)
> +void irq_work_queue(struct irq_work *work)
>  {
> -	if (!irq_work_claim(work)) {
> -		/*
> -		 * Already enqueued, can't do!
> -		 */
> -		return false;
> -	}
> -
> +	/*
> +	 * This function either will claim the entry to queue
> +	 * the work or if the work is already queued and is in
> +	 * pending state then it will simply return.
> +	 */
> +	irq_work_claim(work)

Um, no.

If the state was already pending, we will corrupt the llist node of the
work if we call irq_work_queue(). You must check the return value of
irq_work_claim() and return if it fails. You can not call
__irq_work_queue() if irq_work_claim() does not succeed.

The return value of irq_work_queue() can be ignored, but not
irq_work_claim().

-- Steve

>  	__irq_work_queue(work);
>  	return true;
>  }



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

* Re: [PATCH] [RFC]IRQ CORE: irq_work_queue function return value not used.
  2012-10-31 14:15 ` Steven Rostedt
@ 2012-10-31 14:36   ` anish kumar
  0 siblings, 0 replies; 4+ messages in thread
From: anish kumar @ 2012-10-31 14:36 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, peterz, akpm, paul.gortmaker, tglx, mingo, fweisbec

On Wed, 2012-10-31 at 10:15 -0400, Steven Rostedt wrote:
> On Wed, 2012-10-31 at 23:02 +0900, anish kumar wrote:
> > From: anish kumar <anish198519851985@gmail.com>
> > 
> > As no one is using the return value of irq_work_queue function
> > it is better to just make it void.
> > 
> > This patch is just a way to understand if there is some future
> > plan to use it but in any case please let me know the reason.
> > ---
> >  kernel/irq_work.c |   21 ++++++++++-----------
> >  1 files changed, 10 insertions(+), 11 deletions(-)
> > 
> > diff --git a/kernel/irq_work.c b/kernel/irq_work.c
> > index 1588e3b..4a9a44c 100644
> > --- a/kernel/irq_work.c
> > +++ b/kernel/irq_work.c
> > @@ -32,21 +32,21 @@ static DEFINE_PER_CPU(struct llist_head, irq_work_list);
> >  /*
> >   * Claim the entry so that no one else will poke at it.
> >   */
> > -static bool irq_work_claim(struct irq_work *work)
> > +static void irq_work_claim(struct irq_work *work)
> >  {
> >  	unsigned long flags, nflags;
> >  
> >  	for (;;) {
> >  		flags = work->flags;
> >  		if (flags & IRQ_WORK_PENDING)
> > -			return false;
> > +			return;
> >  		nflags = flags | IRQ_WORK_FLAGS;
> >  		if (cmpxchg(&work->flags, flags, nflags) == flags)
> >  			break;
> >  		cpu_relax();
> >  	}
> >  
> > -	return true;
> > +	return;
> >  }
> >  
> >  void __weak arch_irq_work_raise(void)
> > @@ -79,15 +79,14 @@ static void __irq_work_queue(struct irq_work *work)
> >   *
> >   * Can be re-enqueued while the callback is still in progress.
> >   */
> > -bool irq_work_queue(struct irq_work *work)
> > +void irq_work_queue(struct irq_work *work)
> >  {
> > -	if (!irq_work_claim(work)) {
> > -		/*
> > -		 * Already enqueued, can't do!
> > -		 */
> > -		return false;
> > -	}
> > -
> > +	/*
> > +	 * This function either will claim the entry to queue
> > +	 * the work or if the work is already queued and is in
> > +	 * pending state then it will simply return.
> > +	 */
> > +	irq_work_claim(work)
> 
> Um, no.
> 
> If the state was already pending, we will corrupt the llist node of the
> work if we call irq_work_queue(). You must check the return value of
> irq_work_claim() and return if it fails. You can not call
> __irq_work_queue() if irq_work_claim() does not succeed.
> 
> The return value of irq_work_queue() can be ignored, but not
> irq_work_claim().
Oh I didn't see that logic properly and rightly pointed out by you, we
should _just_ return instead of queuing the work if the state was
already pending.
> 
> -- Steve
> 
> >  	__irq_work_queue(work);
> >  	return true;
> >  }
> 
> 



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

end of thread, other threads:[~2012-10-31 14:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-31 14:02 [PATCH] [RFC]IRQ CORE: irq_work_queue function return value not used anish kumar
2012-10-31 14:09 ` Pallala, Ramakrishna
2012-10-31 14:15 ` Steven Rostedt
2012-10-31 14:36   ` anish kumar

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®