From patchwork Thu Nov 22 16:51:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10694507 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 186C75A4 for ; Thu, 22 Nov 2018 16:51:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0601D2CD19 for ; Thu, 22 Nov 2018 16:51:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED2902CD5D; Thu, 22 Nov 2018 16:51:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBE7C2CD19 for ; Thu, 22 Nov 2018 16:51:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 300E76B2C3B; Thu, 22 Nov 2018 11:51:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B36D6B2C3C; Thu, 22 Nov 2018 11:51:19 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B8136B2C3D; Thu, 22 Nov 2018 11:51:19 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id A71F96B2C3B for ; Thu, 22 Nov 2018 11:51:18 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id o21so1369344edq.4 for ; Thu, 22 Nov 2018 08:51:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IqCNVNv0Y8aoRKucGwKEjdCDvF336AuZYaELjzjP6Ls=; b=Jc/JGlh47d9edFyUTOSA5RzIrEEuveh+AmpksEKQYu5MIrLo4qENIDAgkTDaOgpsSY 8FLVgj/fceWnjEkNyJdXCBNcGVQ0ODZjBsUUvOKZgxgq5KFQEhhc4+2Kt3KZGPsvyS08 0EiW6LdhzIGM7rj5Qz83xNT/DpBETRoW3nFliZS9M3yyLRjGATB/luBtJ4E9DkomWhxk +mIEy9RSNDK5r4JHxzlGIMfRgrPFspsRO+8R6imLV3VENRIqGL29G8rCYvh61GxsA0w7 4aMCtaP0mZ+5G81RxrQLP/gCVduGHNP74vg/BXmck/GVD4Nq135D3B4o5iBvnaTPoMIb 1tfg== X-Gm-Message-State: AA+aEWbK7y/EMkmP06WhBnXikiYgJi2abUM++KnvqcOb/SiHwReyZUC/ fXonrxUlSlAgUoXnL/CJn29fZGbWtnPzdIoKRbU65QeX4rTYc8oA+vH6GX0+KlvHUpR6avb94gw saXAmPbouLRXB7KKIoDiR5OL3Yn4SowIaqWHKtjn9l2Qhnug/7uq+PwZhnkObBzYaIJkuf73AIl LmUuSYdXYkB/N8lyzkq1Jj7h0jRfZ5lpnTYuz7eHEH+0NJuPgMg3BVjz8XaLkDV8i2bjyxPPQHG qgfTMyEoKiwJI7jdxA7eABBXp0JZza4pIOwtqI9d42yb+yw3F7btlwDjCiCY1o3aAARalkDW9sm hWMiNwrFt6iYUnnZXsGJm6zpXBvDzf3smRvst5l81Tl75CV4iaZEdTx2L3cNiMm8GxH7ugQP3q5 N X-Received: by 2002:a50:e045:: with SMTP id g5mr10357933edl.152.1542905478160; Thu, 22 Nov 2018 08:51:18 -0800 (PST) X-Received: by 2002:a50:e045:: with SMTP id g5mr10357876edl.152.1542905477206; Thu, 22 Nov 2018 08:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542905477; cv=none; d=google.com; s=arc-20160816; b=RtG6vBkiMvoKoIWGD5JBulfs+f75T8ItbRvew0oHN4GBzkGZNelkAhT5Tm1twi4lTV V70tlu2Hy//hPb6+ObIzNuTnIplxRLz745hAzHaDMZjpf8y04TbxW07ppBYE8XilE0Fx 2skKtSfxwfRDdLXW6B5zvaCrJn9UnSo4SipX5de2KLkPtKm6s2LD4N4KkyZsJwgd/pns gk+6wQq9SgOgsNkkQaqAQRRPF2zJwvOhxWtQsxj9qpbToBIUSZjxJvPhFVFs+jgM3K0O O24ccWsbrSHVRY1e2DHfYk37n3PhiHikgbQQRN1S9zSsd1/JT1Hud7NpWVtAzOTdPL3/ RdvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=IqCNVNv0Y8aoRKucGwKEjdCDvF336AuZYaELjzjP6Ls=; b=OQm6E19KNUd0CGVhUE6IcKCpLCKRgSqAYl/0Ln6Ij5latS2hyYIFD3c3CE7HJCnOdF 45fwX6Y0uh6ZCsSe/NXZHHPmznMQ2a5R9awSJjVTm/EgVzOClUcXYRuJAuMw6HObYbp1 vQdZ2Q5Bdes4xHAYNJnrb0LJd0jquyLmFVjMvERkf2qBc3pi6jY4P23/NG0HasAqnwfD IsoJo8Y96lfHUcu4SnesifOrME5xtXxG2YKWmT4k7ErnTFdA5BZYfXGxox9uo9yrwgJZ clwK+ypoelEnWWdtjAtTPDlIXi5CU2w4iQ5d5g99YioFFoLA6MdnthO5Ol2uF+I3PTLt b6jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="MMzYO6/w"; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) smtp.mailfrom=daniel.vetter@ffwll.ch Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b51sor8949498edd.5.2018.11.22.08.51.17 for (Google Transport Security); Thu, 22 Nov 2018 08:51:17 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="MMzYO6/w"; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) smtp.mailfrom=daniel.vetter@ffwll.ch 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-Smtp-Source: AFSGD/X3yt1n8EIDxKFM/dx7WPreYbLdq5CVYlgu9XO9dTU/ze5Lq/MSqa8fCcbBo2dSkl61aed9Sg== 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?b?SsOpcsO0bWUgR2xpc3Nl?= , Michal Hocko , =?utf-8?q?Christian_K=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 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: X-Virus-Scanned: ClamAV using ClamSMTP 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