Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3154157imu; Fri, 23 Nov 2018 22:51:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/UxhG+fLYbUjitF4vCdprtezuKbS1fBIO3Ao7MtS8trfLDmchEX1794kJ11eR6rTbZrCebT X-Received: by 2002:a17:902:161:: with SMTP id 88mr3609854plb.306.1543042317494; Fri, 23 Nov 2018 22:51:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543042317; cv=none; d=google.com; s=arc-20160816; b=Skp5kTpfMJYdkq7eEyuUGs+m3aKv/rOZnZxK87jnyU2DHxq3B1B+xaMOzE55A3YsmR 0O6bZJwYy1M5QiHsXyGjIEt6Ew117RdTglW0k2r/F3aRLbq523jzTP2lY90o+IzHZ/3C 9QSIaXLpZmJoBehIxr+tOiUnEljs/26/J8pm4uaUcs1aBrC/wEU3l03Y3uerQUYpiH5f GN2h8D5tw8kiMWQuvyB9EvqTk2TBF0MgwkWT9X+f6sGsftHpnfkCaxx+mvcsTCkfGbWs CNiyC7GZDbuu195O5ltbjt6Zhn1oaNslQwfhVezGpB5jxKjLeV0QNyK/Fdcc5GOn/A8H 19UQ== 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=IqCNVNv0Y8aoRKucGwKEjdCDvF336AuZYaELjzjP6Ls=; b=Vwfhq2F2qDEq3RlCjNhhMFBaE0t4rWJaAlvKRCFnr7c/62t/Q4GcJj6sa1rwlTREK+ nKZYWL7MQ+K7zYPTM5ArPACBR+J6OhDN6eNF5B7cT+iTIiLsHGIM7brX+v3Tfw9T7NuC NwsXKpmFho/aCk/evNCZg53IAAxhXrNSO6cLRHqRDvqRdtbj61Oja6ypOGixquWtf2oX jG+LAsTwSd5oGj5vrP/BAGCt9Jd7Asf1jHcIv/Ju1s1H/vyzUG9gxgQUNwI3NaQ6dY/Z EINHjNh9K4NpkfbMyaFTfihk540qGvkKf618nbRKVnLtEFxtQK/k0rH+cQT3M69Ycg0K H2VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="MMzYO6/w"; 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 h1-v6si58110168pld.332.2018.11.23.22.51.42; Fri, 23 Nov 2018 22:51:57 -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="MMzYO6/w"; 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 S2406049AbeKWDba (ORCPT + 99 others); Thu, 22 Nov 2018 22:31:30 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:43935 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730624AbeKWDb3 (ORCPT ); Thu, 22 Nov 2018 22:31:29 -0500 Received: by mail-ed1-f66.google.com with SMTP id f4so8199520edq.10 for ; Thu, 22 Nov 2018 08:51:17 -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=IqCNVNv0Y8aoRKucGwKEjdCDvF336AuZYaELjzjP6Ls=; b=MMzYO6/waCjCYerQTkvOeF8GBYcFu0U7oI6tc9TyEKstlXpVLz2o7sa6oi3lFZfhPG v38/v1GFssxWyCYmgz0LqI9Sm+APanFajOvvvpBoCT/nfxyAUye3LZpj1po5QpUN12NU adNcLC9JNMKYMy36LmWpSDW8/uY5Z48mR9P1w= 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=IqCNVNv0Y8aoRKucGwKEjdCDvF336AuZYaELjzjP6Ls=; b=gpT1tHhXCctHZGihc/tfYwd733Y6npspdCFOGVb+hgxX8RE/vRUe+GWYDezPdEliKe 8112X3DT0OoaUNelD6qt7HZ/tdyqIiFTvOjn+lYkgjhR28yg5Uo5WBAYVGdL8AsTkdjn RnGcu5RabHNk9Ph4Ey52uelE/D6/9kqbQ6hyevTTgg3cbxmrzAbQQwvJxqpW4G2c8Nvv 8dGafgIyrerZ+8YIU4X+6zRF4D2Zi7srPMdU8+l9ma3MTGbxybXV9wI3kqg7k0fHovx9 HWEZUXT1CJAhRhi6fBFDQyb2FQKivpcmqE69tBtjhXKO0qFSu8doYwZwPg1WEumZ4Bb7 7GtA== X-Gm-Message-State: AA+aEWbOOysnaurxPFXigJNerLKhgAQ2I3ztpXA85bhJPNPXD0y/c4cz PBPPaUFpZnTjis7GFnkTTCZBapOgHzI= X-Received: by 2002:a50:fd0e:: with SMTP id i14mr9994539eds.98.1542905476815; Thu, 22 Nov 2018 08:51:16 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id s12sm12914780edb.43.2018.11.22.08.51.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 08:51:16 -0800 (PST) From: Daniel Vetter To: LKML Cc: Linux MM , Intel Graphics Development , DRI Development , Daniel Vetter , 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 3/3] mm, notifier: Add a lockdep map for invalidate_range_start Date: Thu, 22 Nov 2018 17:51:06 +0100 Message-Id: <20181122165106.18238-4-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181122165106.18238-1-daniel.vetter@ffwll.ch> References: <20181122165106.18238-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. 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 | 7 +++++++ mm/mmu_notifier.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 9893a6432adf..a39ba218dbbe 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,11 @@ 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) { + mutex_acquire(&__mmu_notifier_invalidate_range_start_map, 0, 0, + _RET_IP_); if (mm_has_notifiers(mm)) __mmu_notifier_invalidate_range_start(mm, start, end, true); + mutex_release(&__mmu_notifier_invalidate_range_start_map, 1, _RET_IP_); } 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 4d282cfb296e..c6e797927376 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.19.1