Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1455721ybl; Wed, 14 Aug 2019 17:43:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXYfixwsgR01lZ9GcnwoZFlRo3oap6YKL4LEbqbbAmeoMo993tpPz3Xv5ZqVE/2PwoZdyh X-Received: by 2002:a65:6448:: with SMTP id s8mr1490612pgv.223.1565829789022; Wed, 14 Aug 2019 17:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565829789; cv=none; d=google.com; s=arc-20160816; b=y7czQT2do1HoF3H41iNExefJCrVAPdG4vpGYOx7bgGo/vEQ/PbSZBfun3exj2PJxW/ VuXv8CUNLIagUl4u8ufCTEKzzcxfwj1+KjyCgrJ5nXNpwv+h3I/d+1oRhVEugha0cFBa VOBMxWIR5aEshthX4CBxykaP68EWKUDJGf/O1sb2JidrTcNwIUwHXFx+6MLTfTOlyIjR s8hxvPFnfuqKK4yXFLe+GqsrRTfYOE+hrl8PhUH+q3Vn3ZSpJawU8lZJrDUItq18Sofa n7rqYXIkeuX+Hsl4ezOrJmzM0mNW+yvHHuOFLruhRlO/UL+Fvx79zYRZh16RhXotaIZp jkQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SjWxEd5trWQnubGgd93z8JQghkn2ieuomaNUqpFunr8=; b=LFomwZI59pcm9L+8Y+GLgd/ME+Mek9r/iCyaJCghDCenwgxh32XS4xU7HXSGKFMSzX QXiWc8DO8rofe9qzbK39F1s4izRFQrtewa2eG0LbAPpOrDBaEPFM/9IczOAvXuzQ/MM3 B0gUprqmm2iGEKdcCNuLR94svRoM1mfffrlgB2HxdISACLpEr2u53eLqQo4qKKqGDsNP TWyB9Cujvij0QOqKpfm1JR7g3EkCDaOK7X1jlqmMqvrwdmn1bq1S4a4x0MHOaeQe1DN0 iEENNyKaLqvAc7M3sov9dKCWgnxG6kw5M61SDm8+Z5JTwsCoRCttgvSkrCAxHuAIEEui sI8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=XsReatup; 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 h10si257924pje.43.2019.08.14.17.42.15; Wed, 14 Aug 2019 17:43:09 -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=@ziepe.ca header.s=google header.b=XsReatup; 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 S1728774AbfHOAKC (ORCPT + 99 others); Wed, 14 Aug 2019 20:10:02 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:37146 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727217AbfHOAKB (ORCPT ); Wed, 14 Aug 2019 20:10:01 -0400 Received: by mail-qt1-f196.google.com with SMTP id y26so662955qto.4 for ; Wed, 14 Aug 2019 17:10:00 -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:content-transfer-encoding:in-reply-to :user-agent; bh=SjWxEd5trWQnubGgd93z8JQghkn2ieuomaNUqpFunr8=; b=XsReatupBTmqJdBQODBjcynGCD+EFRZj1C84UwqKxIHDJry1koHSXZhFLNthqLNrdI sJvO2xr4Yf8efKKyOEPzz7lmm+x5GdcACC+54eKm4Ge4AB3iU9YvjJ+GUY28eyC1XgX1 yHn7fdbhBHZEjgohLQ+eJwsIhykXJmXNP4Ad2fzIbW68tY8NtCAmf+n/uw1CrUSltNtz Di2z0LFvJ3NxwlbScerLC+k3cfD1cixFWpONt/9P09Wv9Gezy+22yPiI3marKmyMBzcg UiogqqKUE89OdisyiimkZeCXTgAaWaEz0svYJBDgWT9nFweVWM05nK9xTUKar+rpAnbC nO+Q== 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:content-transfer-encoding :in-reply-to:user-agent; bh=SjWxEd5trWQnubGgd93z8JQghkn2ieuomaNUqpFunr8=; b=N/ADRpBcB89SOeuK+L3fMxUGXJo1haKY/JONCx6FsmllzXuM7s53prVUbE9Womjhkx BxLRb3/ptop0IUvpSto+5GQCNFfe607t42I4fU5WTfw8F32xA/6p/nLCfkPaP29bhRnL EfvC8yUGOPpKow9uDXsMh7dx+GeCZT7giYi9jn6gtgu/JQ9KcGOamyqN4E9fykNa2P2O uDd8Kb0IGTjet4Dq5K0rc5FctUuSwkNyLWoKqAG23GH1bd6eW4sw4MiVMGP0+2ukDP2s IqLG3LEEOulLf27QJ3SvZ1R7MQ8GsE6TMQJJ4CB7KtI4VyX9PhDKvdZy+ApQWfmTdWr6 cUBw== X-Gm-Message-State: APjAAAV116ey3t8PE2ExNNfRdy6cVB1o10RI1d5bFjKFWj300+hIhfdc SeD4K9JNcaGIDJePB1O02G+tbg== X-Received: by 2002:a0c:fa89:: with SMTP id o9mr1559689qvn.165.1565827800115; Wed, 14 Aug 2019 17:10:00 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id n21sm762512qtc.70.2019.08.14.17.09.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Aug 2019 17:09:59 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hy3L5-0003Ys-7h; Wed, 14 Aug 2019 21:09:59 -0300 Date: Wed, 14 Aug 2019 21:09:59 -0300 From: Jason Gunthorpe To: Daniel Vetter Cc: LKML , linux-mm@kvack.org, DRI Development , Intel Graphics Development , Chris Wilson , Andrew Morton , David Rientjes , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Michal Hocko , Christian =?utf-8?B?S8O2bmln?= , Greg Kroah-Hartman , Mike Rapoport , Daniel Vetter Subject: Re: [PATCH 4/5] mm, notifier: Add a lockdep map for invalidate_range_start Message-ID: <20190815000959.GD11200@ziepe.ca> References: <20190814202027.18735-1-daniel.vetter@ffwll.ch> <20190814202027.18735-5-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190814202027.18735-5-daniel.vetter@ffwll.ch> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 14, 2019 at 10:20:26PM +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 was thinking about doing something like this.. IMHO only range_end needs annotation, the other ops are either already non-sleeping or only used by KVM. BTW, I have found it strange that i915 only uses invalidate_range_start. Not really sure how it is able to do that. Would love to know the answer :) > Reviewed-by: Jérôme Glisse > Signed-off-by: Daniel Vetter > include/linux/mmu_notifier.h | 6 ++++++ > mm/mmu_notifier.c | 7 +++++++ > 2 files changed, 13 insertions(+) > > diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h > index b6c004bd9f6a..9dd38c32fc53 100644 > +++ b/include/linux/mmu_notifier.h > @@ -42,6 +42,10 @@ enum mmu_notifier_event { > > #ifdef CONFIG_MMU_NOTIFIER > > +#ifdef CONFIG_LOCKDEP > +extern struct lockdep_map __mmu_notifier_invalidate_range_start_map; > +#endif I wonder what the trade off is having a global map vs a map in each mmu_notifier_mm ? > /* > * The mmu notifier_mm structure is allocated and installed in > * mm->mmu_notifier_mm inside the mm_take_all_locks() protected > @@ -310,10 +314,12 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm, > static inline void > mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) > { > + lock_map_acquire(&__mmu_notifier_invalidate_range_start_map); > if (mm_has_notifiers(range->mm)) { > range->flags |= MMU_NOTIFIER_RANGE_BLOCKABLE; > __mmu_notifier_invalidate_range_start(range); > } > + lock_map_release(&__mmu_notifier_invalidate_range_start_map); > } Also range_end should have this too - it has all the same constraints. I think it can share the map. So 'range_start_map' is probably not the right name. It may also make some sense to do a dummy acquire/release under the mm_take_all_locks() to forcibly increase map coverage and reduce the scenario complexity required to hit bugs. And if we do decide on the reclaim thing in my other email then the reclaim dependency can be reliably injected by doing: fs_reclaim_acquire(); lock_map_acquire(&__mmu_notifier_invalidate_range_start_map); lock_map_release(&__mmu_notifier_invalidate_range_start_map); fs_reclaim_release(); If I understand lockdep properly.. Jason