From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936813AbcCQUl3 (ORCPT ); Thu, 17 Mar 2016 16:41:29 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:36792 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932357AbcCQUlZ (ORCPT ); Thu, 17 Mar 2016 16:41:25 -0400 Subject: Re: 4.5.0+ panic when setup loop device To: Thomas Gleixner References: <20160317095220.GO6344@twins.programming.kicks-ass.net> <20160317102633.GR6344@twins.programming.kicks-ass.net> <20160317115120.GT6344@twins.programming.kicks-ass.net> <56EADE5F.7000601@kernel.dk> <56EAF6CC.7070108@kernel.dk> <56EB124C.2040808@kernel.dk> Cc: Peter Zijlstra , Xiong Zhou , "linux-kernel@vger.kernel.org" , Ingo Molnar , Borislav Petkov , Andreas Herrmann From: Jens Axboe Message-ID: <56EB1672.7000002@kernel.dk> Date: Thu, 17 Mar 2016 13:41:22 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/17/2016 01:30 PM, Thomas Gleixner wrote: > On Thu, 17 Mar 2016, Jens Axboe wrote: >> On 03/17/2016 01:20 PM, Thomas Gleixner wrote: >>>> This might be better, we need to start at -1 to not miss the first one... >>>> Still untested. >>> >>>> +static inline struct blk_mq_ctx *next_ctx(struct request_queue *q, int >>>> *i) >>>> +{ >>>> + do { >>>> + (*i)++; >>>> + if (*i < q->nr_queues) { >>>> + if (cpu_possible(*i)) >>>> + return per_cpu_ptr(q->queue_ctx, *i); >>>> + continue; >>>> + } >>>> + break; >>>> + } while (1); >>>> + >>>> + return NULL; >>>> +} >>>> + >>>> +#define queue_for_each_ctx(q, ctx, i) >>>> \ >>>> + for ((i) = -1; (ctx = next_ctx((q), &(i))) != NULL;) >>>> + >>> >>> What's wrong with >>> >>> for_each_possible_cpu(cpu) { >>> ctx = per_cpu_ptr(q->queue_ctx, cpu); >>> >>> .... >>> } >>> >>> instead of hiding it behind an incomprehensible macro mess? >> >> We might not have mapped all of them. > > blk_mq_init_cpu_queues() tells a different story and q->queue_ctx is a per_cpu > allocation. Yeah my bad, I mistook the possible for online. So we can do the easier fix. -- Jens Axboe