Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1126172ybm; Tue, 21 May 2019 09:02:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9cR3b5c4cgGcW9zPTHO14yeVv0NqX3dLA4LzgwBlGGU4+Q3Oi3hhtHrf8ropJCdSvwMI1 X-Received: by 2002:a17:902:28c9:: with SMTP id f67mr64324578plb.190.1558454541539; Tue, 21 May 2019 09:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558454541; cv=none; d=google.com; s=arc-20160816; b=MRuwkpjSnyR/VzKBhYdWdXxCsNTv6oidLEp0WhP2ZqZELMjQhJliQU9trZD0poBq9q pzdP3GyceB8y5aviDlaiLrztUJuobLrixPqDeG8EKZABTmXmcDGoOGTauw/ds9jLpiiR pDVFYhS29C26EXBCHifSGVaa8ei66nxEYk3nKpMYoZVS7neMCSyGxN0imajuReQgwyWi 2GqtjMbW2MjqCjT/AsjXgb43Jtyti3fstRjz2YcYTibOHn0xzRL5tfuHaxQXnEHAof/l akj88/6S/KuLuxTM/IuydBeMRN25gQO0urfPSTFAe1KECAu6f0pIJ7oN0n3I6InEuTJW 4piw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=NhMdeTlwpp1ipABlk4vrZFRm+ansgm/gZL6cQawSF+c=; b=TEObOUyd7QaKYCXkuytBW7lGzYEkWkgAT/e3l6fWlWgnYxInBL7KpsJf8WcJMau/D4 2c6s7m4J8mT3pvpSu1kaNWAL1dv4hauPkSjDHaol/YBNsGQNFzHnbZTodKHkJ4SXQhjD M8H6JrC+8sXX7dieqytFxdMW/Tn8pu5MPIoUpB7GMy5Rlw9XIWxF+EJwa0l2JAAm7Hs9 SiLwgJqouAISHSWFTqfCjyK0TPmH2as3hhyUZS7Ek65z6KdCdzt+Z23fqLWXYv12b4PP XgemPgS/Bjxz4Rjr6hfk7I0PYt+VGkAtgU/GQXNv8ulYHfYqpGjWykve+/3ABJP0l2+V wkiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=iWPYjGwy; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si20574516plr.209.2019.05.21.09.02.03; Tue, 21 May 2019 09:02:21 -0700 (PDT) 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=@ffwll.ch header.s=google header.b=iWPYjGwy; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728678AbfEUQAt (ORCPT + 99 others); Tue, 21 May 2019 12:00:49 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:42292 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbfEUQAs (ORCPT ); Tue, 21 May 2019 12:00:48 -0400 Received: by mail-oi1-f193.google.com with SMTP id w9so11387952oic.9 for ; Tue, 21 May 2019 09:00:48 -0700 (PDT) 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=NhMdeTlwpp1ipABlk4vrZFRm+ansgm/gZL6cQawSF+c=; b=iWPYjGwyHiS4RY9vwsXeZ8i6fKnHYt4FFltlGbL8zLBXNA8i8brUrULMsuEhL8dHVf mFcmOyqSuXprZfVNumy/KKsfMmPjtpula612aIpH4kUKtfFSu1IVVl9/lN7lo1EbO5Di Nm953Hx97nGZEsz7iDskJM7qE79xpAl3pv/ys= 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=NhMdeTlwpp1ipABlk4vrZFRm+ansgm/gZL6cQawSF+c=; b=M6tuItgkfZ068A0ugYYQTOca1p3M56V9vrMI6D+bWsBpl4lj4RIFEabb/UWq3NWrMo x8IFpP8KYuB/CKpYkYNX+lHhDyAkvOG8aUNAM/g4oQdhX8rCIbj1NgrAoRrlrTCVUvUP dOGx8pEvRzYl6lX4mq0OvHSVT7b2zL3zV40YZZHAJBTP+8T8YFOWAom5WBBDPLunoFBm AMQvwzJSh8Q8+k4j3xTVlCTaEsKs6e32ONMoT2p5nn41oOVHUAq0ScjCxhlKzSpVqPIl qJiksDfSgfUEtsKFW2ebT8TK+TW7J3RSW+uqITW5yQ6Wahr00TK0FenljEXjDgvk98L3 F5Zw== X-Gm-Message-State: APjAAAWWaR5evPg2c4ahEOg9AmbG6TDA9S1pHiQFk470P1xNGh9NVm0V qeL79sdu/J/EG+tSIPrNFTsYn9NUHRPEuukby75/xw== X-Received: by 2002:aca:e4c8:: with SMTP id b191mr4039039oih.110.1558454448157; Tue, 21 May 2019 09:00:48 -0700 (PDT) MIME-Version: 1.0 References: <20190520213945.17046-1-daniel.vetter@ffwll.ch> <20190520213945.17046-4-daniel.vetter@ffwll.ch> <20190521154059.GC3836@redhat.com> In-Reply-To: <20190521154059.GC3836@redhat.com> From: Daniel Vetter Date: Tue, 21 May 2019 18:00:36 +0200 Message-ID: Subject: Re: [PATCH 4/4] mm, notifier: Add a lockdep map for invalidate_range_start To: Jerome Glisse Cc: DRI Development , Intel Graphics Development , LKML , Linux MM , Chris Wilson , Andrew Morton , David Rientjes , Michal Hocko , =?UTF-8?Q?Christian_K=C3=B6nig?= , Greg Kroah-Hartman , Mike Rapoport , Daniel Vetter Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 21, 2019 at 5:41 PM Jerome Glisse wrote: > > On Mon, May 20, 2019 at 11:39:45PM +0200, Daniel Vetter wrote: > > This is a similar idea to the fs_reclaim fake lockdep lock. It's > > fairly easy to provoke a specific notifier to be run on a specific > > range: Just prep it, and then munmap() it. > > > > A bit harder, but still doable, is to provoke the mmu notifiers for > > all the various callchains that might lead to them. But both at the > > same time is really hard to reliable hit, especially when you want to > > exercise paths like direct reclaim or compaction, where it's not > > easy to control what exactly will be unmapped. > > > > By introducing a lockdep map to tie them all together we allow lockdep > > to see a lot more dependencies, without having to actually hit them > > in a single challchain while testing. > > > > Aside: Since I typed this to test i915 mmu notifiers I've only rolled > > this out for the invaliate_range_start callback. If there's > > interest, we should probably roll this out to all of them. But my > > undestanding of core mm is seriously lacking, and I'm not clear on > > whether we need a lockdep map for each callback, or whether some can > > be shared. > > I need to read more on lockdep but it is legal to have mmu notifier > invalidation within each other. For instance when you munmap you > might split a huge pmd and it will trigger a second invalidate range > while the munmap one is not done yet. Would that trigger the lockdep > here ? Depends how it's nesting. I'm wrapping the annotation only just around the individual mmu notifier callback, so if the nesting is just - munmap starts - invalidate_range_start #1 - we noticed that there's a huge pmd we need to split - invalidate_range_start #2 - invalidate_reange_end #2 - invalidate_range_end #1 - munmap is done But if otoh it's ok to trigger the 2nd invalidate range from within an mmu_notifier->invalidate_range_start callback, then lockdep will be pissed about that. > Worst case i can think of is 2 invalidate_range_start chain one after > the other. I don't think you can triggers a 3 levels nesting but maybe. Lockdep has special nesting annotations. I think it'd be more an issue of getting those funneled through the entire call chain, assuming we really need that. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch