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=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 4AA3FC2D0A8 for ; Wed, 23 Sep 2020 17:12:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9DA5F212CC for ; Wed, 23 Sep 2020 17:12:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="TRkNPai+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DA5F212CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D5E686B005A; Wed, 23 Sep 2020 13:12:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE74E6B005C; Wed, 23 Sep 2020 13:12:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB0116B005D; Wed, 23 Sep 2020 13:12:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id A03986B005A for ; Wed, 23 Sep 2020 13:12:10 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 54A20184AAE90 for ; Wed, 23 Sep 2020 17:12:10 +0000 (UTC) X-FDA: 77294969220.20.army90_5a0058d27158 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 2B7F61801A5DE for ; Wed, 23 Sep 2020 17:12:10 +0000 (UTC) X-HE-Tag: army90_5a0058d27158 X-Filterd-Recvd-Size: 4962 Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Sep 2020 17:12:09 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id k25so519495qtu.4 for ; Wed, 23 Sep 2020 10:12:09 -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=YH/9x4YduAyQyFROAONGfUKpUo9D+DQjCl2dO1jW42c=; b=TRkNPai+t1R0PtqPcyqs6KRV5QEbc5x6RwYBkbneOVWJUErvcMuwUfidTUu24hxvyM QWWezsITBu4MtvOSn52tUC4S+bParRapl0X1mF37RPWvx1qRmxnLLM8IoCpXai2n27mH Xntw7cmjEgXr3GjsThBy3MziR0NoftOW9lGqsGcjV+yx8u8QFsgjEkSpNGzJIVb4yV/T c64V+znpcZwKsPdgLyasu5JkVCGdiuwpf3EiT3C8lUdLMDdxp8CZ3+br0S6bmNmQHaZT /E9bdFiaO7KOWdWGOeoqG7XI9coRz+0HTBpiS3k9dlSFxGSMAv7gKooWZfQwiV2Qj9Go ChwQ== 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=YH/9x4YduAyQyFROAONGfUKpUo9D+DQjCl2dO1jW42c=; b=YzQ5aRK+iY9LxZI0kt9GdYGptS7RINYXhAMpjZYARsU4+71SSlSQ0qIeK8nvRR+t1p idBtAP12x+RwZhTRddrQR3brKMpl2aHuq1i9ejAHDfQdGfr+m0Rn7yGEJhLWkyx+lDCS UfSr0ChJmAcJ7+zD6jFzenWKljP8xy1ai1u4Q+rqJqtRuz3arHHVqGPbtxOQm1qX5b06 7Ar7S4Q7MBT7IoFvbt0CP4GAz5oAzsojZEilWUrRvVJCc1X99L1AdpILkv3/OJdBXFGR bCq7kWLcx0R64wU9qy1IMaSdTm8Y6Kvz/kTM/IP/X3qRyNik06m1tADNvg5Dyy9V2w4e tYlg== X-Gm-Message-State: AOAM532d5wZHPS2xtDxBfkWILSyhbzdn5qIlYDWmFBmHKl7CMogNMbpi SW0rDWLcKL2QqhiEOqTzrd22XQ== X-Google-Smtp-Source: ABdhPJxhAjIHv39LR6OHwFCOae6z68HtgCbw+0HGYa1v5jIrIg/spi3GmVBR2szfKKNfPUBjRm5YCQ== X-Received: by 2002:ac8:1c5a:: with SMTP id j26mr1153667qtk.48.1600881129105; Wed, 23 Sep 2020 10:12:09 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id g25sm259170qto.47.2020.09.23.10.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 10:12:08 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kL8JL-0006N8-Pz; Wed, 23 Sep 2020 14:12:07 -0300 Date: Wed, 23 Sep 2020 14:12:07 -0300 From: Jason Gunthorpe To: Jan Kara Cc: Peter Xu , John Hubbard , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , Oleg Nesterov , Leon Romanovsky , Linus Torvalds , Jann Horn Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned Message-ID: <20200923171207.GB9916@ziepe.ca> References: <20200921211744.24758-1-peterx@redhat.com> <20200921211744.24758-2-peterx@redhat.com> <224908c1-5d0f-8e01-baa9-94ec2374971f@nvidia.com> <20200922151736.GD19098@xz-x1> <20200922161046.GB731578@ziepe.ca> <20200922175415.GI19098@xz-x1> <20200922191116.GK8409@ziepe.ca> <20200923002735.GN19098@xz-x1> <20200923131043.GA59978@xz-x1> <20200923142003.GB15875@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200923142003.GB15875@quack2.suse.cz> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Sep 23, 2020 at 04:20:03PM +0200, Jan Kara wrote: > I'd hate to take spinlock in the GUP-fast path. Also I don't think this is > quite correct because GUP-fast-only can be called from interrupt context > and page table locks are not interrupt safe. Yes, IIRC, that is a key element of GUP-fast. Was it something to do with futexes? > and then checking page_may_be_dma_pinned() during fork(). That should work > just fine AFAICT... BTW note that GUP-fast code is (and this is deliberated > because e.g. DAX depends on this) first updating page->_refcount and then > rechecking PTE didn't change and the page->_refcount update is actually > done using atomic_add_unless() so that it cannot be reordered wrt the PTE > check. So the fork() code only needs to add barriers to pair with this. It is not just DAX, everything needs this check. After the page is pinned it is prevented from being freed and recycled. After GUP has the pin it must check that the PTE still points at the same page, otherwise it might have pinned a page that is alreay free'd - and that would be a use-after-free issue. ason