Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1141009ybb; Sat, 28 Mar 2020 19:58:37 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtWJdgLgHMfb2YeoZidycVwWLsKoj5dapzDaN/AJvH5jUYy57MWGHHKNyGcKMuZJJ0TwgYy X-Received: by 2002:a9d:2963:: with SMTP id d90mr4337927otb.149.1585450716914; Sat, 28 Mar 2020 19:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585450716; cv=none; d=google.com; s=arc-20160816; b=XUiEvzJ1bhpWnwQFeNHXoVlxxf6vuQsa8Ms2ckPFGXPB/7cERCwFFhyUpFQLghU/HY jce4h2wYUQ2AbY0IyFkc2RlNGYPpjJlwu4ZirmpdvxAIb6ZVslEbEwWGgv5WuJOamasL iqJkJw32UUhNw+UsNYKsZY9yvLoeubqhbla5WaHtQhoFu19kZKqOwSSzcFxbMJM4xeSH 0V/DUo15NPsFHNfaQjLTFnGuIrlqH90DChclR+0BrKZFD2MoPItKIAdniz8vZiP0cd1i 54fyc4XiHeKatHy1YxQQDKc89k8FKEio6UTnRrrXz/CXhIbCbtWoK+XSp2b6XAE8ZXUr e7Dw== 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=4yXTPf18akGL4F1+3ogioOkX9iKPvYO8hyOrfJXVtE8=; b=UHA0qVVeTCPfdUbK5qOw8REaAmQBWodGLl1DsLK3Oem3z2qDGJ34CjbwnDfeocRW1I FV8NmT3Xh8qu7fIv+Sgz7Q8MQm5jzNpXagH1u+YarF4rFHirG/aScERpS/cdn5opt6sJ qQSt2vuUMhhm/eptfwLikpIkqDKW6hHK2TfTdktz9Krl6bTwF8h+NOASoU3dlsNtHrRn weMsLVNE3341oX4+JnV1LIdPNeyHca9P6f8XSvdUjZa8egzrohck+jGgXfwtWn6M0f0A a28gLxg2sWDCSdvVUJSGL9ZD1kft+biQX/IDmahE/8BbakJ+nymVB3LsdC8x5YNuGSB3 OWpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=JQUR5R0l; 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 x13si4386244oto.105.2020.03.28.19.58.24; Sat, 28 Mar 2020 19:58:36 -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=JQUR5R0l; 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 S1727028AbgC2C5B (ORCPT + 99 others); Sat, 28 Mar 2020 22:57:01 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57992 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgC2C5B (ORCPT ); Sat, 28 Mar 2020 22:57:01 -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=4yXTPf18akGL4F1+3ogioOkX9iKPvYO8hyOrfJXVtE8=; b=JQUR5R0lE7xi/bwp2+wCOJ6n+2 jr/hNpXfA6Sap1y57jeS+TIIvZ50P9Y0zhfobUFlky6zEHnrl36iUVGituZcetweLxImlDgR+0iir d3QCGnZfRnPVOSoC/nsRLR2bhPsiB+W2w8sFoZ77juMrW4OGkTFvQUvqhPA08FEK7I5Eg97c5tGib Zw7dB5t65kxfGeoY0SAo/6dRwhdi9zSLhZhYeBRJ2LSRPBWI8gvyMpqmHcCHQ0sWsQbZXQvsWH/mT 6hETfSx0PyDhWRS+X/9G+thvPoa8q1ZMjK5EVIvLqln8TC7mmm8ZUKLOFxK9rhl7dENKu5keZOLVK thM8OiZQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jIO7V-00020F-KY; Sun, 29 Mar 2020 02:56:17 +0000 Date: Sat, 28 Mar 2020 19:56:17 -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: <20200329025617.GT22483@bombadil.infradead.org> References: <20200327071202.2159885-1-alastair@d-silva.org> <20200327071202.2159885-11-alastair@d-silva.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200327071202.2159885-11-alastair@d-silva.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); ... ida_free(&minors, MINOR(ocxlpmem->dev.devt)); ... and you can drop the dynamic initialisation. And the mutex.