From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13222C5DF62 for ; Wed, 6 Nov 2019 09:22:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C1ABA2173E for ; Wed, 6 Nov 2019 09:22:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1ABA2173E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2B5836B0003; Wed, 6 Nov 2019 04:22:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 265DE6B0006; Wed, 6 Nov 2019 04:22:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A2FA6B0007; Wed, 6 Nov 2019 04:22:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 04F636B0003 for ; Wed, 6 Nov 2019 04:22:54 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id C667E83F0 for ; Wed, 6 Nov 2019 09:22:53 +0000 (UTC) X-FDA: 76125313026.18.death19_190e8a81a2401 X-HE-Tag: death19_190e8a81a2401 X-Filterd-Recvd-Size: 4784 Received: from mail3-163.sinamail.sina.com.cn (mail3-163.sinamail.sina.com.cn [202.108.3.163]) by imf48.hostedemail.com (Postfix) with SMTP for ; Wed, 6 Nov 2019 09:22:51 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([221.219.0.223]) by sina.com with ESMTP id 5DC290E700037C3B; Wed, 6 Nov 2019 17:22:49 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 64694349283913 From: Hillf Danton To: Jerome Glisse Cc: Hillf Danton , John Hubbard , linux-mm , Andrew Morton , linux-kernel , Vlastimil Babka , Mel Gorman , Dan Williams , Ira Weiny , Christoph Hellwig , Jonathan Corbet Subject: Re: [RFC] mm: gup: add helper page_try_gup_pin(page) Date: Wed, 6 Nov 2019 17:22:40 +0800 Message-Id: <20191106092240.1712-1-hdanton@sina.com> In-Reply-To: <20191105042755.7292-1-hdanton@sina.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 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 5 Nov 2019 10:54:15 -0500 Jerome Glisse wrote: >=20 > On Tue, Nov 05, 2019 at 12:27:55PM +0800, Hillf Danton wrote: > > > > On Mon, 4 Nov 2019 14:03:55 -0500 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 g= upers > > > > > > 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 with= out > > > > warning? > > > > > > It can happens today, is it ok ... well no but we live in an imperf= ect > > > 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 exist= ing > > > device driver that we can not break that do wrong thing. > > > > See your point :) > > > > > I personaly think that we should use bounce page for writeback so t= hat > > > writeback can still happens if a page is GUPed. > > > > 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. > > > > 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. > > > > As long as that stability is ensured writeback will no longer need to > > take care of gup pin, long-lived or transient. > > > > 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? >=20 > 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, ...). Because "there is no synchronization whatsoever after GUP happened," we need to take another close look at the reasoning for tracking multiple gupers if the chance of their mutual data corruptions exists in the wild. (If any sync mechanism sits between them to avoid data corruption, then it seems single pin is enough.) > 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. It becomes clearer OTOH that we are more likely than not moving in the incorrect direction, in cases like how to detect gupers and what to do for writeback if page is gup pinned, without a clear picture of the bounce page in the first place. Any plan to post a patch just for idea show? Hillf