From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 339A4C2D0EB for ; Sun, 29 Mar 2020 03:00:15 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08E6520717 for ; Sun, 29 Mar 2020 03:00:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="nEBs34CU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08E6520717 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B293210FC362D; Sat, 28 Mar 2020 20:01:04 -0700 (PDT) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=willy@infradead.org; receiver= Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8CB3B1003E9A2 for ; Sat, 28 Mar 2020 20:01:02 -0700 (PDT) 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 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-Disposition: inline In-Reply-To: <20200329025617.GT22483@bombadil.infradead.org> Message-ID-Hash: 7HAMMAF4GSMUA4ZNU46MLKF4GW2JK4KC X-Message-ID-Hash: 7HAMMAF4GSMUA4ZNU46MLKF4GW2JK4KC X-MailFrom: willy@infradead.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: "Aneesh Kumar K . V" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman , 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 X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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. _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EAF2C43331 for ; Sun, 29 Mar 2020 03:00:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E8D0206DB for ; Sun, 29 Mar 2020 03:00:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="nEBs34CU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727191AbgC2DAK (ORCPT ); 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. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8111EC43331 for ; Sun, 29 Mar 2020 03:02:04 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E161206DB for ; Sun, 29 Mar 2020 03:02:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="nEBs34CU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E161206DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48qgNm6RWSzDqhR for ; Sun, 29 Mar 2020 14:02:00 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=willy@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=nEBs34CU; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48qgLh11h5zDqWJ for ; Sun, 29 Mar 2020 14:00:12 +1100 (AEDT) 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 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> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Madhavan Srinivasan , Alexey Kardashevskiy , Masahiro Yamada , Oliver O'Halloran , Mauro Carvalho Chehab , Ira Weiny , Thomas Gleixner , Rob Herring , Dave Jiang , linux-nvdimm@lists.01.org, "Aneesh Kumar K . V" , Krzysztof Kozlowski , Anju T Sudhakar , Mahesh Salgaonkar , Andrew Donnellan , Arnd Bergmann , Greg Kurz , Nicholas Piggin , =?iso-8859-1?Q?C=E9dric?= Le Goater , Dan Williams , Hari Bathini , linux-mm@kvack.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Vishal Verma , Frederic Barrat , Paul Mackerras , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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.