Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5453933ybv; Tue, 11 Feb 2020 16:17:01 -0800 (PST) X-Google-Smtp-Source: APXvYqxHAFdPamj2q2Yo5wI+Gq/m7jzTsEareGHcuPilja9r9+bDKoaGUmJtmVq3sFlyhmFRQvLN X-Received: by 2002:a05:6830:2154:: with SMTP id r20mr7575527otd.131.1581466621726; Tue, 11 Feb 2020 16:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581466621; cv=none; d=google.com; s=arc-20160816; b=znbPzsZlRV+whaJXFGKGRKhL6+7nCZx7/+1OvFsema/vnehZRjcEJTNJqgURX8S1Dr DpgDGKtu8yTNOPkW/jA/SU9yof1vvBd4qckFQghV67t0Cc/R0jY+p9DU0+WAL/IZHk3c Tww+z0cYe6wSGKpUCU1M7Eq25//1t3eQgSI9FkCyflf9i8sgCmGr5OpZq0H8FqeQIW4Q 8Amz/KmxcKwpOk5hSL/XJpD/JB1Ycb8Tb3DKPoN+2PeOgM5RXg4GOktd3SKvq0wqQWlE HvThv9r8sso6XGBflDzKrgbTMrgGWTcPnQhJMqekyceIs7zJI2zGdPKCAmpGTmzSS0sn CAXA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=w1PrTcYnGubFJTywEb+s8xI7Et1NeXbiwwojWkT+wWg=; b=jwLLb9669TzKuZQWowCALF004wFM46VUohE8h7uJ3RJKZL5vrWzYP0vsdtT4w9qJpq MWXcTdAi9gsYqLWIsO8uEjpzE2oQdlWO3qnOXQrRgh6ovh4yEa7o6j325vf1ya/dpr3A T0wNcOCVTyG6fytE9uV4XLGqSYse4IMn1a7k8eEYvtJFaTM9NMdaDleIUG1YFjxsEafk l0Dmgm9tJIORA71kJtdPGl8inqvXIGORo4CcNi5EjFqnBWNPoVP9Qvgip8LGs3CZvsAu buTjEDF+XgF7LOVr+aXC7FwxqjbhuH7KWdfQ6Fu9YniF56+yLsPv4b1CDXAskt+9/N41 uieA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-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 w16si2469515oih.154.2020.02.11.16.16.40; Tue, 11 Feb 2020 16:17:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728043AbgBLAQi (ORCPT + 99 others); Tue, 11 Feb 2020 19:16:38 -0500 Received: from mail1.ugh.no ([178.79.162.34]:46522 "EHLO mail1.ugh.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728025AbgBLAQi (ORCPT ); Tue, 11 Feb 2020 19:16:38 -0500 Received: from localhost (localhost [127.0.0.1]) by mail1.ugh.no (Postfix) with ESMTP id 987DF24EA99; Wed, 12 Feb 2020 01:16:36 +0100 (CET) Received: from mail1.ugh.no ([127.0.0.1]) by localhost (catastrophix.ugh.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8BqjRa5j_czg; Wed, 12 Feb 2020 01:16:35 +0100 (CET) Received: from [10.255.64.11] (unknown [185.176.245.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: andre@tomt.net) by mail.ugh.no (Postfix) with ESMTPSA id 7E26F24EA64; Wed, 12 Feb 2020 01:16:35 +0100 (CET) Subject: Re: [PATCH v1] xprtrdma: Fix DMA scatter-gather list mapping imbalance To: Chuck Lever Cc: robin.murphy@arm.com, Linux NFS Mailing List , iommu@lists.linux-foundation.org References: <158145102079.515252.3226617475691911684.stgit@morisot.1015granger.net> <8781b043-74a6-4ee0-d1c9-46f797b4aec2@tomt.net> From: Andre Tomt Message-ID: Date: Wed, 12 Feb 2020 01:16:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 11.02.2020 23:00, Chuck Lever wrote: > Hi Andre, thanks for trying this out. > >> On Feb 11, 2020, at 3:50 PM, Andre Tomt wrote: >> >> On 11.02.2020 20:58, Chuck Lever wrote: >>> The @nents value that was passed to ib_dma_map_sg() has to be passed >>> to the matching ib_dma_unmap_sg() call. If ib_dma_map_sg() choses to >>> concatenate sg entries, it will return a different nents value than >>> it was passed. >>> The bug was exposed by recent changes to the AMD IOMMU driver. >> >> This seems to fail differently on my system; mount fails with: >> mount.nfs: mount system call failed >> >> and the kernel log reports: >> [ 38.890344] NFS: Registering the id_resolver key type >> [ 38.890351] Key type id_resolver registered >> [ 38.890352] Key type id_legacy registered >> [ 38.901799] NFS: nfs4_discover_server_trunking unhandled error -5. Exiting with error EIO >> [ 38.901817] NFS4: Couldn't follow remote path >> >> amd_iommu=off still works >> >> One detail I accidentally left out of the original report is that the server (intel system) is running Ubuntu 20.04 ("beta") userspace, and AMD clients are Ubuntu 19.10 userspace. Although I dont believe this to matter at this point. > > Next thing to try: > > # trace-cmd record -e sunrpc -e rpcrdma > > then issue the mount command. Once it completes, ^C the trace-cmd and send me trace.dat. > > Try this with both the v5.4 kernel and the v5.5 kernel (and note that trace-cmd overwrites trace.dat, so copy it out between tests). I've uploaded them to https://tomt.net/temp/rdmaiommubug/ I'll probably do a 5.5.3 with the v1 fix as well, should show up momentarily. >>> Reported-by: Andre Tomt >>> Suggested-by: Robin Murphy >>> Fixes: 1f541895dae9 ("xprtrdma: Don't defer MR recovery if ro_map fails") >>> Signed-off-by: Chuck Lever >>> --- >>> net/sunrpc/xprtrdma/frwr_ops.c | 5 ++--- >>> 1 file changed, 2 insertions(+), 3 deletions(-) >>> Hey Andre, please try this out. It just reverts the bit of brokenness that >>> Robin observed this morning. I've done basic testing here with Intel >>> IOMMU systems, no change in behavior (ie, all good to go). >>> diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c >>> index 095be887753e..449bb51e4fe8 100644 >>> --- a/net/sunrpc/xprtrdma/frwr_ops.c >>> +++ b/net/sunrpc/xprtrdma/frwr_ops.c >>> @@ -313,10 +313,9 @@ struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, >>> break; >>> } >>> mr->mr_dir = rpcrdma_data_dir(writing); >>> + mr->mr_nents = i; >>> - mr->mr_nents = >>> - ib_dma_map_sg(ia->ri_id->device, mr->mr_sg, i, mr->mr_dir); >>> - if (!mr->mr_nents) >>> + if (!ib_dma_map_sg(ia->ri_id->device, mr->mr_sg, i, mr->mr_dir)) >>> goto out_dmamap_err; >>> ibmr = mr->frwr.fr_mr; >> > > -- > Chuck Lever > > >