Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1142979ybb; Sat, 28 Mar 2020 20:02:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuHI/klA/+uN4/n8MPRUHz9BluWDR67B+fOAJ2xt+16IK1h+If90fGWtI/4kWtHr9jIhy/s X-Received: by 2002:a9d:2028:: with SMTP id n37mr4830917ota.127.1585450940347; Sat, 28 Mar 2020 20:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585450940; cv=none; d=google.com; s=arc-20160816; b=DF4or+CvgWRf8esEQTKGdrWLLct+CeVW9wn8UMANf9qd5zDIWpICXx5R1r5ERCUOlh ix22YDIhOeHwcy85K0k7IIjxtBJ7p5wQOwY4GW67hGCAHSy55gJcHZqj2OeJ76+YdxlS DiHwnV4ef3KrZugJpNMDPNJaekf+zih9vkY6XCjW2d3VmLMPIITKVGXctpYFidH3HbrV aOaFbAkm06TIUoo2i1udpAqvGKbxXSd4frnebEYDl+AkHYCy4gGIFpHqfxY9IN+Uj/vX xvsQICb1pf41F4YrJf4AshejotmmgnOHpZ6uPncxANpnU/DuvtxzWJu0tJuJKj0mFgIg IUvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=tzQQI4sPYIQBmBbwCro/n16BP95THEmRO7t6mifRML4=; b=oF0edIqmLqvD51BEGPjJG1obCRxlgRYWrcSoK/hScufwWb4hRDu/pC1qCb8ziuYH// PSxe051pKw3BHkWtlzoLoDNTqelDwTQHfTJWvQHn0a/NnoYpMPBZlPohh7U8OC1w7qiU 1PZjeOvdRCknnYquOSYYnX98doi8DVP9erxE9BNTjvjkSQ/PU8xlUei1vV2NnB7Zu0G+ FjPhOXomYbXH0IuTbz0NBMwu4Eho/pXu+R4/1vHkIVhqOdxPe7bU4ijWTulEXuZvXbBk Ce6Hh0UBoCEAOasjV9LVOaFWNmfcfzl9CJqVxNV+ZBGn+YV5nGrsdyO7DHFeZWnBs8Pj ocbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=nEBs34CU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p21si5011064oth.257.2020.03.28.20.02.08; Sat, 28 Mar 2020 20:02:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=nEBs34CU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727144AbgC2DAK (ORCPT + 99 others); Sat, 28 Mar 2020 23:00:10 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58074 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgC2DAK (ORCPT ); Sat, 28 Mar 2020 23:00:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=tzQQI4sPYIQBmBbwCro/n16BP95THEmRO7t6mifRML4=; b=nEBs34CUPbdlvIX+D+1uQ1RH24 Ej5dOZ3lLrQuut9PtYNGkXA3koeQSQDdqMsYWaMEp38KgpDHYt8XQzVxIL0+LIbI71dtFlnqUNYUI +b8YfoGgqyK7V3Q2hkO5qRe9i9vorjXPJjM783KKCNLoKzNKArwYEbKteh5/DeRV/STBoJRPsqniL vyEcyBq095i2wwMZa3rKCvmt4CciHoEdoxVj9OjEF170WeNqffsvP+GXUqd9RDH5LkA9FKVqR4F1I VHwBcBcQA7Rtrf8fWswpp038xYh+MxshHzYqQ2kP4XDg9Gu+3InwGR63sWP94CEsMbluooRi8qUR0 HrUD8Z/g==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jIOAs-0002Hp-Jl; Sun, 29 Mar 2020 02:59:46 +0000 Date: Sat, 28 Mar 2020 19:59:46 -0700 From: Matthew Wilcox To: Alastair D'Silva Cc: "Aneesh Kumar K . V" , Oliver O'Halloran , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Andrew Morton , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Anton Blanchard , Krzysztof Kozlowski , Mahesh Salgaonkar , Madhavan Srinivasan , =?iso-8859-1?Q?C=E9dric?= Le Goater , Anju T Sudhakar , Hari Bathini , Thomas Gleixner , Greg Kurz , Nicholas Piggin , Masahiro Yamada , Alexey Kardashevskiy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org Subject: Re: [PATCH v4 10/25] nvdimm: Add driver for OpenCAPI Persistent Memory Message-ID: <20200329025946.GU22483@bombadil.infradead.org> References: <20200327071202.2159885-1-alastair@d-silva.org> <20200327071202.2159885-11-alastair@d-silva.org> <20200329025617.GT22483@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200329025617.GT22483@bombadil.infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 28, 2020 at 07:56:17PM -0700, Matthew Wilcox wrote: > On Fri, Mar 27, 2020 at 06:11:47PM +1100, Alastair D'Silva wrote: > > +static struct mutex minors_idr_lock; > > +static struct idr minors_idr; > ... > > + mutex_lock(&minors_idr_lock); > > + minor = idr_alloc(&minors_idr, ocxlpmem, 0, NUM_MINORS, GFP_KERNEL); > > + mutex_unlock(&minors_idr_lock); > ... > > + mutex_lock(&minors_idr_lock); > > + idr_remove(&minors_idr, MINOR(ocxlpmem->dev.devt)); > > + mutex_unlock(&minors_idr_lock); > ... > > + mutex_init(&minors_idr_lock); > > + idr_init(&minors_idr); > > Unless you look up ocxlpmem by minor number later in the patch series (and > most of the series didn't make it to my mailbox), this can just be an ida. > > static DEFINE_IDA(minors); > ... > minor = ida_alloc_max(&minors, NUM_MINORS, GFP_KERNEL); Oops. NUM_MINORS - 1. Or #define MAX_MINOR 255 since you only seem to use NUM_MINORS in this one place. > ... > ida_free(&minors, MINOR(ocxlpmem->dev.devt)); > ... > and you can drop the dynamic initialisation. And the mutex.