Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1419272ybl; Wed, 14 Aug 2019 16:59:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2cOApFdl4Z8BuvSOtTo1VUL9p5U1py0QUKoS/uV3mmGlx6jbihL38IJsfbG5aNwadpbge X-Received: by 2002:a65:6281:: with SMTP id f1mr1301271pgv.400.1565827143029; Wed, 14 Aug 2019 16:59:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565827143; cv=none; d=google.com; s=arc-20160816; b=Nbi1nh5atiSUPkSam1qpb8SlwhzTvYTszzUXFomDiHf6sA3Yy4xHjKWmSlJpT5LZry BC03KAuo6BnG8qqN9ZVjEONardEgz1f6A/BWdxdgwle7CaqLMIAxpCOC3Lv8vFR0jApS NYc1Sqn7Dxp0pu+gRfAMPlGgJ7b3W8C1JjoMPtxT39FfVeOVCtnSHkdB7/r0iUzNRSRK fCMsaRwiNycbxiBr5YrmXo6nehZEIV1UNf2Gd2gf6ZTta8XXr/4Oh+JvdOnCFxayDYdE 56YsWM8X7H4dPKIkOWy4tw8aQ0zCef5aJgtTWLuoprSB9g0ZhuOuy/MBTFfx6MMz0WmT NAIQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+oq/5hVDOEPmfOLGRxP/LWMzZW9hvok8H3hUDypMEVM=; b=G9iO9n+IvXk43TuCVJgApVydiUTqmz82gy6MNifFkQbdQcAnL4dE2MSjXbk7IkQjWV ldAvTIc3Ni4FkBPO7qYwdUWoATkX8beCy1C4hkQR42lDkOUz1b5kuwltttL8VJn60AGo ui190C0mt7bIn/fD0/ybN0o/CHY1GvUpdkqu7YvVc3vn6F+Mhgw+bXj6744wgDS/Cd4Y +wp2NrF28mWo6QSxqlXd+WSPeWyvLuw67h7adbfRbAQR5Pps0VNFfbm4fsO1Sf/zgXYD GkPZ727yv+/kT4+5vFVscwCZnsY5VQk59VUuUYVul/60+PxEPhSvAEE4uWemYM7GSCaf UtxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=CeW4A6s9; 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 u10si810985pls.385.2019.08.14.16.58.47; Wed, 14 Aug 2019 16:59:03 -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=CeW4A6s9; 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 S1728792AbfHNXWl (ORCPT + 99 others); Wed, 14 Aug 2019 19:22:41 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:44421 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728416AbfHNXWk (ORCPT ); Wed, 14 Aug 2019 19:22:40 -0400 Received: by mail-qk1-f193.google.com with SMTP id d79so459941qke.11 for ; Wed, 14 Aug 2019 16:22:40 -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:in-reply-to:user-agent; bh=+oq/5hVDOEPmfOLGRxP/LWMzZW9hvok8H3hUDypMEVM=; b=CeW4A6s9kz9AiVYMqcDI06mk+8c43yhH15wi/FMEFEpQYj8SoEDj5igZ++T61nyJEF J7bz0bCMDreJWQK3+sSkHZZElkuyAADVchuhvjtrodJFxPZC3y/SlYmVyZDBspE6JQMx QBl4yI3FTbCPsBXJIEej0rRovg1r1eAJISK6dGTgM2wlBFQ9LmobWpzLw4t831OfYRb3 /nDARP5ragOjl1a4cBnMFDGnjBCOaSWZPg4MgvhREoOAQZk/AElEi+uxFPxrJ0nhHZo2 mDgtCgwDUIpQdxdHxzFJsk3H7GsWbWO3a1pFsGNrwr6UFL1DCAwb0wYESMq+D/n6TN/i qPKw== 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:in-reply-to:user-agent; bh=+oq/5hVDOEPmfOLGRxP/LWMzZW9hvok8H3hUDypMEVM=; b=RCEK2kpcQmicYgQFhHU/nh0THqz7SXn4tc+37nDJ8n2ccrKQ9YnfzPxxGYl0UI2ebT ODCSZBbqOOiC1I0QEHgUHjrdOTx0P+dzZOWBzSh14UGr9OpNxW26wjv33GNMmCiIUDD/ pL57PodCGnF5+tDozkpCx7M+Zko/ZYV2Z6jhv7izueZRbVEEXmyYi3hx8b7+hCNUqc+b Rvl4Q58gqiX8+T9p5/AqFXwHNfL3PknLqJuwtK8bVsqdtYk5MJizkx+2TfQU/WwielCe EWnEyZ7j4IKUxL+F1jx7XfpjVPh+VFgKtzSIt3asCmX+cQ5RhTx0KTDzhvumi9RoCjoC rAjQ== X-Gm-Message-State: APjAAAXmYgzxrYBP4sp0scvfZdK3WfVJ3yi3BmN7z56/Zj9D6ySEF0Qj u9ArQ88UOw1sAt4vspXahsXRlA== X-Received: by 2002:a05:620a:15f4:: with SMTP id p20mr1484735qkm.303.1565824959470; Wed, 14 Aug 2019 16:22:39 -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 x5sm529189qtr.54.2019.08.14.16.22.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Aug 2019 16:22:39 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hy2bG-00035M-Gd; Wed, 14 Aug 2019 20:22:38 -0300 Date: Wed, 14 Aug 2019 20:22:38 -0300 From: Jason Gunthorpe To: Andrew Morton Cc: Daniel Vetter , LKML , linux-mm@kvack.org, DRI Development , Intel Graphics Development , Michal Hocko , Christian =?utf-8?B?S8O2bmln?= , David Rientjes , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Paolo Bonzini , Daniel Vetter Subject: Re: [PATCH 1/5] mm: Check if mmu notifier callbacks are allowed to fail Message-ID: <20190814232238.GA11200@ziepe.ca> References: <20190814202027.18735-1-daniel.vetter@ffwll.ch> <20190814202027.18735-2-daniel.vetter@ffwll.ch> <20190814151447.e9ab74f4c7ed4297e39321d1@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190814151447.e9ab74f4c7ed4297e39321d1@linux-foundation.org> 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 03:14:47PM -0700, Andrew Morton wrote: > On Wed, 14 Aug 2019 22:20:23 +0200 Daniel Vetter wrote: > > > 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. > > > > ... > > > > +++ 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; > > } > > } > > A problem with WARN_ON(a || b) is that if it triggers, we don't know > whether it was because of a or because of b. Or both. So I'd suggest > > WARN_ON(a); > WARN_ON(b); > Well, we did just make a pr_info right above with the value of blockable, that seems enough to tell the cases apart? But you are generally right, the full logic: if (_ret) { if (WARN_ON(mmu_notifier_range_blockable(range))) continue; WARN_ON(_ret != -EAGAIN); ret = -EAGAIN; break; } would force correct API contract up the call chain once we detect a broken driver.. But at some point it does feel like a bit much debugging logic to have in a production code path, as this should never happen and is just to discourage wrong driver behaviors during driver development. If we like this version then: Reviewed-by: Jason Gunthorpe Also - I have a bunch of other patches to mmu notifiers for hmm.git, so when everyone agrees I can grab this to avoid conflicts. Thanks, Jason