Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3219877imu; Mon, 19 Nov 2018 12:29:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/WXFjKyqqkwF+4VlMKKNYx6d+uoZpRgVoAuUezqDUJO2Q3yOq1WErCSb9OrFMtz4wokMhzD X-Received: by 2002:a17:902:2862:: with SMTP id e89mr749931plb.158.1542659389741; Mon, 19 Nov 2018 12:29:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542659389; cv=none; d=google.com; s=arc-20160816; b=Bg8i+hvz9jE3+aGCogWxflmSmTMj1yE9EyUZD18c7hOvs4Wli6qtQBGVgV1St5UZMA 00p3D91vgvYe9fL3Kw86Jz2vYchinQOHyxcHuNxcwqUlRSdV0WefclAZLWuWwpnj/+Av 6rkMTEM+JdT/dcc03TkZjyjf7p5CjgTTPQVNlHWSmdMiRJdhDBPk5Wz+Mac8Hn6UaL7q f5aG/TzA8MclouTnJX2i/WeTaHwmNTuJinrJVB8kIgTGUFa17006bKYhexuBoTQ7HYvo IOW5/mO5H4cm+k1mVQKLP8KiHPgbDImI/LLj+bdA3EFkIuLPV2PnIQVim4+CgpVsPm8o Lbnw== 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; bh=Kzn4v7HDCf/zsGd9HXqgvGrsvf5OfTgPllGA+4s4d2I=; b=dNUp/LTXjPUj0c1fAyhFhFO9Rx/y4q/+aMVBqRwAgMWnsw9EIjYEpQBrcHOJQxZHdJ aeNG9n1eBcZLw/TSwfo0FH9IZeu2nbpsnvMksjoR1ZFmLWlwXuLbNb9qDYW8Lh6Wj99X YZHYy0tVJq3U79xae4Z4GOvCFNF4aGoYQGInsfNKEOVRcV/mp59HnUbo1dIAoXOGn78v awDGCBrhW21U1EKYFw2l6AHt99todORZ2GYy9DeB734wRqVaX/NjBfhdJ1ImSlFA1QNG 3y2OMKJU7WYQK0BlkKcDbhhyqwJm2iZkrQLRfix+raf2DQBTd5cLO/UOGqJMuN+1zsaX LPtA== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6-v6si38531041pgr.274.2018.11.19.12.29.34; Mon, 19 Nov 2018 12:29:49 -0800 (PST) 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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730783AbeKTGvj (ORCPT + 99 others); Tue, 20 Nov 2018 01:51:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42506 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728938AbeKTGvj (ORCPT ); Tue, 20 Nov 2018 01:51:39 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADBD67F6BB; Mon, 19 Nov 2018 20:26:20 +0000 (UTC) Received: from redhat.com (ovpn-124-1.rdu2.redhat.com [10.10.124.1]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13CA3600D7; Mon, 19 Nov 2018 20:26:16 +0000 (UTC) Date: Mon, 19 Nov 2018 15:26:15 -0500 From: Jerome Glisse To: Jason Gunthorpe Cc: Tim Sell , linux-doc@vger.kernel.org, Alexander Shishkin , Zaibo Xu , zhangfei.gao@foxmail.com, linuxarm@huawei.com, haojian.zhuang@linaro.org, Christoph Lameter , Hao Fang , Gavin Schenk , Leon Romanovsky , RDMA mailing list , Vinod Koul , Doug Ledford , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , David Kershner , Kenneth Lee , Johan Hovold , Cyrille Pitchen , Sagar Dharia , Jens Axboe , guodong.xu@linaro.org, linux-netdev , Randy Dunlap , linux-kernel@vger.kernel.org, Zhou Wang , linux-crypto@vger.kernel.org, Philippe Ombredanne , Sanyog Kale , Kenneth Lee , "David S. Miller" , linux-accelerators@lists.ozlabs.org Subject: Re: [RFCv3 PATCH 1/6] uacce: Add documents for WarpDrive/uacce Message-ID: <20181119202614.GF4593@redhat.com> References: <20181119091910.GF157308@Turing-Arch-b> <20181119104801.GF8268@mtr-leonro.mtl.com> <20181119164853.GA4593@redhat.com> <20181119182752.GA4890@ziepe.ca> <20181119184215.GB4593@redhat.com> <20181119185333.GC4890@ziepe.ca> <20181119191721.GC4593@redhat.com> <20181119192702.GD4890@ziepe.ca> <20181119194631.GE4593@redhat.com> <20181119201156.GG4890@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181119201156.GG4890@ziepe.ca> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 19 Nov 2018 20:26:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 19, 2018 at 01:11:56PM -0700, Jason Gunthorpe wrote: > On Mon, Nov 19, 2018 at 02:46:32PM -0500, Jerome Glisse wrote: > > > > ?? How can O_DIRECT be fine but RDMA not? They use exactly the same > > > get_user_pages flow, right? Can we do what O_DIRECT does in RDMA and > > > be fine too? > > > > > > AFAIK the only difference is the length of the race window. You'd have > > > to fork and fault during the shorter time O_DIRECT has get_user_pages > > > open. > > > > Well in O_DIRECT case there is only one page table, the CPU > > page table and it gets updated during fork() so there is an > > ordering there and the race window is small. > > Not really, in O_DIRECT case there is another 'page table', we just > call it a DMA scatter/gather list and it is sent directly to the block > device's DMA HW. The sgl plays exactly the same role as the various HW > page list data structures that underly RDMA MRs. > > It is not a page table that matters here, it is if the DMA address of > the page is active for DMA on HW. > > Like you say, the only difference is that the race is hopefully small > with O_DIRECT (though that is not really small, NVMeof for instance > has windows as large as connection timeouts, if you try hard enough) > > So we probably can trigger this trouble with O_DIRECT and fork(), and > I would call it a bug :( I can not think of any scenario that would be a bug with O_DIRECT. Do you have one in mind ? When you fork() and do other syscall that affect the memory of your process in another thread you should expect non consistant results. Kernel is not here to provide a fully safe environement to user, user can shoot itself in the foot and that's fine as long as it only affect the process itself and no one else. We should not be in the business of making everything baby proof :) > > > > Why? Keep track in each mm if there are any active get_user_pages > > > FOLL_WRITE pages in the mm, if yes then sweep the VMAs and fix the > > > issue for the FOLL_WRITE pages. > > > > This has a cost and you don't want to do it for O_DIRECT. I am pretty > > sure that any such patch to modify fork() code path would be rejected. > > At least i would not like it and vote against. > > I was thinking the incremental cost on top of what John is already > doing would be very small in the common case and only be triggered in > cases that matter (which apps should avoid anyhow). What John is addressing has nothing to do with fork() it has to do with GUP and filesystem page. More specificaly that after page_mkclean() all filesystem expect that the page content is stable (ie no one write to the page) with GUP and hardware (DIRECT_IO too) this is not necessarily the case. So John is trying to fix that. Not trying to make fork() baby proof AFAICT :) I rather keep saying that you should expect weird thing with RDMA and VFIO when doing fork() than trying to work around this in the kernel. Better behavior through hardware is what we should aim for (CAPI, ODP, ...). J?r?me