Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4587289imm; Wed, 30 May 2018 08:16:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL3gnuGgmNcMKIlECtpfVvoA0VfOOz1SklNwclM2xUQmaKo78I9ZjCv3v+Vn+u0Ng0CmDHf X-Received: by 2002:a63:a84f:: with SMTP id i15-v6mr2639773pgp.422.1527693391871; Wed, 30 May 2018 08:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527693391; cv=none; d=google.com; s=arc-20160816; b=kLXv0+1qhC+yK3sho7HyBmwanUsNS0taqASiCHwm9NHUy4bClWUVCJxmzpdnTMnABl uOaqqxXyjUNnO8jAQsbNUxGgqfXz7GuGTYDq0kDlecfQjIKWO8i7BY23+rItx5E9zeAM 4/6ImOfMcnsIcqdZQ8us2NgfTuOJFqdKALcv4iVwy7+08bgSDeU5aBAWntZoPRymifMt 2qWZMeKt9E0d5p9WTKuTq2Ldt9beeYNibWCZ1bV0J5xVfWBJgk+xb8JzkUe+mOOtvD1G HC33rErxSIEzSFnCr2qZtjhJiaqiZAsWRuZKzOrfbxN7oWiXbdHbNGvRrfIAXKL8nqS6 XBxw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=RhhoDbpYwKujplMTuadF8QmUJg+JQZw3rjfpLbGy5HU=; b=shbwJqoeECmZnt+fvo6TzhDCkjQzlV3wdc8bCSuceK502y6Furghl69rUGbMgNFT+b ZHYwMgxoVbldkoYM6NoAujyxVaGLS3HP7Ef2xRYb9L60RJjgFs8bG5PoJpUt3zEjo8Xj efXkf8qoiuFwQE9qV9y5bfboVQirmXK83F62vyWL33D245wte+oy1CHxFas90jWyHhqr 3BLsVGhAMLCFeWatDcBlKKTL0jKXK/QCJF0F0ipvVHxGFFuz7bNCqgza05tFYaafTF2I 88dYGJlr5Wz9JroaS/grc4UxIHtyk+WFgHdZRd023V4MAWw9pYtP1G0pjFJuKlNKhwXe ro8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=MVZzjP7f; 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 p1-v6si34716180pfe.158.2018.05.30.08.16.17; Wed, 30 May 2018 08:16:31 -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=pass header.i=@ziepe.ca header.s=google header.b=MVZzjP7f; 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 S1753276AbeE3PPx (ORCPT + 99 others); Wed, 30 May 2018 11:15:53 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43640 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750990AbeE3PPt (ORCPT ); Wed, 30 May 2018 11:15:49 -0400 Received: by mail-pf0-f194.google.com with SMTP id j20-v6so9182246pff.10 for ; Wed, 30 May 2018 08:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=RhhoDbpYwKujplMTuadF8QmUJg+JQZw3rjfpLbGy5HU=; b=MVZzjP7fltEjrhgwvOKxasb5VrCHq+fdJfbXB+ObqCWilvryZIuWp8ybJ9qMDbjAch GBxtV61hGfBu3gQK9hPgM7jmPikjRbzRE6sbEJTkQkT9duizOs5RfY/c2nx/YhlVkegr VX2t1j0YIJqOTaDdHsJHtNStI7apcnqS3X5V94liXZjcchjiu3r5nC8p01T5ubHZxNxV bBBCm9ZkgTjqmPtGx0LAjC6AF93IvpSyR1b6Y+iVD5NB+wpllgA74jW5Ih9x0bytZ4Rx ZnlDxCU+CbqS3qqRWXr/Ms0gY1L5eL0L6bpZ8djeUmKhSfN7/wGMlM+21XBly7BTj3UX B2UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=RhhoDbpYwKujplMTuadF8QmUJg+JQZw3rjfpLbGy5HU=; b=N6ELSFwr1fPkWxVpUA2Ev1ZaXS71ETCmikZAnr0rsQIA6sGUMvILKdAOLvYo92pLa8 9KQx0TMpncxdisXR3hc+aZBDUXeWd3g1WRh1/VHEerhP+pBNKBMc6chWPmxtxCNo9+wY 1S3JGmTnFvLKASWSD/v6RjcWTftQbFY2uyUDJoj4h6EEExHkThXIMBTajrpbucStRvyO SS9yjubx2a41RYgpHQvbzkTZkvHc6WXtQN8FI4aR2hLYQzftWsQK8BDStqfuMjzjOXNa h2/NMCnSmctlqPY5Bm78aitK7MdJfMZJ9EY8wSBqGmoli2cpxP0B1YqbKKKAVeBJdcwB udcQ== X-Gm-Message-State: ALKqPwd4he7kpw+xlnXxfJdKSlLsjpmJkzvtCLrpfZh5DqqnHseruHh2 oP5lj79NyBhJRSgQho4o5bQQAw== X-Received: by 2002:a63:67c4:: with SMTP id b187-v6mr2385040pgc.86.1527693348865; Wed, 30 May 2018 08:15:48 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id 29-v6sm8846422pfp.24.2018.05.30.08.15.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 08:15:48 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1fO2pH-0008DX-OQ; Wed, 30 May 2018 09:15:47 -0600 Date: Wed, 30 May 2018 09:15:47 -0600 From: Jason Gunthorpe To: =?utf-8?B?SMOla29u?= Bugge Cc: Hans Westgaard Ry , Doug Ledford , Jack Morgenstein , Daniel Jurgens , Parav Pandit , Pravin Shedge , OFED mailing list , linux-kernel@vger.kernel.org Subject: Re: [PATCH] IB/mad: Use ID allocator routines to allocate agent number Message-ID: <20180530151547.GC30754@ziepe.ca> References: <20180529073808.27735-1-hans.westgaard.ry@oracle.com> <20180529154922.GA18457@ziepe.ca> <20180529164032.GB18457@ziepe.ca> <0E56560E-F577-43A6-9F18-B7AC7B5DB213@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0E56560E-F577-43A6-9F18-B7AC7B5DB213@oracle.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 30, 2018 at 09:32:02AM +0200, Håkon Bugge wrote: > > > > On 29 May 2018, at 18:40, Jason Gunthorpe wrote: > > > > On Tue, May 29, 2018 at 06:16:14PM +0200, Håkon Bugge wrote: > >> > >>> On 29 May 2018, at 17:49, Jason Gunthorpe wrote: > >>> > >>> On Tue, May 29, 2018 at 09:38:08AM +0200, Hans Westgaard Ry wrote: > >>>> The agent TID is a 64 bit value split in two dwords. The least > >>>> significant dword is the TID running counter. The most significant > >>>> dword is the agent number. In the CX-3 shared port model, the mlx4 > >>>> driver uses the most significant byte of the agent number to store the > >>>> slave number, making agent numbers greater and equal to 2^24 (3 bytes) > >>>> unusable. > >>> > >>> There is no reason for this to be an ida, just do something like > >>> > >>> mad_agent_priv->agent.hi_tid = atomic_inc_return(&ib_mad_client_id) & mad_agent_priv->ib_dev->tid_mask; > >>> > >>> And have the driver set tid_mask to 3 bytes of 0xFF > >> > >> The issue is that some of the mad agents are long-lived, so you will > >> wrap and use the same TID twice. > > > > We already have that problem, and using ida is problematic because we > > need to maximize the time between TID re-use, which ida isn't doing. > > Initially, I thought that too, but consulted the spec which states: > > C13-18.1.1: When initiating a new operation, MADHeader:TransactionID > shall be set to such a value that within that MAD the combination of TID, > SGID, and MgmtClass is different from that of any other currently executing > operation. [] > > "currently executing operation" that is. 'currently executing operation' encompasses a wide range of behaviors and it is not just 'completing the MAD at the local node' You have to exceed all the timeouts before a single node can be certain that the condition is satisfied. This is why we just simply maximize the time between allocations, and encourage the user providing the rest of the tid to do the same. > > Preventing re-use seems like a seperate issue from limiting the range > > to be compatible with mlx4. > > Yes. But a v2 of Hans' patch using idr_alloc_cyclic() solves both issues. That might work, but still have to get rid of the sysctl Jason