From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753401AbaCLKMx (ORCPT ); Wed, 12 Mar 2014 06:12:53 -0400 Received: from smtp03.stone-is.org ([87.238.162.6]:35423 "EHLO smtpgw.stone-is.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbaCLKMw (ORCPT ); Wed, 12 Mar 2014 06:12:52 -0400 X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network Message-ID: <5320331F.7060601@acm.org> Date: Wed, 12 Mar 2014 11:12:47 +0100 From: Bart Van Assche User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Jens Axboe CC: Alexander Gordeev , Kent Overstreet , Shaohua Li , Mike Christie , linux-kernel Subject: [PATCH v2] percpu_ida: Handle out-of-tags gracefully X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wait until a tag becomes available instead of giving up when running out of tags temporarily. This patch fixes the following kernel bug: ------------[ cut here ]------------ kernel BUG at lib/percpu_ida.c:81! invalid opcode: 0000 [#1] SMP RIP: 0010:[] [] percpu_ida_alloc+0x33e/0x370 Call Trace: [] blk_mq_get_tag+0x2f/0x50 [] blk_mq_alloc_rq.isra.17+0x1c/0x90 [] blk_mq_alloc_request_pinned+0x9b/0x110 [] blk_mq_make_request+0x426/0x480 [] generic_make_request+0xc0/0x110 [] submit_bio+0x6b/0x140 [] _submit_bh+0x13b/0x220 [] block_read_full_page+0x1ff/0x300 [] blkdev_readpage+0x18/0x20 [] __do_page_cache_readahead+0x277/0x280 [] force_page_cache_readahead+0x8d/0xc0 [] page_cache_sync_readahead+0x4b/0x50 [] generic_file_aio_read+0x4c5/0x700 [] blkdev_aio_read+0x4b/0x70 [] do_sync_read+0x5a/0x90 [] vfs_read+0x9b/0x160 [] SyS_read+0x49/0xa0 [] tracesys+0xd0/0xd5 ---[ end trace cdd1a8a7968266cf ]--- Signed-off-by: Bart Van Assche Cc: Alexander Gordeev CC: Jens Axboe Cc: Kent Overstreet Cc: Shaohua Li Cc: Christoph Hellwig Cc: Mike Christie --- 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 93d145e..56b5067 100644 --- a/lib/percpu_ida.c +++ b/lib/percpu_ida.c @@ -73,7 +73,7 @@ static inline void steal_tags(struct percpu_ida *pool, if (cpu >= nr_cpu_ids) { cpu = cpumask_first(&pool->cpus_have_tags); if (cpu >= nr_cpu_ids) - BUG(); + break; } pool->cpu_last_stolen = cpu; -- 1.8.4.5