diff mbox

lib/percpu_ida.c: don't do alloc from per-CPU list if there is none

Message ID 20180613075830.c3zeva52fuj6fxxv@linutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Sebastian Andrzej Siewior June 13, 2018, 7:58 a.m. UTC
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(-)

Comments

David Disseldorp June 13, 2018, 9:43 a.m. UTC | #1
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
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;