Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp944711ybx; Tue, 5 Nov 2019 07:57:37 -0800 (PST) X-Google-Smtp-Source: APXvYqwuwlB7kHjslENL4hcCEYC/3PqTZfWIdh998izh8ziMjGJJb1aRi4yNFzNQ+t0Qi9Y4nLrb X-Received: by 2002:a05:6402:54a:: with SMTP id i10mr13157064edx.230.1572969457795; Tue, 05 Nov 2019 07:57:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572969457; cv=none; d=google.com; s=arc-20160816; b=kLMBX3mp6MWylmCh43hQ1G6L8eIK2kwKbmJuQ8AgoBsT0ZoxlFFyxJvfT9HdaOTNYc BsMWklCOpq8sr9M+x+usrsZGR+/z8/BQSIHgBohNSUmj/Hw3ySl3z64GmVL8iWL4DVqW yxKrdH1S2XFvRHbHdZTfJOF1r4ODgcT8p1hnrp6VL2+tQmfwaGp902e1lGwmy8rJeCmg GT4Mp5mtpzT5TJD6wpV2Ei1W5JkhBryyz/rUNaeO10UjlNWsnfGblfgXJF83j8cn4Kep ggsaewlQ6X0ILkQdQyvqC0p/KuoAUI3NqgVgyjxUlrvjJUN48K9cnY55vjDc4KQl2+j5 KgWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lBJK8xKzWTLoxZq+hjJ5V27RUipKZggRLn9sGq9znSg=; b=Jn+1uX6CLM0ywcvvQNJ1IOEOqEYrwVq27deZ1lHF4mH/rTJ/ZuopsBN4GUhmyo7WMc W+ZbRmcWXDmDDFpu7lRIT2EyI/aX8T3TrTY2kTALJKtXnnAjiZhwp3AJ7TRIDTgZB5z0 2aGHYcEO3m5UuCsC2pcBtQxMNiRlqQRAJhLcpDS99h2Sl6JkU7MtMbxtdlOuRUj4HEUN qyOCnTQK7Lv0dYWlNqa4QpmJBnfb08UOeiQdysGF85AA0cR8oxH1cDkQXrI0dvBGI9TI ks6m6yRoGqtybMY1b2InrVZrz7ZSncQmDDoy+dqWBRCpEG3agqwSRTb4iClvMMIMEsC1 2eEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qdew3CQo; 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=pass (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 nj2si13560879ejb.233.2019.11.05.07.57.14; Tue, 05 Nov 2019 07:57:37 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qdew3CQo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389985AbfKEPy0 (ORCPT + 99 others); Tue, 5 Nov 2019 10:54:26 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40790 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389571AbfKEPy0 (ORCPT ); Tue, 5 Nov 2019 10:54:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572969265; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lBJK8xKzWTLoxZq+hjJ5V27RUipKZggRLn9sGq9znSg=; b=Qdew3CQo5EkWekU9g5jjE92qA2NYbJfbbLCTGFKuHpg3izpcSyBZbl+TjzvjNnJ49iz9Qa YgzeTap2ohUbboR5hylIzU1o0xsOnMQY8qCWYr/g7TeNb1nycGpd/YgvuWTXGx5KM4CLs0 q4W6c7YYl39znLpPRCOcd285GwV3zJk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-323-uSxGkBi8PyWQ5OqXVxSb7w-1; Tue, 05 Nov 2019 10:54:21 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B76A1005500; Tue, 5 Nov 2019 15:54:19 +0000 (UTC) Received: from redhat.com (ovpn-118-16.phx2.redhat.com [10.3.118.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B21625D6A3; Tue, 5 Nov 2019 15:54:17 +0000 (UTC) Date: Tue, 5 Nov 2019 10:54:15 -0500 From: Jerome Glisse To: Hillf Danton Cc: John Hubbard , linux-mm , Andrew Morton , linux-kernel , Vlastimil Babka , Jan Kara , Mel Gorman , Dan Williams , Ira Weiny , Christoph Hellwig , Jonathan Corbet Subject: Re: [RFC] mm: gup: add helper page_try_gup_pin(page) Message-ID: <20191105155415.GA3142@redhat.com> References: <20191103112113.8256-1-hdanton@sina.com> <20191104043420.15648-1-hdanton@sina.com> <20191104102050.15988-1-hdanton@sina.com> <20191105042755.7292-1-hdanton@sina.com> MIME-Version: 1.0 In-Reply-To: <20191105042755.7292-1-hdanton@sina.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: uSxGkBi8PyWQ5OqXVxSb7w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 05, 2019 at 12:27:55PM +0800, Hillf Danton wrote: >=20 > On Mon, 4 Nov 2019 14:03:55 -0500 Jerome Glisse wrote: > >=20 > > On Mon, Nov 04, 2019 at 06:20:50PM +0800, Hillf Danton wrote: > > > > > > On Sun, 3 Nov 2019 22:09:03 -0800 John Hubbard wrote: > > > > On 11/3/19 8:34 PM, Hillf Danton wrote: > > > > ... > > > > >> > > > > >> Well, as long as we're counting bits, I've taken 21 bits (!) to = track > > > > >> "gupers". :) More accurately, I'm sharing 31 bits with get_page= ()...please > > > > > > > > > > Would you please specify the reasoning of tracking multiple guper= s > > > > > for a dirty page? Do you mean that it is all fine for guper-A to = add > > > > > changes to guper-B's data without warning and vice versa? > > > > > > > > It's generally OK to call get_user_pages() on a page more than once= . > > > > > > Does this explain that it's generally OK to gup pin a page under > > > writeback and then start DMA to it behind the flusher's back without > > > warning? > >=20 > > It can happens today, is it ok ... well no but we live in an imperfect > > world. GUP have been abuse by few device driver over the years and thos= e > > never checked what it meant to use it so now we are left with existing > > device driver that we can not break that do wrong thing. >=20 > See your point :) >=20 > > I personaly think that we should use bounce page for writeback so that > > writeback can still happens if a page is GUPed. >=20 > Gup can be prevented from falling foul of writeback IMHO if the page > under writeback, gup pinned or not, remains stable until it is no > longer dirty. >=20 > For that stability, either we can check PageWriteback on gup pinning > for instance as the RFC does or drivers can set a gup-pinned page > dirty only after DMA and start no more DMA until it is clean again. >=20 > As long as that stability is ensured writeback will no longer need to > take care of gup pin, long-lived or transient. >=20 > It seems unlike a request too strict to meet in practice wrt data > corruption, and bounce page for writeback sounds promising. Does it > need to do a memory copy? Once driver has GUP it does not check and re-check the struct page so there is no synchronization whatsoever after GUP happened. In fact for some driver you can not synchronize anything once the device has been program. Many devices are not just simple DMA engine you can start and stop at will (network, GPUs, ...). So once a page is GUP there is just noway to garanty its stability hence the best thing we can do is snapshot it to a bounce page. Cheers, J=E9r=F4me