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 0DF8AC55178 for ; Mon, 2 Nov 2020 13:24:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 791C5222BA for ; Mon, 2 Nov 2020 13:24:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="Redsc76/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 791C5222BA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9A81C6B0072; Mon, 2 Nov 2020 08:24:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 957B76B0074; Mon, 2 Nov 2020 08:24:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8465C6B0075; Mon, 2 Nov 2020 08:24:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 56D5A6B0072 for ; Mon, 2 Nov 2020 08:24:11 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E6200362B for ; Mon, 2 Nov 2020 13:24:10 +0000 (UTC) X-FDA: 77439546660.06.slave27_060e884272b0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id BC0D0100404E7 for ; Mon, 2 Nov 2020 13:24:10 +0000 (UTC) X-HE-Tag: slave27_060e884272b0 X-Filterd-Recvd-Size: 4533 Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Nov 2020 13:24:10 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id j7so14588507oie.12 for ; Mon, 02 Nov 2020 05:24:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JGM5iJVe1/YS3RI7Ox6P0c/NeEFHo7I8woI64ttdcHw=; b=Redsc76//XOqhmrR47LrRhhRKZfVgrPgcKjaj3flUUV05IMeYYgYI96W5nS3FoZvN7 n0yN3r95mirzqxFiZdIGicTdRpE+APj1YYPKDXlNxKd2lAM4+mMT2WniX47hjE9Yln3I Y2p0Ua++jSUdgHYquFbAF5VAHeKUIvWvGxWx4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JGM5iJVe1/YS3RI7Ox6P0c/NeEFHo7I8woI64ttdcHw=; b=KWu7CV33w3k4hv31plP4gqg4AkFI/1mGUKRDaH4EjTWOjji9rEoYDO43A2N+ACBEXm HkB/XcE/Aw9jx87QvNgn2bS6+/Hhf7KlSV1taDXV7kTVFU1/BZBSYhMmws6/iDp7AGF3 bDwAy3KiZTWRUqe1bobdM2OlFInTD16pqDjNpzx6xBHv1IGnLI6HGgBDdNqCcXrYTlJn 0Du8ai2PBY88tvRgyg8NmNJzD+iU6BLZkvZdGtx98fGUvFyZKDhfkbJjz1hMMHkiuOjY tU+snQSAEiVjE/NlcigNfuZwdv4qBTSraQ7MrCBsE6LwXNWZ8KwoLOEtQgq1K4PsPpkv +cng== X-Gm-Message-State: AOAM530W8MOcM1wh0pSbcSIvwd13Mtnf2Du+IfARrGpt5STYe0bgNhWR EfZZeIsLgMPmT19omKoYEPon+aIaEl04MM2kaa8Xog== X-Google-Smtp-Source: ABdhPJz6z2w7hj9FcAzqiJvVAZYDEwQ1hz51TSyVs1UuhBMkzKJELH0Nji35ZsSbH8nvJRYlHjcaT+TvGc3KsVWMNe0= X-Received: by 2002:aca:b141:: with SMTP id a62mr9289032oif.101.1604323449305; Mon, 02 Nov 2020 05:24:09 -0800 (PST) MIME-Version: 1.0 References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-9-daniel.vetter@ffwll.ch> <20201102072931.GA16419@infradead.org> <20201102130115.GC36674@ziepe.ca> In-Reply-To: <20201102130115.GC36674@ziepe.ca> From: Daniel Vetter Date: Mon, 2 Nov 2020 14:23:58 +0100 Message-ID: Subject: Re: [PATCH v5 08/15] mm: Add unsafe_follow_pfn To: Jason Gunthorpe 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 Content-Type: text/plain; charset="UTF-8" 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 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. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch