Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4887251imm; Mon, 11 Jun 2018 22:00:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL5ljDJgsa6eZJ/v87ngs2jUbN+pTn7d77r/Fo45De3t8oXYk75nnCUg4rM2PBhz0ZLedvE X-Received: by 2002:a63:8dca:: with SMTP id z193-v6mr1791716pgd.451.1528779643791; Mon, 11 Jun 2018 22:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528779643; cv=none; d=google.com; s=arc-20160816; b=L9FwDW1OQgEgaAAfpRI730aHageRWXHC1LvSmRGRta7ufMkAWfMCnAXV5PDMEQcdeG H1SbnORSO56QjKFRUtcbppC3Z4dAiIINcIB74902ls+d6OnJxzlEDQUKgLyK3wHhk0hd Fqut1fBwq9uLDtFngiZdg9Xczb/HS2deyo7GB+iv5TGvGRhXcyZgWHUNZPllDiqCPZ9j wmvgRF8OJBdH+q19rUyTzth2vb1GkXcn9jk9b/mlBVZbI0YJfLfoG+86vHna/zuZp4Q7 Q08WvxKrrLy7F+6MyYiKHHz5jeAzPGFkTO0W1f17q+ONDHt8e0WHdiVIVfsavA5Vx/CF Jf5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature:arc-authentication-results; bh=Pxl8hyQgwEHhkrm6gi05tW8HT/vtA7BdpXPFVQNcNWs=; b=gVkJDWN5n7mYAGX6rq89bZRbXMfRRKh7nAtScTvDO2xzDGTl/Uzm2tLxc+E2Bjii3q 8kcdwSsr88v/ubTytqIOEcv3XC64swuImyvc1fxzHO9lp6TvQo3OzDdgEbqP60XH6OfI SFKAjuX7Hh3kQJIL+ooUkllqbmBPxKv2OA3UPOiZJuYCXTIloOOHTUCBXoCHl3GWKiEV xrRx5xo2M+tuSLzmToeJr+onO0RNKoxkQpR1kUzlQ2RJk4IQx1eXNUjiNV4EsZ+RJkj+ +rG9u4NCQjzLW2rRCM6g2A7+70PsK0Ab3XhhrHKywUZC9nmR9GvGF+z4yLK2znxe5cUc 1+Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dev-mellanox-co-il.20150623.gappssmtp.com header.s=20150623 header.b=yI44WtEK; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.co.il Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si15381043pfc.312.2018.06.11.22.00.28; Mon, 11 Jun 2018 22:00:43 -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=@dev-mellanox-co-il.20150623.gappssmtp.com header.s=20150623 header.b=yI44WtEK; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.co.il Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932357AbeFLE7t (ORCPT + 99 others); Tue, 12 Jun 2018 00:59:49 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:34122 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753423AbeFLE7r (ORCPT ); Tue, 12 Jun 2018 00:59:47 -0400 Received: by mail-wr0-f194.google.com with SMTP id a12-v6so22557712wro.1 for ; Mon, 11 Jun 2018 21:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=Pxl8hyQgwEHhkrm6gi05tW8HT/vtA7BdpXPFVQNcNWs=; b=yI44WtEKYq6tiV+Pk1faIwSu2LgMMp9V73vpVsnflSAXamW0cK5vXodpsnXQu25G2L iSg0AQakxTQ4ygOKHim8Wf+x4JSqelJ9oE2jIiZZ06SfzgyRv/eNwYj+ahTjvDWQThar LUT1zxQWYhOJuUUQujWPjOUmWVsBSpDlgbq8dvIqpkb+lom3fwY1qK5HTf5pkH8zCGx6 NScR85AAb5RFxzBzwd6WAEzk9kix2C+t0ANFHuuyI2aRcOQhxjBCkNSttTZbFQV5/GHB l/tDlLDTyr1sZhrziC31oCiGpH7BJK0UIdApPltBrLR3DD9kTDk3uwGaI4SHf3DGkc9m NiJQ== 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:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=Pxl8hyQgwEHhkrm6gi05tW8HT/vtA7BdpXPFVQNcNWs=; b=D6llYnBw24B/Y7CCnzeHzKj+TRqzkiLhtNlQNJemFXlyXS+Q4UQakvlZluhplQblqo i8xqmznQqwaO0IbtuenAsI2rX6zMC5yjhNH/TJTwa7XoJn0DR4M9SnrsOXuvstINBiRI XJJRv7W2DiyAMGZ0IG1KOyjccsQnJ11mcm1iLj3n4/Vvy7z1rhlYtSudg8u4ZqTylYFy WdL+pOMV+lzbKr2cJ+Ctc4yv7pLsCiLQtPDApjVINTo/3F1H9ecWVPKKSDr570qXjZ+k xy7t8h18xD0cCgHU/8ZaEYDQJ57Kta7fMKLXgH2x0LwxcU7gjO/ktx1eQwcev04+vH7c 4c6g== X-Gm-Message-State: APt69E0Nw9qrBU1Ai3ECf3Cn0UZCuktmG60VA7hN1Nko906h+5fDFE+B hgaPACKpdQ20qbBgkOLOTcb2bA== X-Received: by 2002:adf:a0aa:: with SMTP id m39-v6mr1228827wrm.125.1528779586369; Mon, 11 Jun 2018 21:59:46 -0700 (PDT) Received: from localhost ([141.226.165.75]) by smtp.gmail.com with ESMTPSA id i76-v6sm373984wmd.20.2018.06.11.21.59.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 21:59:45 -0700 (PDT) Date: Tue, 12 Jun 2018 07:59:42 +0300 From: jackm To: Jason Gunthorpe Cc: Leon Romanovsky , Matthew Wilcox , hans.westgaard.ry@oracle.com, Doug Ledford , Matthew Wilcox , linux-rdma@vger.kernel.org, =?ISO-8859-1?Q?H=E5kon?= Bugge , Parav Pandit , Pravin Shedge , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] IB/mad: Use IDR for agent IDs Message-ID: <20180612075942.00005061@dev.mellanox.co.il> In-Reply-To: <20180611161918.GF5815@mellanox.com> References: <20180608174218.32455-1-willy@infradead.org> <20180608174218.32455-3-willy@infradead.org> <20180610063028.GH12407@mtr-leonro.mtl.com> <20180610104305.GA9284@bombadil.infradead.org> <20180610122505.GM12407@mtr-leonro.mtl.com> <20180610203027.GF5560@mellanox.com> <20180611043425.GA21382@mtr-leonro.mtl.com> <20180611044203.GA32562@mellanox.com> <20180611091914.00007858@dev.mellanox.co.il> <20180611161918.GF5815@mellanox.com> Organization: Mellanox X-Mailer: Claws Mail 3.15.0 (GTK+ 2.24.31; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Jun 2018 10:19:18 -0600 Jason Gunthorpe wrote: > On Mon, Jun 11, 2018 at 09:19:14AM +0300, jackm wrote: > > On Sun, 10 Jun 2018 22:42:03 -0600 > > Jason Gunthorpe wrote: > > > > > Er, the spec has nothing to do with this. In Linux the TID is made > > > unique because the core code provides 32 bits that are unique and > > > the user provides another 32 bits that are unique. The driver > > > cannot change any of those bits without risking non-uniquenes, > > > which is exactly the bug mlx4 created when it stepped outside its > > > bounds and improperly overrode bits in the TID for its own > > > internal use. > > > > Actually, the opposite is true here. When SRIOV is active, each VM > > generates its *own* TIDs -- with 32 bits of agent number and 32 bits > > of counter. > > And it does it while re-using the LRH of the host, so all VMs and the > host are now forced to share a TID space, yes I know. > > > There is a chance that two different VMs can generate the same TID! > > Encoding the slave (VM) number in the packet actually guarantees > > uniqueness here. > > Virtualizing the TID in the driver would be fine, but it must > virtualize all the TIDs (even those generated by the HOST). It DOES do so. The host slave id is 0. Slave numbers start with 1. If the MS byte contains a zero after paravirtualization, the MAD was sent by the host. In fact, ALL mads are paravirtualized -- including those to/from the host. > > Just blindly assuming the host doesn't generate TID's that overlap > with the virtualization process is a bug. > Not the case, host mads are also paravirtualized. > > There is nothing wrong with modifying the TID in a reversible way in > > order to: a. guarantee uniqueness b. identify the VM which should > > receive the response packet > > Sure, as long as *all* TID's sharing a LRH are vitalized like this. > > > The problem was created when the agent-id numbers started to use the > > most-significant byte (thus making the MSB slave-id addition > > impossible). > > It hasn't always been this way? What commit? > Commit: 37bfc7c1e83f1 ("IB/mlx4: SR-IOV multiplex and demultiplex MADs"): Code snippet which replaces the MS byte is below (file drivers/infiniband/hw/mlx4/mad.c, procedure mlx4_ib_multiplex_mad() ). Just an aside: Oracle noted the problem on the *host*: The host's message log contained the warning issued on line 1529, with slave=0 (which is the hypervisor). 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1519) switch (tunnel->mad.mad_hdr.method) { 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1520) case IB_MGMT_METHOD_SET: 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1521) case IB_MGMT_METHOD_GET: 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1522) case IB_MGMT_METHOD_REPORT: 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1523) case IB_SA_METHOD_GET_TABLE: 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1524) case IB_SA_METHOD_DELETE: 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1525) case IB_SA_METHOD_GET_MULTI: 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1526) case IB_SA_METHOD_GET_TRACE_TBL: 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1527) slave_id = (u8 *) &tunnel->mad.mad_hdr.tid; 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1528) if (*slave_id) { 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1529) mlx4_ib_warn(ctx->ib_dev, "egress mad has non-null tid msb:%d " 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1530) "class:%d slave:%d\n", *slave_id, 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1531) tunnel->mad.mad_hdr.mgmt_class, slave); 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1532) return; 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1533) } else 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1534) *slave_id = slave; 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1535) default: 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1536) /* nothing */; 37bfc7c1e (Jack Morgenstein 2012-08-03 08:40:44 +0000 1537) } > Jason