Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp510861ybx; Tue, 5 Nov 2019 00:59:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwjPuh4zUa3Nlsv/jXmjWofhR2fTBw3Q/K9ff0xcaxEk3IV7nCfHRVkWAJ8Qd5EiCOk3b0A X-Received: by 2002:a17:906:27cc:: with SMTP id k12mr2349181ejc.181.1572944355854; Tue, 05 Nov 2019 00:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572944355; cv=none; d=google.com; s=arc-20160816; b=QARHSEPMieFLy1ekJ+3BrKXZlG7JIjk/TD8l+m3VHFwEzwgpzTna9TzOcXIQKDz0/s yeQEXoulNdsHeNOxkGEQq860B+kzc3XBmpbkk+mnbyPvrrLyOzVuf2osNNdAoEpSYC0D AGWzMsUNOjCosxsFNncB6siYmdyviuBzJJVx5bPYyayNUK1h7SxRTxtXpprSozmHQz6y gnjGmaIDaPFFXenz5JDEnYo9cEhcTcnAcSYNFVbEHgSXlpHmbA3d57w3XK/22iRPWCi/ D1iBGbNI9YA4IxkQsZAcf38eG9Shieg3udk3JeQuNAv+jjFqlGvRopkNcaqAGdxo+qCq Fg6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=ePB2ZQmY2sifU+nwwoHipXio+6LOoXm3aODKbiWSPvI=; b=JJV7aBDS83ottxNy6PJA3iwA4AEvhuedwBjakcD/aIG4XMRHNFnsiQYCO0XBYnQSea /danmJpOE6Y+gFl97+x0aHvVDaVaQF7ph4RzmwxTbJ2WYWDqH7ZWpysI5/Y7VKalETZR UZdLMmKkAPLopU6tNd8klaYRofcxXlx7YpbPE34Af6QOhz/2yHXzzi8LIUh8UYP6PI9+ lRrsK3elDBUS/ySZkpWvL7oMNemR5nwQcuzbBT9RHJaXrFZBkNIPWWa9CZY2luWq8L+s 4MXlgYOXZ+ez4/4OBZvcjvIXqiVrMVM2CcVHf/LaHBVCUR06Fn5wtyjSvnY+sCXKkE5n JyTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O5kg6ivk; 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 g11si12661084ejj.11.2019.11.05.00.58.52; Tue, 05 Nov 2019 00:59:15 -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=O5kg6ivk; 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 S1730569AbfKEI5C (ORCPT + 99 others); Tue, 5 Nov 2019 03:57:02 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39425 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730502AbfKEI5B (ORCPT ); Tue, 5 Nov 2019 03:57:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572944220; 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=ePB2ZQmY2sifU+nwwoHipXio+6LOoXm3aODKbiWSPvI=; b=O5kg6ivkJS5VzdoaoCRE4n4UimbTzx3aNyPc1vaBwWIbWn2MptffR0vS53ppg7SaLB6KwN r8b57eggEOSVmA8NUkw/RrDT7bF6PRlz6bhIQJiupJb4O/EoL2P26JOf0oAZOjAfZMpoSr Ea9WpAf6/dKAHkXqez6wmuzlWqeQn1E= 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-51-s5fQEbBQNE-l8mw9EbzlxA-1; Tue, 05 Nov 2019 03:56:57 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 078B6477; Tue, 5 Nov 2019 08:56:55 +0000 (UTC) Received: from [10.36.117.253] (ovpn-117-253.ams2.redhat.com [10.36.117.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6B26600C4; Tue, 5 Nov 2019 08:56:51 +0000 (UTC) Subject: Re: [RFC] mm: gup: add helper page_try_gup_pin(page) To: Jerome Glisse , 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 References: <20191103112113.8256-1-hdanton@sina.com> <20191104043420.15648-1-hdanton@sina.com> <20191104102050.15988-1-hdanton@sina.com> <20191104190355.GH5134@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <2f271007-0a46-bc9f-fca9-4fceeb819cc1@redhat.com> Date: Tue, 5 Nov 2019 09:56:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191104190355.GH5134@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: s5fQEbBQNE-l8mw9EbzlxA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04.11.19 20:03, Jerome Glisse wrote: > 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 gupers >>>> 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 those > 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 > I personaly think that we should use bounce page for writeback so that > writeback can still happens if a page is GUPed. John's patchset is the > first step to be able to identify GUPed page and maybe special case them. >=20 >> >>> And even though we are seeing some work to reduce the number of places >>> in the kernel that call get_user_pages(), there are still lots of call = sites. >>> That means lots of combinations and situations that could result in mor= e >>> than one gup call per page. >>> >>> Furthermore, there is no mechanism, convention, documentation, nor anyt= hing >>> at all that attempts to enforce "for each page, get_user_pages() may on= ly >>> be called once." >> >> What sense is this making wrt the data corruption resulting specifically >> from multiple gup references? >=20 > Multiple GUP references do not imply corruption. Only one or more devices > writing to the page while writeback is happening is a cause of corruption= . > Multiple device writting in the same page concurrently is like multiple > CPU thread doing the same. Either the application/device drivers are doin= g > this rightfully on purpose or the application has a bug. Either way it is > not our problem (note here i am talking about userspace portion of the > device driver). >=20 If I'm not completely off, we can have multiple GUP references easily by=20 using KVM+VFIO. --=20 Thanks, David / dhildenb