Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2245337ybl; Thu, 15 Aug 2019 08:45:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSrBNjKWzG1f7YOpfgK/H5iWszfS9ATtPzOyYCQ708/HJ+4NZ/dT168fGMVaVna6Y1wduF X-Received: by 2002:a63:5754:: with SMTP id h20mr3866280pgm.195.1565883908361; Thu, 15 Aug 2019 08:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565883908; cv=none; d=google.com; s=arc-20160816; b=PvF8P9RGQq82wRBauJNZf6Sy1B9ngPswRp+Fv5N19kw2+IyL7KEMQt3HsqKdLWsrTp muvpLThoeaB6+uqnIxuzT5S+jNuxBU934eccL6SuSO3dHen0aAuQ9FkgQd3yljtRIq77 Q6QrOByituhK83CAd0aEoBAJg8ZvFfCfX3DyNmuXR4mgJN+uuJsvXevv5H+e3nUSLZdA uIEq6nFn6/b6eBf/xNX9gcK/CG0AsYQ2bexCsf2B0X5KKf7nrFLE+lmDisG9hwG12HAK mllqD3lQiHbLWVvbgBoGC9OXnGifPXzmeVoB205BzAS7VLy/vzg9w1khN1S/lpBRH8dH zgdg== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xzO7Mshohtsh0MjNCwtfvdaSBmY8e4joFkYT0O9y2JI=; b=jK7vUQ9b0LfnwXzBYCtwO5DLgpXrj1PVtOLhte5hm7d9V2+JH15RffD7vFqRU9SqHR 1ewTho+UfK+1IcGLg8mm/ewyR1D2UBafqOOHMKBrljvpu9njy4vqDgOyeiZKGcGBlDz6 cB00S88+VNkDxwp/dRb+aXTluBBZbPL5Pn/oG17Oeoj5sE8OXUvCzIEy3kfcRdhpQjGZ GgR8qjIkcQcapMr9jndFIj2lCuuy4zYpx9iCb7k9uuGwOcQL02Wdvga5bprhvcP8jeT9 EpBeS4o5yD+15Etvlxb+nNVMM5y0oQb2SvKWLlBRyv8/LRxvYylZ2u05+6aq7jdPPg+j btqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=lI3y7R44; 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 v1si2126713plp.264.2019.08.15.08.44.53; Thu, 15 Aug 2019 08:45:08 -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=lI3y7R44; 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 S1732445AbfHOPKa (ORCPT + 99 others); Thu, 15 Aug 2019 11:10:30 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:37907 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfHOPKa (ORCPT ); Thu, 15 Aug 2019 11:10:30 -0400 Received: by mail-qk1-f195.google.com with SMTP id u190so2090646qkh.5 for ; Thu, 15 Aug 2019 08:10:29 -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:user-agent; bh=xzO7Mshohtsh0MjNCwtfvdaSBmY8e4joFkYT0O9y2JI=; b=lI3y7R44OI9cE4EW3AD4mdCTJlQwdhtFMnFulkuEqvQdz88hWBkf/Luz9A97zWh1WM 6VlnHYIeU9yHzN5gLW2s6pZtC53ZcoK+QYnLyrm71HqORWm7eDtaZclaBxKxBqoBfR6a wQh2bKmRFu8C01tUVSEPeeZYrB6Zf+XdIvZRedLH4G7bY1xFFrYAoyZPI6cM+2j3i+UD ekO1QrzYXDSKJKdF9J3udmvIveoENdrM4omYutvyVHhrkIapI79MBHNcmw35rsWFNK76 65B13pG5zrwaNbu2GbqZZmb2GB6hh98QSz3unRjRNSzvxzUILwBIuF3oriB53wVaSEzR S8UA== 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:user-agent; bh=xzO7Mshohtsh0MjNCwtfvdaSBmY8e4joFkYT0O9y2JI=; b=KjhJoniRUc48ma+61TygWzaiAupIvcQWFkTGEXbM+7AD5+3cPuoMmrAbeWEIHXanHC lsKp12bs6+oaUZ0XD26ZhtumheugfdEPRcNsqakp/JGDdfoEXMN2sxC3PdnV27PYdUs/ E5YOH2A1+Did15QKdjQpEZ8VYibTT0uTIasPDLEPYSN3OjR/dTOlva9cNeGgj49MjwO6 m2dUvzd4hveKwPXyRHT2Akvxi9kDuIsBdX8ZMgal2HnKXLVDOMq9TATWDeltqp/tO/KQ ipX2MerSUJH0tBAt9cb1q9eJdQvsV6wIHTYuvhkwGruu6O0kSnwAVEWt3a3TOS1CraPC Bakg== X-Gm-Message-State: APjAAAWk6H/8Y8PxRQ8ZfvjpH4xgM9BmG5qHhpZ8mvzv2u6NggZw3idH jWj0i1AVooLtCjc0jFOyEYFp3A== X-Received: by 2002:a37:aa88:: with SMTP id t130mr4635639qke.12.1565881829208; Thu, 15 Aug 2019 08:10:29 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id i62sm1568446qke.52.2019.08.15.08.10.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Aug 2019 08:10:28 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hyHOW-0005WZ-AT; Thu, 15 Aug 2019 12:10:28 -0300 Date: Thu, 15 Aug 2019 12:10:28 -0300 From: Jason Gunthorpe To: Daniel Vetter Cc: Michal Hocko , Andrew Morton , LKML , Linux MM , DRI Development , Intel Graphics Development , Peter Zijlstra , Ingo Molnar , David Rientjes , Christian =?utf-8?B?S8O2bmln?= , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Masahiro Yamada , Wei Wang , Andy Shevchenko , Thomas Gleixner , Jann Horn , Feng Tang , Kees Cook , Randy Dunlap , Daniel Vetter Subject: Re: [PATCH 2/5] kernel.h: Add non_block_start/end() Message-ID: <20190815151028.GJ21596@ziepe.ca> References: <20190814202027.18735-1-daniel.vetter@ffwll.ch> <20190814202027.18735-3-daniel.vetter@ffwll.ch> <20190814134558.fe659b1a9a169c0150c3e57c@linux-foundation.org> <20190815084429.GE9477@dhcp22.suse.cz> <20190815130415.GD21596@ziepe.ca> <20190815143759.GG21596@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 15, 2019 at 04:43:38PM +0200, Daniel Vetter wrote: > You have to wait for the gpu to finnish current processing in > invalidate_range_start. Otherwise there's no point to any of this > really. So the wait_event/dma_fence_wait are unavoidable really. I don't envy your task :| But, what you describe sure sounds like a 'registration cache' model, not the 'shadow pte' model of coherency. The key difference is that a regirstationcache is allowed to become incoherent with the VMA's because it holds page pins. It is a programming bug in userspace to change VA mappings via mmap/munmap/etc while the device is working on that VA, but it does not harm system integrity because of the page pin. The cache ensures that each initiated operation sees a DMA setup that matches the current VA map when the operation is initiated and allows expensive device DMA setups to be re-used. A 'shadow pte' model (ie hmm) *really* needs device support to directly block DMA access - ie trigger 'device page fault'. ie the invalidate_start should inform the device to enter a fault mode and that is it. If the device can't do that, then the driver probably shouldn't persue this level of coherency. The driver would quickly get into the messy locking problems like dma_fence_wait from a notifier. It is important to identify what model you are going for as defining a 'registration cache' coherence expectation allows the driver to skip blocking in invalidate_range_start. All it does is invalidate the cache so that future operations pick up the new VA mapping. Intel's HFI RDMA driver uses this model extensively, and I think it is well proven, within some limitations of course. At least, 'registration cache' is the only use model I know of where it is acceptable to skip invalidate_range_end. Jason