Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3466930imu; Mon, 10 Dec 2018 02:42:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/VSy93eOZHm7A3up84X+1+fRao77YPqNkM0BtPYwk6VgDTS1thdxd8ajkdw/Qyixu3jdrNQ X-Received: by 2002:a63:9402:: with SMTP id m2mr10051237pge.93.1544438559617; Mon, 10 Dec 2018 02:42:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544438559; cv=none; d=google.com; s=arc-20160816; b=p+scUjwmZkZh4PZClMGraSZTklv4uMMo+R+Uxgnn9zGLf/s8yi05g/cbfMxa4IV/5/ wo2zGnjwIuKAERnDqzY6DTIXq5BinEGjrNjaY/Rb+DUlNh6oNvMd0waAJKbHpyZlqBW6 Kt8p7BLv+XSEpggRC81HsngFaf3R5kl4KG/Y6xE4t4iHiIJ4aocxsEQp2WPenHSU9xmH gKWEUQ/WcCUvhJ/SElcgzVSo8QWJ0yz+UfxI6tj2j89fPCtIvAxehAdlP/zhLw0hyYkK eUGqOGEULxjnpJqAslEkbtAYcramXyyrwr4zTWO3pSAdMY04uf3JKYY3AayyriABVtTW P7ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c6Z9o1UxIwE7Qp4GM9ozZMxGfybJeBYWvC+NX0jB8Ig=; b=Cspyt260+N96504EG/wRyokEiVnUYN+iwn0/9BcwBhk1bgMll7meRLcNP6PHEFz1Xb nHY/DH9XKSv+DqFcRg7uGdXPVnyh6HYIcrIyf6jdSt2uhdsfW5qlRZFRhZlsk/o+7hNV H2P7wxphfHrqohJuLGHHI3ncYxLzE54oKA6+zNHx5E0H8/ah2ncH3MtqQH1l/H03AO6o lyE/V9N5T5SgI0oA51aDlEA9/uVcmg0O4ZLyTA/GPiOGVkYKo0irv+rq+IPXqHvAEBFN nxH3uTucpSmwq1FLKL2ho+RQ+rQg4wuDgAjBWeH9AVszrKHD6pkNjHMh55JzNZuXn/0H FJDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=icP2AHNm; 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 m65si10894535pfg.282.2018.12.10.02.42.24; Mon, 10 Dec 2018 02:42:39 -0800 (PST) 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=icP2AHNm; 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 S1727316AbeLJKg6 (ORCPT + 99 others); Mon, 10 Dec 2018 05:36:58 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:41402 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbeLJKgz (ORCPT ); Mon, 10 Dec 2018 05:36:55 -0500 Received: by mail-ed1-f67.google.com with SMTP id z28so9014705edi.8 for ; Mon, 10 Dec 2018 02:36:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c6Z9o1UxIwE7Qp4GM9ozZMxGfybJeBYWvC+NX0jB8Ig=; b=icP2AHNmcD+B4xLZa9BqY9xY3/IFbnZyMH88+fTJ6npgQP++AoT86deQ+1xEADFajI lv4tzBLHCpf4+pdhpXVTVHN6gGHV6ApiDf4REPSgiGhykR/Kvu5HBWTVUjq3FxwLwJDg CL0fC11rqPywTMOksfy8+IKeWwhPykofEf6os= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c6Z9o1UxIwE7Qp4GM9ozZMxGfybJeBYWvC+NX0jB8Ig=; b=dLTa4Zha6W5YAgSROOZrd+GZb5Fxw2IvhbPtPFquUndOvvti+1h1zD7bn+ivXDKbp4 S+r2anJGMwLXAZwesO0D4RYChMaPQWaaDNVsMCsZqGNzRd8xEt0OFua1tbMx6SmKoIhC 6A/oJ0EH3TwBNHgSRQz/Qrvb1gL/+ginVDZd6vjvjYcdQTU/Xgm1D6AcA3Xxg7EJPdDc lmGxmVqnSqIaMS2K0FOednzd+bbdwY6yHoDlvMbCqcYTB6o4z88L5d9kusJr/oNAhFTP b+B9HXAHYUKqnl0yr3BINjeL7qEfDtaYPWSsaYk+WJ6Pzs06HmNez+E70OZa0Rk6rWjK nDlw== X-Gm-Message-State: AA+aEWbkvz+np84vvREOZKojfWyzmhCIUOaRlcOg43JPDwPnUh8al+Fe pK5QfbMP2AKfRjNW2QusllnQ+g== X-Received: by 2002:a50:8f44:: with SMTP id 62mr10781951edy.264.1544438213379; Mon, 10 Dec 2018 02:36:53 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id q50sm3223862edd.66.2018.12.10.02.36.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 02:36:52 -0800 (PST) From: Daniel Vetter To: Intel Graphics Development Cc: DRI Development , LKML , linux-mm@kvack.org, Daniel Vetter , Chris Wilson , Andrew Morton , David Rientjes , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Michal Hocko , =?UTF-8?q?Christian=20K=C3=B6nig?= , Greg Kroah-Hartman , Mike Rapoport , Daniel Vetter Subject: [PATCH 4/4] mm, notifier: Add a lockdep map for invalidate_range_start Date: Mon, 10 Dec 2018 11:36:41 +0100 Message-Id: <20181210103641.31259-5-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181210103641.31259-1-daniel.vetter@ffwll.ch> References: <20181210103641.31259-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. v2: Use lock_map_acquire/release() like fs_reclaim, to avoid confusion with this being a real mutex (Chris Wilson). Cc: Chris Wilson Cc: Andrew Morton Cc: David Rientjes Cc: "Jérôme Glisse" Cc: Michal Hocko Cc: "Christian König" Cc: Greg Kroah-Hartman Cc: Daniel Vetter Cc: Mike Rapoport Cc: linux-mm@kvack.org 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 9893a6432adf..19be442606c6 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -12,6 +12,10 @@ struct mmu_notifier_ops; #ifdef CONFIG_MMU_NOTIFIER +#ifdef CONFIG_LOCKDEP +extern struct lockdep_map __mmu_notifier_invalidate_range_start_map; +#endif + /* * The mmu notifier_mm structure is allocated and installed in * mm->mmu_notifier_mm inside the mm_take_all_locks() protected @@ -267,8 +271,10 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm, static inline void mmu_notifier_invalidate_range_start(struct mm_struct *mm, unsigned long start, unsigned long end) { + lock_map_acquire(&__mmu_notifier_invalidate_range_start_map); if (mm_has_notifiers(mm)) __mmu_notifier_invalidate_range_start(mm, start, end, true); + lock_map_release(&__mmu_notifier_invalidate_range_start_map); } static inline int mmu_notifier_invalidate_range_start_nonblock(struct mm_struct *mm, diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index a50ed7d1ecef..c91d58fe388b 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -23,6 +23,13 @@ /* global SRCU for all MMs */ DEFINE_STATIC_SRCU(srcu); +#ifdef CONFIG_LOCKDEP +struct lockdep_map __mmu_notifier_invalidate_range_start_map = { + .name = "mmu_notifier_invalidate_range_start" +}; +EXPORT_SYMBOL_GPL(__mmu_notifier_invalidate_range_start_map); +#endif + /* * This function allows mmu_notifier::release callback to delay a call to * a function that will free appropriate resources. The function must be -- 2.20.0.rc1