Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2404imm; Tue, 12 Jun 2018 17:12:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKV/uce6uFbVR3lxjmeNx8Phk3WjPQEh9r2NZeftnlZJyaNCP8J4HILvLbaCQ1xLH2jMKv2 X-Received: by 2002:a62:8d5:: with SMTP id 82-v6mr2558536pfi.154.1528848759125; Tue, 12 Jun 2018 17:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528848759; cv=none; d=google.com; s=arc-20160816; b=kx5TeNm7Sdd7JjTMlQESWcpezUeQF5eJhjfgQBK37R7u4v4Q9f217/6exKq9QXmiFD +OnL3XyG97efJHGQDXEqYxkSxlrDCqhTKq5nACF1d9XJlmKRvV2SBLsIL1CvURpPFqjU S+ld02JoHWpKKtzU18cYpGosNIsh2IrqtXQCIiq6ZNzhAt4gLVsY4MlpcEU4BsvzDoGr 3M1ZKEdzR400qqsixnKTpAHHhhcJ9URvZgntw197OZbGByzZjiPJPYb0kdQtJ2mNpb66 4EXb8/1b1wxL8Cut5dcVVlg1fXX0obSdb/3jhBHdI3Oh95qZ758w4AQWlwiPgThMDu3A WHnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=mm+TnLSfW7zHU2HGoOrzIBekoPWYa6NwfU1DYMo3DsQ=; b=GgJ3RgZ+GSx4j8Nf2fyh6h5IVJ7ODgYUnmc8HU7XUit0qYHeSgF0UbOQkjjQ6C4zpQ MWqikNEOoyFufyDuEKTKnhzBxW7dePR5ApZlkMq+pRy6YZOGztkCod4GWuOY0U5s8d8k WV/l6c/7H8qWcq4puo5YV4NInSSYvHJ4wKmIYO9yeqX72AhmTWMJGvy+dwNFyg1k0MCi 8sEJw6fktSniz5F691Jy67rXu7D3CtmY0tfmIO/acwbVz+/mdDJdDhfb20l6rPT5IntY mIFkhAzkWqR2ESt3KpwmRCm5+qAye4dml4WF9zEe1kjG+PIun4/VLHNBQMke7i1sAsOr TP7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=V7Kx3cf0; 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 q7-v6si1028219pgt.556.2018.06.12.17.12.01; Tue, 12 Jun 2018 17:12:39 -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=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=V7Kx3cf0; 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 S934982AbeFMAHq (ORCPT + 99 others); Tue, 12 Jun 2018 20:07:46 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:59744 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932596AbeFMAHo (ORCPT ); Tue, 12 Jun 2018 20:07:44 -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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HX1gyr2WL2UZn+VqBNuK3kMGZItAcSEIDiLIXGQMu98=; b=V7Kx3cf0g2GUPwT9arLOTwaJm +vAsg3S6xOSy5M2CbJnvjQcEhoSKvoMH7+5Q+aR5xAdinbDtgczmVmX+6ReInuz1uL9PC+F4ZyYmh J1MlVZvo+BCE8O3l0BerwhxPukcjuNKFirKsVtrtUuhjjNCW1KNgIp3f+mRPDnDzxpO4hnMcsJL1F D+X0eW6clQxOBPZhZQPBZNiuNT2YzH4qbn5ycXn3niIxixCfzJLdhRqBVI0SCHCPRdWc7lb8pboHz h/KHKTxjMy8Mho3dgCo9DRmZS9iyFqmelm/bWpn2Ql/2SNxAIuS/RAzJinaHsOax7td4ycgVvVh3D vJPbvciKQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fStK8-0005fC-5O; Wed, 13 Jun 2018 00:07:40 +0000 Date: Tue, 12 Jun 2018 17:07:39 -0700 From: Matthew Wilcox To: Jason Gunthorpe Cc: hans.westgaard.ry@oracle.com, Doug Ledford , Matthew Wilcox , linux-rdma@vger.kernel.org, =?iso-8859-1?Q?H=E5kon?= Bugge , Parav Pandit , Jack Morgenstein , Pravin Shedge , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] IB/mad: Use IDR for agent IDs Message-ID: <20180613000739.GA32191@bombadil.infradead.org> References: <20180608174218.32455-1-willy@infradead.org> <20180608174218.32455-3-willy@infradead.org> <20180612203322.GG6314@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180612203322.GG6314@ziepe.ca> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 12, 2018 at 02:33:22PM -0600, Jason Gunthorpe wrote: > > @@ -377,13 +378,24 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, > > goto error4; > > } > > > > - spin_lock_irq(&port_priv->reg_lock); > > - mad_agent_priv->agent.hi_tid = atomic_inc_return(&ib_mad_client_id); > > + idr_preload(GFP_KERNEL); > > + idr_lock(&ib_mad_clients); > > + ret2 = idr_alloc_cyclic(&ib_mad_clients, mad_agent_priv, 0, > > + (1 << 24), GFP_ATOMIC); > > I like this series, my only concern is this magic number here, at the > very least it deserves a big comment explaining why it > exists.. Yes, you're right. Maybe something like this ... /* * The mlx4 driver uses the top byte to distinguish which virtual function * generated the MAD, so we must avoid using it. */ #define AGENT_ID_LIMIT (1 << 24) ... ret2 = idr_alloc_cyclic(&ib_mad_clients, mad_agent_priv, 0, AGENT_ID_LIMIT, GFP_ATOMIC); > Let me see if I can get someone to give it some test time, I assume > you haven't been able to test it it? I don't have any IB hardware. Frankly I'm scared of Infiniband ;-) > > +#define idr_lock(idr) xa_lock(&(idr)->idr_rt) > > +#define idr_unlock(idr) xa_unlock(&(idr)->idr_rt) > > +#define idr_lock_irq(idr) xa_lock_irq(&(idr)->idr_rt) > > +#define idr_unlock_irq(idr) xa_unlock_irq(&(idr)->idr_rt) > > +#define idr_lock_irqsave(idr, flags) \ > > + xa_lock_irqsave(&(idr)->idr_rt, flags) > > +#define idr_unlock_irqrestore(idr, flags) \ > > + xa_unlock_irqrestore(&(idr)->idr_rt, flags) > > + > > And you are Ok to take these through the rdma tree? Yes, that's fine with me; I'm not planning on merging any IDR patches this cycle. Thanks!