Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5369693imu; Tue, 29 Jan 2019 18:22:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN423C6i7l9r5pxmF9R89mCa4ytOvS4sA7aHVo9JKhNo/fUnQU6WCYTQEK2w+4TIjZcR6hmo X-Received: by 2002:a62:520b:: with SMTP id g11mr29130691pfb.53.1548814940625; Tue, 29 Jan 2019 18:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548814940; cv=none; d=google.com; s=arc-20160816; b=nx53ZfRrqz+FMVNl+7mgdQo+wcTn++nF97H4Egub4R6J4PQ/AItTMp/9+hftwIWTIV blpuT8dH1xZlNJdD9NkVt1sypQylvHkdoHmNzaydbfbcOYQrsb3rkXvCEbBREIO8UV1T 8KzT8ZrzVgCy0ycl19uUAdS/gtvcG+07RRtIfW7L3S12rmmnm7ZJ1s71GfK7wNZosfTv JMf/LkFQ8VaiCA7WuJG0s4hSWVBdrfCRR+/+6uAYEaPNhFs/eAbDythYDELmV+pG03lp JdLEcfPtIAG657rGGoHi6fyx47jLEnHFawpiHaUYZ7C//80yJsTM15sYHbYiObdzZEsE DpQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=fhXjDs+tpYnR9fC2/TPq13qS+GooJ05aAT+eGKah/Nc=; b=hlHQNRelhiYkkd7BzL2bHRkCBx294wUewyhBLlgZ1IcAPqScGExi9CTdSJ04OOXFnR HNnOynotp3F98PqYp6WvKOUxo7ppftfGHFXlQFRvufAD6M560iq0bDRZ1mIOrCmV+v7D yWtLCkqGmGUFKkhOzwVGjlvjZXbKmVYxZ+rN4imXEt5Q99imN0NsH1QEpWBTdx2SrRvg oiqkiehCxwuqNmdjUkiaLSWk3H+asKVyvTaDMKGddE4jwJrZqlZLcOVEV9WdZ2QL3VKD YRL+jLBagd4oLVOX0oEdg1i7UHqyNVFmH5Gs6YDseVfmNaArtCpslbl8wKRcoRiFb1vX ogwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=sPI+brV6; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si174541plr.355.2019.01.29.18.22.04; Tue, 29 Jan 2019 18:22:20 -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=@nvidia.com header.s=n1 header.b=sPI+brV6; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729736AbfA3CV7 (ORCPT + 99 others); Tue, 29 Jan 2019 21:21:59 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:5651 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727658AbfA3CV7 (ORCPT ); Tue, 29 Jan 2019 21:21:59 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 29 Jan 2019 18:21:29 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 29 Jan 2019 18:21:57 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 29 Jan 2019 18:21:57 -0800 Received: from [10.110.48.28] (172.20.13.39) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 30 Jan 2019 02:21:56 +0000 Subject: Re: [PATCH 1/2] mm: introduce put_user_page*(), placeholder versions To: Jan Kara CC: Jerome Glisse , Matthew Wilcox , Dave Chinner , Dan Williams , John Hubbard , Andrew Morton , Linux MM , , Al Viro , , Christoph Hellwig , Christopher Lameter , "Dalessandro, Dennis" , Doug Ledford , Jason Gunthorpe , Michal Hocko , , , Linux Kernel Mailing List , linux-fsdevel References: <20190116130813.GA3617@redhat.com> <20190117093047.GB9378@quack2.suse.cz> <20190117151759.GA3550@redhat.com> <20190122152459.GG13149@quack2.suse.cz> <20190122164613.GA3188@redhat.com> <20190123180230.GN13149@quack2.suse.cz> <20190123190409.GF3097@redhat.com> <8492163b-8c50-6ea2-8bc9-8c445495ecb4@nvidia.com> <20190129012312.GB3359@redhat.com> <3c3bb2a3-907b-819d-83ee-2b29802a5bda@nvidia.com> <20190129101225.GB29981@quack2.suse.cz> From: John Hubbard X-Nvconfidentiality: public Message-ID: <1e4e9c5f-c04a-0e8e-cdfb-b41e365cc2a2@nvidia.com> Date: Tue, 29 Jan 2019 18:21:56 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190129101225.GB29981@quack2.suse.cz> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL103.nvidia.com (172.20.187.11) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8" Content-Language: en-US-large Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1548814889; bh=fhXjDs+tpYnR9fC2/TPq13qS+GooJ05aAT+eGKah/Nc=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=sPI+brV6Qvw/eIScEgWNgUoEvVL196Fgzc04hVs5GBaB8Rk8KYZVPak3EyeDQwzkJ 53atJ5nzMIrLtx0nUOU2Qrm/tOEStFQUGy7NEgJEnrzi+8M6cuhOyCZYCAFQzGvZgY uAF//7owMXO/sGw0hSJPAtCdIVA32fkAEQoGkjG3On8pdYURsezHM6IH0gysC8Ason WrU3V8JLeChDW6y5KMA2yh5xSHa6J2Uw70jeRTfraQxT7wLnoDhMqXl2mtQQNOKCua RyFyxucd2MaJBEW0O5tEpa2PxijtV75UrYcc9gql21NkQuzcoEWy2dJkXpTXWQI5b0 EpFZMJA3cNb1Q== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/29/19 2:12 AM, Jan Kara wrote: > On Mon 28-01-19 22:41:41, John Hubbard wrote: [...] >> Here is the case I'm wondering about: >> >> thread A thread B >> -------- -------- >> gup_fast >> page_mkclean >> is page gup-pinned?(no) >> page_cache_get_speculative >> (gup-pins the page here) >> check pte_val unchanged (yes) >> set_pte_at() >> >> ...and now thread A has created a read-only PTE, after gup_fast walked >> the page tables and found a writeable entry. And so far, thread A has >> not seen that the page is pinned. >> >> What am I missing here? The above seems like a problem even before we >> change anything. > > Your implementation of page_mkclean() is wrong :) It needs to first call > set_pte_at() and only after that ask "is page gup pinned?". In fact, > page_mkclean() probably has no bussiness in checking for page pins > whatsoever. It is clear_page_dirty_for_io() that cares, so that should > check for page pins after page_mkclean() has returned. > Perfect, that was the missing piece for me: page_mkclean() internally doesn't need the consistent view, just the caller does. The whole situation with two distinct lock-free algorithms going on here actually seems clear at last. :) Thanks (also to Jerome) for explaining this! thanks, -- John Hubbard NVIDIA