From patchwork Wed Jun 13 07:58:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 10461831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 211816020A for ; Wed, 13 Jun 2018 07:58:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1824428A1E for ; Wed, 13 Jun 2018 07:58:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B38428A21; Wed, 13 Jun 2018 07:58:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E3FF28A1E for ; Wed, 13 Jun 2018 07:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933657AbeFMH6e (ORCPT ); Wed, 13 Jun 2018 03:58:34 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:43593 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754467AbeFMH6e (ORCPT ); Wed, 13 Jun 2018 03:58:34 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1fT0fm-0002ux-N5; Wed, 13 Jun 2018 09:58:30 +0200 Date: Wed, 13 Jun 2018 09:58:30 +0200 From: Sebastian Andrzej Siewior To: David Disseldorp Cc: target-devel@vger.kernel.org, Bart Van Assche , "Nicholas A. Bellinger" , tglx@linutronix.de, Andrew Morton Subject: [PATCH] lib/percpu_ida.c: don't do alloc from per-CPU list if there is none Message-ID: <20180613075830.c3zeva52fuj6fxxv@linutronix.de> References: <20180613001220.137a9d28@suse.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180613001220.137a9d28@suse.de> User-Agent: NeoMutt/20180512 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Sebastian Andrzej Siewior --- 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;