Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1248863ybl; Wed, 14 Aug 2019 13:21:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVk9vBk7BT6gdOMylK4jxRzVMCCe1InU/V1wtncw66S7G7qa5XF3UCsgRbG6DKdB/6WZu/ X-Received: by 2002:a63:eb51:: with SMTP id b17mr761968pgk.384.1565814091948; Wed, 14 Aug 2019 13:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565814091; cv=none; d=google.com; s=arc-20160816; b=Z9x8a43aauCXwYBnIQciijQc8CfDjmbmhNQTo9rSpmZOhrffd01eL5KValRLyC57TM 1ZT2CNxOv9Sx9Sv+8c3p1fTdTUEBMgCG0OHkwWjtHcKsb7jL/U8fPFADMU6wNJbGdmNM UzfeLud1KV3ERYGwAt2cgst8hc26YSslu+WvhvUd9drLAvf3Lqj24YChJ0REv9Kr/LDX 5wYBLPUoCSALBoYWGHaaJ9VwP4WUPNbElqM3VjBJI+263lUKfM41nplQevNhyQwUfUMg WE36w/rIJyXsqP7UeyFyoR7+Ft1bPu/UNWrNQmINu4z3ss2wQfsUowKmEXMVeKf6mGg4 EYCA== 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=NGoYUnhBV7TeB+3l4wceLC9ZPh9ISIJNJOmyRzHIbHM=; b=NyvXvM2O/XKejj3nykP6tz8CNuzC0OzxlDxuR5XnGJLKzgW00rVmocequlRvrxca+/ fr3Wdqv1+M6xznIKYxo0KAFBy254L8ebNqICIZB/2+HESMtDQxLL6YCY6QIH59lUie7h OUcCOy9cBvNkgY/bfX96QvQKs8fc8Vkewh0yMe/M7UkaKNq9ob0dTMVSKiO+FbWipL5Z gfOkDQj/yw9iktFOG3dsvVa+RdWnT34MzVdTti00MZ/xvxTJ4pg+b9HgfKOiQgwK7ykn JxK9rw0k5OCx8zo5y0GZWICvg09XXx6Q9W5vaXaXD4OtsrySKpa28JzER7jgCHamG8d7 u3Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=B5pmU59y; 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 38si506376pln.426.2019.08.14.13.21.15; Wed, 14 Aug 2019 13:21:31 -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=B5pmU59y; 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 S1729394AbfHNUUj (ORCPT + 99 others); Wed, 14 Aug 2019 16:20:39 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:46642 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729306AbfHNUUh (ORCPT ); Wed, 14 Aug 2019 16:20:37 -0400 Received: by mail-ed1-f66.google.com with SMTP id z51so323567edz.13 for ; Wed, 14 Aug 2019 13:20:36 -0700 (PDT) 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=NGoYUnhBV7TeB+3l4wceLC9ZPh9ISIJNJOmyRzHIbHM=; b=B5pmU59ycnYBpryQhhG1Z3DbeM8Nqe5M8v1SwTte2yz8M8LB54A/UjWXYoWpYTn2Uv 5wXLGfAUtYZN5x4CsUBfceRVwXq/4IjhgUmLTFyUKguhiSbuw71qyrATlnjMjT5+NMfu Y1nD5IwF07+NuCcwz0U1msvMGB0mJkgxThOFM= 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=NGoYUnhBV7TeB+3l4wceLC9ZPh9ISIJNJOmyRzHIbHM=; b=KY4BaOakB/2SNROMXZm0OA+Hw9n6+EIeECzTYvfeYQv8mhlKL83N6Qtn0sjD9xg67S b7fZRDyrVDLRnPqOOHipKHLzNxvQBNV4I+/7oxH202UwfU19qpFdzD8Hnl8Jpjnd74SC cbp7y3kaX0qZ05QiHozro1KqOcQOw5V2qY2aq90aQATvIpomd10ERpQm4fdA34fnGeAt 8nvbZ8+y1JyrPispMx/80ifeI5gZMiJjxH98Clrzs5K3hczpZZha9ax4W4GekqzSpxFl 6wQM1Ljq8MgTJ/MpYirKNsfYr7BvmkvniOOptPBSFsQXAbIKa8UCTyqchUOEhIEv2UVg d5KQ== X-Gm-Message-State: APjAAAW0um5zMZGqC+ZnTbhegMUrjayRcUqb+Yo3MeENTBdZWxxBYuOR EPGQRcwsoy0Abue61Zd6Nlw8SnCt+6tFRQ== X-Received: by 2002:a17:906:1e85:: with SMTP id e5mr1324797ejj.200.1565814035124; Wed, 14 Aug 2019 13:20:35 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id ns22sm84342ejb.9.2019.08.14.13.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2019 13:20:34 -0700 (PDT) From: Daniel Vetter To: LKML Cc: linux-mm@kvack.org, DRI Development , Intel Graphics Development , Daniel Vetter , Andrew Morton , Michal Hocko , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Rientjes , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Paolo Bonzini , Jason Gunthorpe , Daniel Vetter Subject: [PATCH 1/5] mm: Check if mmu notifier callbacks are allowed to fail Date: Wed, 14 Aug 2019 22:20:23 +0200 Message-Id: <20190814202027.18735-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814202027.18735-1-daniel.vetter@ffwll.ch> References: <20190814202027.18735-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 Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to. Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper. An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think. Summary from the m-l discussion on why we want something at warning level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise. v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko). v3: Rebase on top of Glisse's arg rework. v4: More rebase on top of Glisse reworking everything. v5: Fixup rebase damage and also catch failures != EAGAIN for !blockable (Jason). Also go back to WARN_ON as requested by Jason, so automatic checkers can easily catch bugs by setting panic_on_warn. Cc: Andrew Morton Cc: Michal Hocko Cc: "Christian König" Cc: David Rientjes Cc: Daniel Vetter Cc: "Jérôme Glisse" Cc: linux-mm@kvack.org Cc: Paolo Bonzini Cc: Jason Gunthorpe Signed-off-by: Daniel Vetter --- mm/mmu_notifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index b5670620aea0..16f1cbc775d0 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -179,6 +179,8 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) pr_info("%pS callback failed with %d in %sblockable context.\n", mn->ops->invalidate_range_start, _ret, !mmu_notifier_range_blockable(range) ? "non-" : ""); + WARN_ON(mmu_notifier_range_blockable(range) || + ret != -EAGAIN); ret = _ret; } } -- 2.22.0