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.8 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,URIBL_BLOCKED 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 0716AC388F2 for ; Mon, 2 Nov 2020 15:53:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 838BA22258 for ; Mon, 2 Nov 2020 15:53:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="hqSP56nc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 838BA22258 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 BA7F66B0071; Mon, 2 Nov 2020 10:52:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B2FA16B0074; Mon, 2 Nov 2020 10:52:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F5766B0075; Mon, 2 Nov 2020 10:52:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 68E596B0071 for ; Mon, 2 Nov 2020 10:52:59 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0D9D9180AD801 for ; Mon, 2 Nov 2020 15:52:59 +0000 (UTC) X-FDA: 77439921678.04.uncle66_4605f8c272b1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id E1FC1800224C for ; Mon, 2 Nov 2020 15:52:58 +0000 (UTC) X-HE-Tag: uncle66_4605f8c272b1 X-Filterd-Recvd-Size: 5594 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Nov 2020 15:52:58 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id w5so6292156qvn.12 for ; Mon, 02 Nov 2020 07:52:58 -0800 (PST) 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=f4bAkyYQ5JW+w3wAB0B3Wuqs9gDAq+dCKVKb1szgdTE=; b=hqSP56ncN1Xesc0LR+LCBrLcoSGV6TopG9RG3GGTAjXZawK07x4FedOxx8+KwVozhh yTaXjjMacA7HSrB+GRFpwykUXEgHjYuiJRUfTBK6bxwzQkDVZZxpNeA6oR5zy06hcsRr +OWzKfZs32d+rXtNU6sG16vNSbBVRNjen0md3oJEh5m3qEuLJBFDAZd22drwYUhFMUM8 jihAo1Zpdxicjpm3k0zP51jRIixb81HpWfJ8CKClqtFak5XKxto5Xo7s7pUz3s+srShN 1BUfFqWebwl5tOah1zDSpMj6M1bL9GXyO8wQDz9s59OVdbT9CJgBaBWOD1bIDFUY/B+7 N2fQ== 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=f4bAkyYQ5JW+w3wAB0B3Wuqs9gDAq+dCKVKb1szgdTE=; b=TWm3PVjXxjcB4SCDoC+3PWM9BXrYA25tfJE7Ky6LgXnP93u88f9Tag4IwjdcgEXtaC R1gk964Ab/4+ag0SdnvUE6Z4S8Z2HwRy6FhA2YGMdvCC99tj0BSN9jsdrYp8bmb4voiw dJ3OfTvqqIPjvgodc3VN5NdYJa7kToM+cpuvpjCdL017qWjOIfewKRHZ4Zr6YvgWl//Q IIp70dezGweGSjJfTvTCGD4wwEVN5eKR/Gzl2LlPvdkeD/bppC2geJMo1Cx1pUX/B9o+ 6mPB3kWMe+MKxY9m2dPMUjslY74WFLLeXZaP0tx0rA0Ifg/KuoT8st63ZOgUjyxGh4zF BqxQ== X-Gm-Message-State: AOAM532gbPEcM8kFZe6BUfBRcM6VPMDhLpHEJjDF348kJ5BgGFbZD2u0 3CdW9ZgkgHEoN9XDb5i8oFCWxA== X-Google-Smtp-Source: ABdhPJywaNhw5aFpN/pYIk6/MJ/bkf/gh0tZ3udL0VlE8QqDUlZAs/BeSFGHSpJn56VGOhuQYMqcFg== X-Received: by 2002:a0c:a261:: with SMTP id f88mr23351432qva.56.1604332377746; Mon, 02 Nov 2020 07:52:57 -0800 (PST) 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 v92sm8169357qte.33.2020.11.02.07.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 07:52:56 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kZc8e-00F975-6s; Mon, 02 Nov 2020 11:52:56 -0400 Date: Mon, 2 Nov 2020 11:52:56 -0400 From: Jason Gunthorpe To: Daniel Vetter Cc: Christoph Hellwig , DRI Development , LKML , KVM list , Linux MM , Linux ARM , linux-samsung-soc , "open list:DMA BUFFER SHARING FRAMEWORK" , Daniel Vetter , Kees Cook , Dan Williams , Andrew Morton , John Hubbard , J??r??me Glisse , Jan Kara Subject: Re: [PATCH v5 08/15] mm: Add unsafe_follow_pfn Message-ID: <20201102155256.GG36674@ziepe.ca> References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-9-daniel.vetter@ffwll.ch> <20201102072931.GA16419@infradead.org> <20201102130115.GC36674@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon, Nov 02, 2020 at 02:23:58PM +0100, Daniel Vetter wrote: > On Mon, Nov 2, 2020 at 2:01 PM Jason Gunthorpe wrote: > > > > On Mon, Nov 02, 2020 at 01:56:10PM +0100, Daniel Vetter wrote: > > > On Mon, Nov 2, 2020 at 8:29 AM Christoph Hellwig wrote: > > > > > > > > On Fri, Oct 30, 2020 at 11:08:08AM +0100, Daniel Vetter wrote: > > > > > Also mark up follow_pfn as EXPORT_SYMBOL_GPL. The only safe way to use > > > > > that by drivers/modules is together with an mmu_notifier, and that's > > > > > all _GPL stuff. > > > > > > > > I also think it also needs to be renamed to explicitly break any existing > > > > users out of tree or int the submission queue. > > > > > > Ok I looked at the mmu notifier locking again and noticed that > > > mm->subscriptions has its own spinlock. Since there usually shouldn't > > > be a huge pile of these I think it's feasible to check for the mmu > > > notifier in follow_pfn. And that would stuff this gap for good. I'll > > > throw that on top as a final patch and see what people think. > > > > Probably the simplest is to just check mm_has_notifiers() when in > > lockdep or something very simple like that > > lockdep feels wrong, was locking more at CONFIG_DEBUG_VM. And since > generally you only have 1 mmu notifier (especially for kvm) I think we > can also pay the 2nd cacheline miss and actually check the right mmu > notifier is registered. Need to hold the lock to check that and there are two ways to register notifiers these days, so it feels to expensive to me. CH's 'export symbol only for kvm' really does seem the most robust way to handle this though. Jason