Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3164678ybt; Mon, 22 Jun 2020 17:06:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVRxtMCznhh9hs22CgJ8EBz3rpBDY5ZZsAzoIlDxkwIL/fb+naCBQA3qct8dh9pZX5MK49 X-Received: by 2002:aa7:dc57:: with SMTP id g23mr18671406edu.352.1592870789251; Mon, 22 Jun 2020 17:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592870789; cv=none; d=google.com; s=arc-20160816; b=B7fKJaNCaHs9OIzORhHUEcg9YwPwkY6y7OCslaKwfDbpg3ZBJKs5r+eLfG/NmpyM+p viLuF8/8m/0pHSnzEtBaZojMHJnpyhLB/7Y3kITG1MnQ2zPgVNyhl555pV30F6LVxA+E 9GbHkFstpItzEs3OlkBpoG07YvmED7dbp7qWVJ5lEpV7zJBqjitZ+MFWylIY40GJC/FS 0XCHLJAn1I+HtHQl4yHiIm6EsSXtt08cfsWWHtjCOtdha+s6mNIokpvSqQQGMyCWGKVL QHoZ4LcC9qgbH4tds/I2p/mor3eMbLiS+xq/Hh92iQmTyDIDMVs0O3usq/xjL515n3p+ daAw== 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=fL1wENgZCNwSv3s/JTNbtGHYfJcNOvZphPgobRgCX+0=; b=y3qb1aKjkbA5wwK9hd2Otuzf+//ZUsLtazCet6H/Ss/zlqcK+KWYThmLbz4WP220Ny yGKqrMZlrCXyC8wcEsLBuJMq3SqSw9wppuA06+isyHyHtDxG/sx6wk1EibVR2JOUFxcY 48JLL7d+WtHhmPwcsAOHgAghGiKaUeMlGWDs909Asjn62iTLevSwdOQGVLnCrd/aCGrw n98lJZhyvmbtwfjrJnjpQoVnaSmHSb4ayhw61GjrhSXdnx9yiXDL6ZZ2f1Hf7vfzwl03 xOWgemyDaU92tfR+b9eAzIzYby5dc5uffsp10JX+BBVdVEZF+vxvBebjRutZvL0xWrT3 KgHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=jOiz5xhY; 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 h14si10334960ejq.198.2020.06.22.17.06.03; Mon, 22 Jun 2020 17:06:29 -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=jOiz5xhY; 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 S1731356AbgFWACg (ORCPT + 99 others); Mon, 22 Jun 2020 20:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730774AbgFWACf (ORCPT ); Mon, 22 Jun 2020 20:02:35 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39565C061573 for ; Mon, 22 Jun 2020 17:02:34 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id d27so14128638qtg.4 for ; Mon, 22 Jun 2020 17:02:34 -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=fL1wENgZCNwSv3s/JTNbtGHYfJcNOvZphPgobRgCX+0=; b=jOiz5xhY4H9RrA31ewUoMb6lWoSEJluMNJ4pFLIyuL2C/PAw2cU4NhHZPSbOtneWmY ozUMm9lxePnw9yOjxx4YXvXCK3kITgyY6VI+mhuSl9fkmcyIppyhy/Jz6vVv/4LKzuRn Gb8qhMwxyR4RKm7f3IBCU6P9IiqbHgwNX0yoHpJ3PAkHDvus22DcgqWtCXRMKvuPd80+ GtMIE29iM9uSkrK/mkJM41mZz+r3jtg9ekirUsyx5erxi/e/W0HuUH+SRS8iBijVSbYY gVUrM+bjvjO7k15tkl2NlzpoPMdsvYPWVTdqh0sfLGGUDdoylYfcONvUD2B6N+OO84GZ lj3Q== 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=fL1wENgZCNwSv3s/JTNbtGHYfJcNOvZphPgobRgCX+0=; b=nLGqIomqBShQ0kO7uj+ybyHI8gXgvkDymYBuYVXDkE8yK0qJktB1ppa9KoUaKDOIdl 5Iu0mvQ7lr0dIwQfj6jJdNDc2HRqFAyJZUfiA/qG5oEMUc/3XECiifok1UIpwbx6OJkH kxOqwFCq7SIP1iozr5eoe7B5N/E2oTrL7HwM+BRUnJZsMBHv0z0Nn9JpgevoRoishqjK oGeZ4Pod1Ucr6oEaMhLovOEPIpjSzbZW8lApCPMAqwfp8UkcAOncAwKyGvuazi41PzED o4iBtBXer75TBrDUId6oDn+fjqdRrM3G6lQPDp7ELpo9VZxy4CfY7opBvBncVH8NXeaw ZeeQ== X-Gm-Message-State: AOAM531myBiA7AqNGRvWg0PineMbpbYaXd5SFBTtZDKUnmkKtnymvXVQ S6C+xMAz5CxrQvQqKtRbHdIA3g== X-Received: by 2002:ac8:70da:: with SMTP id g26mr17916678qtp.333.1592870553204; Mon, 22 Jun 2020 17:02:33 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id d186sm6145604qkb.110.2020.06.22.17.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 17:02:32 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.93) (envelope-from ) id 1jnWOV-00CHMM-GL; Mon, 22 Jun 2020 21:02:31 -0300 Date: Mon, 22 Jun 2020 21:02:31 -0300 From: Jason Gunthorpe To: Jerome Glisse Cc: Felix Kuehling , linux-rdma , Thomas =?utf-8?B?SGVsbHN0csO2bSAoSW50ZWwp?= , Maarten Lankhorst , LKML , DRI Development , Christian =?utf-8?B?S8O2bmln?= , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Thomas Hellstrom , amd-gfx list , Daniel Vetter , Daniel Vetter , Mika Kuoppala , Intel Graphics Development , "open list:DMA BUFFER SHARING FRAMEWORK" Subject: Re: [Linaro-mm-sig] [PATCH 04/18] dma-fence: prime lockdep annotations Message-ID: <20200623000231.GW6578@ziepe.ca> References: <20200619151551.GP6578@ziepe.ca> <20200619172308.GQ6578@ziepe.ca> <20200619180935.GA10009@redhat.com> <20200619181849.GR6578@ziepe.ca> <56008d64-772d-5757-6136-f20591ef71d2@amd.com> <20200619195538.GT6578@ziepe.ca> <20200619203147.GC13117@redhat.com> <20200622114617.GU6578@ziepe.ca> <20200622201540.GB9708@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200622201540.GB9708@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 22, 2020 at 04:15:40PM -0400, Jerome Glisse wrote: > On Mon, Jun 22, 2020 at 08:46:17AM -0300, Jason Gunthorpe wrote: > > On Fri, Jun 19, 2020 at 04:31:47PM -0400, Jerome Glisse wrote: > > > Not doable as page refcount can change for things unrelated to GUP, with > > > John changes we can identify GUP and we could potentialy copy GUPed page > > > instead of COW but this can potentialy slow down fork() and i am not sure > > > how acceptable this would be. Also this does not solve GUP against page > > > that are already in fork tree ie page P0 is in process A which forks, > > > we now have page P0 in process A and B. Now we have process A which forks > > > again and we have page P0 in A, B, and C. Here B and C are two branches > > > with root in A. B and/or C can keep forking and grow the fork tree. > > > > For a long time now RDMA has broken COW pages when creating user DMA > > regions. > > > > The problem has been that fork re-COW's regions that had their COW > > broken. > > > > So, if you break the COW upon mapping and prevent fork (and others) > > from copying DMA pinned then you'd cover the cases. > > I am not sure we want to prevent COW for pinned GUP pages, this would > change current semantic and potentialy break/slow down existing apps. Isn't that basically exactly what 17839856fd588 does? It looks like it uses the same approach RDMA does by sticking FOLL_WRITE even though it is a read action. After that change the reamining bug is that fork can re-establish a COW./ > Anyway i think we focus too much on fork/COW, it is just an unfixable > broken corner cases, mmu notifier allows you to avoid it. Forcing real > copy on fork would likely be seen as regression by most people. If you don't copy the there are data corruption bugs though. Real apps probably don't hit a problem here as they are not forking while GUP's are active (RDMA excluded, which does do this) I think that implementing page pinning by blocking mmu notifiers for the duration of the pin is a particularly good idea either, that actually seems a lot worse than just having the pin in the first place. Particularly if it is only being done to avoid corner case bugs that already afflict other GUP cases :( > > What do you mean 'GUP fast is still succeptible to this' ? > > Not all GUP fast path are updated (intentionaly) __get_user_pages_fast() Sure, that is is the 'raw' accessor Jason