All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/percpu_ida.c: don't do alloc from per-CPU list if there is none
@ 2018-06-13  7:58 Sebastian Andrzej Siewior
  2018-06-13  9:43 ` David Disseldorp
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-06-13  7:58 UTC (permalink / raw)
  To: target-devel

In commit 804209d8a009 ("lib/percpu_ida.c: use _irqsave() instead of
local_irq_save() + spin_lock") I inlined alloc_local_tag() and mixed up
the >= check from percpu_ida_alloc() with the one in alloc_local_tag().

Don't alloc from per-CPU freelist if ->nr_free is zero.

Fixes: 804209d8a009 ("lib/percpu_ida.c: use _irqsave() instead of local_irq_save() + spin_lock")
Reported-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---

David, could please check if this works for you?

 lib/percpu_ida.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c
index 9bbd9c5d375a..beb14839b41a 100644
--- a/lib/percpu_ida.c
+++ b/lib/percpu_ida.c
@@ -141,7 +141,7 @@ int percpu_ida_alloc(struct percpu_ida *pool, int state)
 	spin_lock_irqsave(&tags->lock, flags);
 
 	/* Fastpath */
-	if (likely(tags->nr_free >= 0)) {
+	if (likely(tags->nr_free)) {
 		tag = tags->freelist[--tags->nr_free];
 		spin_unlock_irqrestore(&tags->lock, flags);
 		return tag;
-- 
2.17.1


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

* Re: [PATCH] lib/percpu_ida.c: don't do alloc from per-CPU list if there is none
  2018-06-13  7:58 [PATCH] lib/percpu_ida.c: don't do alloc from per-CPU list if there is none Sebastian Andrzej Siewior
@ 2018-06-13  9:43 ` David Disseldorp
  0 siblings, 0 replies; 2+ messages in thread
From: David Disseldorp @ 2018-06-13  9:43 UTC (permalink / raw)
  To: target-devel

On Wed, 13 Jun 2018 09:58:30 +0200, Sebastian Andrzej Siewior wrote:

> In commit 804209d8a009 ("lib/percpu_ida.c: use _irqsave() instead of
> local_irq_save() + spin_lock") I inlined alloc_local_tag() and mixed up
> the >= check from percpu_ida_alloc() with the one in alloc_local_tag().
> 
> Don't alloc from per-CPU freelist if ->nr_free is zero.
> 
> Fixes: 804209d8a009 ("lib/percpu_ida.c: use _irqsave() instead of local_irq_save() + spin_lock")
> Reported-by: David Disseldorp <ddiss@suse.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> 
> David, could please check if this works for you?

Works for me. Thanks for the quick fix, Sebastian.

Cheers, David

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

end of thread, other threads:[~2018-06-13  9:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-13  7:58 [PATCH] lib/percpu_ida.c: don't do alloc from per-CPU list if there is none Sebastian Andrzej Siewior
2018-06-13  9:43 ` David Disseldorp

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.