Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1007333ybt; Fri, 19 Jun 2020 21:24:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1e7ECyUFzpGiDCgq4cExXtPv46s5/xqCF5UC8BdCdXvKMoq2i9w6/XnTTyFb2XudN75hl X-Received: by 2002:a17:906:4f13:: with SMTP id t19mr6253830eju.269.1592627078749; Fri, 19 Jun 2020 21:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592627078; cv=none; d=google.com; s=arc-20160816; b=BE6ANFrD2HNWxm1AXOWIL/shMP5f9kCSNDHc5uMywv7H+eOKkjM4MszNBrzmP0RocE ZYnfiPxBhXS5/ix5Odlmre+yjFrkHOHrWKx4Oh2hahxThijgM7DkHK734MpDBLjnGzQy Q/CNYI4tmtFcTOCO4zsq4G7LBxbr5R0U073Pcb5wKf1zWGkBTE6LMb4AINFGp6ZomMyn kO6PvZnnOxhyGJislqfgGIyOKMMuud3u1yl2vhrKZuGyzvZet2jibiNlipMdyNvsH4sj jufSRx5NHOn4Sw7o7V7XYdRkUC/P+YNbxPrllVLr5S5Qo+GsWhwGpN8NawCvrkJSkyzb EPhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=1/Hgy08bto/uuUKyMYyyKuV+V6dnJEVWt8WI7nf113M=; b=Fg4hjmsf0AQv0QpaibtItU9NG/iPRyRd1ucRtiybenOhVvmnUuAp/LU6uDy6silPJA OHqGGDMHN/5XbdH4pwQEEyFglWxRsWCF7LuDidcACuKZ5SyuhZyEXk5eZQABeeOGEFYh UWWz45M0s67lKAtwFuIelLc89A3JRScaIk1lYyFO6WSJ9340BVwT+rwZo+cNCZiGB+eV NjPr4UlRHEisJuJsyZXmVNp5c2oxZkZuXDdCo4YDjMk8IMo1Yjy/O8i17oaqUp5zr5bf RNBS6UvOeAnnseSOr7e3vJy3RUbicSN/ZtoINQz6qX6a/Yd/CKnTWzY0RNEPFA/Yo4ko o+WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=oKJaPgv8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si5193815eds.92.2020.06.19.21.24.16; Fri, 19 Jun 2020 21:24:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=oKJaPgv8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732476AbgFSSSx (ORCPT + 99 others); Fri, 19 Jun 2020 14:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731907AbgFSSSw (ORCPT ); Fri, 19 Jun 2020 14:18:52 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4C4BC0613EF for ; Fri, 19 Jun 2020 11:18:51 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id k18so702399qke.4 for ; Fri, 19 Jun 2020 11:18:51 -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:in-reply-to; bh=1/Hgy08bto/uuUKyMYyyKuV+V6dnJEVWt8WI7nf113M=; b=oKJaPgv8wNzRDCQM/lbllCSa8UopWR/4B3ZObmEr8TAf1+Rds44pV9VzNub4sQdhc2 bjSNRQFpC1WEcAOQoeY8RSETmivCfaJ304Nt+yFVJOJ3EAJPutPkzAstPxgxWTthm32r lAh5yy5JF9Zclqktay5+zs6zAs4qsPCMyyTnmAlKngaG1QbMRQj5/aW32rxFtirPl7SN HF7NEkxn7w4GPh8ayZInrb8FNVuIMujbguuDEsHpUspaixZEf7pYVjnwEs3vjnveMg0N FydqN5NJ5K9LZc5hUEs32llHDaDYk5KrqnBUzpPC9LHlhF+AF1cEaShjq0uYpfPfAwu+ i2ug== 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:in-reply-to; bh=1/Hgy08bto/uuUKyMYyyKuV+V6dnJEVWt8WI7nf113M=; b=tLQSWf2O46qyLxJ6V/Hvm7Vtu21dIFmfKajdNIX6K9u87fKTp36/6Frou+0hJgaand SZkNdkCpvaxpqurwuOt8iVebIZ9jBG4ARO5GzLIe2lTePuwaanQPGqG2h9r4zgNO/yvb oN00vJzlEM2gPaug6TjjskQeECVtFY3p06tiTAAIq3RnUs9RRzMbn4HDCwACYNzxNAuU ebd5RPPlhGZUH4lJroVAHmdRjGIzPyzGaVfUVT2p90pYOxPusZXe+J+Ww77/SnEQL50V uMgJGDxA7GpsMLZAVMT0Fj9quzKontOdnCrzLRbO9dfa83O1qQ6d0Gj2gupXRfiziXkE VN9w== X-Gm-Message-State: AOAM5329mjHNMJRK1fWCRv3zNVcuWM99cf7NYr0iAi7ZMeHZJItR4TAS Bz3TYr1YkIvxAU86doKRpC5yyg== X-Received: by 2002:a37:4e4a:: with SMTP id c71mr4652759qkb.61.1592590730926; Fri, 19 Jun 2020 11:18:50 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id f203sm815339qke.135.2020.06.19.11.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 11:18:50 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.93) (envelope-from ) id 1jmLbF-00AyFH-UW; Fri, 19 Jun 2020 15:18:49 -0300 Date: Fri, 19 Jun 2020 15:18:49 -0300 From: Jason Gunthorpe To: Jerome Glisse Cc: Daniel Vetter , Thomas =?utf-8?B?SGVsbHN0csO2bSAoSW50ZWwp?= , DRI Development , linux-rdma , Intel Graphics Development , Maarten Lankhorst , LKML , amd-gfx list , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Thomas Hellstrom , Daniel Vetter , "open list:DMA BUFFER SHARING FRAMEWORK" , Christian =?utf-8?B?S8O2bmln?= , Mika Kuoppala Subject: Re: [Linaro-mm-sig] [PATCH 04/18] dma-fence: prime lockdep annotations Message-ID: <20200619181849.GR6578@ziepe.ca> References: <20200617152835.GF6578@ziepe.ca> <20200618150051.GS20149@phenom.ffwll.local> <20200618172338.GM6578@ziepe.ca> <20200619113934.GN6578@ziepe.ca> <20200619151551.GP6578@ziepe.ca> <20200619172308.GQ6578@ziepe.ca> <20200619180935.GA10009@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200619180935.GA10009@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 19, 2020 at 02:09:35PM -0400, Jerome Glisse wrote: > On Fri, Jun 19, 2020 at 02:23:08PM -0300, Jason Gunthorpe wrote: > > On Fri, Jun 19, 2020 at 06:19:41PM +0200, Daniel Vetter wrote: > > > > > The madness is only that device B's mmu notifier might need to wait > > > for fence_B so that the dma operation finishes. Which in turn has to > > > wait for device A to finish first. > > > > So, it sound, fundamentally you've got this graph of operations across > > an unknown set of drivers and the kernel cannot insert itself in > > dma_fence hand offs to re-validate any of the buffers involved? > > Buffers which by definition cannot be touched by the hardware yet. > > > > That really is a pretty horrible place to end up.. > > > > Pinning really is right answer for this kind of work flow. I think > > converting pinning to notifers should not be done unless notifier > > invalidation is relatively bounded. > > > > I know people like notifiers because they give a bit nicer performance > > in some happy cases, but this cripples all the bad cases.. > > > > If pinning doesn't work for some reason maybe we should address that? > > Note that the dma fence is only true for user ptr buffer which predate > any HMM work and thus were using mmu notifier already. You need the > mmu notifier there because of fork and other corner cases. I wonder if we should try to fix the fork case more directly - RDMA has this same problem and added MADV_DONTFORK a long time ago as a hacky way to deal with it. Some crazy page pin that resolved COW in a way that always kept the physical memory with the mm that initiated the pin? (isn't this broken for O_DIRECT as well anyhow?) How does mmu_notifiers help the fork case anyhow? Block fork from progressing? > I probably need to warn AMD folks again that using HMM means that you > must be able to update the GPU page table asynchronously without > fence wait. It is kind of unrelated to HMM, it just shouldn't be using mmu notifiers to replace page pinning.. > The issue for AMD is that they already update their GPU page table > using DMA engine. I believe this is still doable if they use a > kernel only DMA engine context, where only kernel can queue up jobs > so that you do not need to wait for unrelated things and you can > prioritize GPU page table update which should translate in fast GPU > page table update without DMA fence. Make sense I'm not sure I saw this in the AMD hmm stuff - it would be good if someone would look at that. Every time I do it looks like the locking is wrong. Jason