Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1139922ybi; Wed, 19 Jun 2019 14:21:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFgDkf2cf8mXhYsaYuv3lkoneCkbr+YhiwnIvHV27Dimhp/yf8nsR6DJMjcl7hPecWGmaQ X-Received: by 2002:a17:902:968b:: with SMTP id n11mr80717112plp.120.1560979265037; Wed, 19 Jun 2019 14:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560979265; cv=none; d=google.com; s=arc-20160816; b=ADu82J8EQZXO1NAkvn/yR0f8siphpghu/1kEklokNkC9qDI1l3sysbcr9ZsrDrokww ObMi6B3EDJkEdshl8a49sO5h9wFqCGz0fKVxddyOBO9JYirNUIHSHDhs1/SrsrZDpnpO xB+g84oVVFTzd0eMIy+v2+0XJRx+dBI5GCASFnEV68oXRV+9D7/e7wrTmB6Wqp1ph7B3 MYTbANVZNUX7+rNqJRsJY19vu8RFmdEygiR/Td1aO6yC3xK/vPmO6nQkUDjrYoXv3uGl zOgnDP0rbVS3zgkKHplip0c1h49ntb9UD+dTugrOKEvvNUHe7wqxASMpBDZ/7GRcelq9 Ar5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=bI9P9AKaggByB2J+3Bzt1bHMyBdbzhZul43br86InHM=; b=yBNH8qQicY0YKmPNdVP+7oDthyYk5VbJdPxh+79/1EaVXw/7WBVpNWRYDvLVAPDbLS 8GkPz8oVl0LQORQDCQ5ucMzyhoWXKOqLlFBRZ0hOKCTy4xLI6lQB3WpXbrnYYsQtWGlW VK8CB7gTs71hyrm5MHT6hcL7gk2TbuTF68s+Nn2JDYxQYrqqeYdiPVfrClY1r+DFVxaO nIYWQ+h1RmXetA59Xu76wzyRNpyrWc/QWc1TBB5Wq6tqdTUcM+rwb/64CLkhYYnnbmZ8 WvWg/pX4aTYAuMZH7Z4Fv8j8vvbCWEG7Dp+j9iCJvxdLngUrahj1q429JFRGKaMK1Hki LbEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Tz3wIEMJ; 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 g8si3939791pgd.64.2019.06.19.14.20.49; Wed, 19 Jun 2019 14:21:05 -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=Tz3wIEMJ; 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 S1730487AbfFSVUi (ORCPT + 99 others); Wed, 19 Jun 2019 17:20:38 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:41698 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbfFSVUi (ORCPT ); Wed, 19 Jun 2019 17:20:38 -0400 Received: by mail-oi1-f193.google.com with SMTP id g7so466391oia.8 for ; Wed, 19 Jun 2019 14:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bI9P9AKaggByB2J+3Bzt1bHMyBdbzhZul43br86InHM=; b=Tz3wIEMJQ6KUu24p8kJGpTzmA6Co/vmiIUI3dfmnw92cqIil2cOfv4n0isjZeDFBj/ N2DwUQt3F8qi0Lq/xtl6BMeVRiOStswnCRJNxGBm9I3jcsl0Vin08++XC8/kTEXa8Rb4 gdhuT8fnTwj/ll0yWjskwxZDpP7xdYe59hvjI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bI9P9AKaggByB2J+3Bzt1bHMyBdbzhZul43br86InHM=; b=CvFmuWSMkMaxl/tEHQzmhjKDw9rf7uVKFyovpNkuHpmWxsaD+Fv14zLQ89tOOuQXsa hsSChssdFyyHalvZG1S94us0QluQENSRV/PGSFIjetqzv5z7JhF4+XVQtvU+THmfCi3z ETdwADx53LnS+f3yN56WKFwUBK9hPCiFrv+sb1qtGi+9cW5R4Ft/yZRcMpsX+TYjEJ6g GVIWXVlJVjn/Wvm+IbdGKiLwghVKCPl5zX1oJV4W0Jtsd3UYBJaS3p2MugzSzIIQ9a9l tdw6R0UEcRC/yUxDyvkwwW1MP+dsT0aJsbfRZ024/j6YGxF790+ViyOl0gl6lmhSOJH6 B1Bw== X-Gm-Message-State: APjAAAUOIq1KLX7QhvXLzy6WA6KeoT9B9zn2wZtqpUtYOwiVU/rYTo24 0wv/0P5tYKC0tlWb1f+fZv88Rtg/HEu2yD0o2e36Cg== X-Received: by 2002:a05:6808:118:: with SMTP id b24mr3757147oie.128.1560979237149; Wed, 19 Jun 2019 14:20:37 -0700 (PDT) MIME-Version: 1.0 References: <20190520213945.17046-1-daniel.vetter@ffwll.ch> <20190521154411.GD3836@redhat.com> <20190618152215.GG12905@phenom.ffwll.local> <20190619165055.GI9360@ziepe.ca> <20190619201340.GL9360@ziepe.ca> <20190619204243.GM9360@ziepe.ca> In-Reply-To: <20190619204243.GM9360@ziepe.ca> From: Daniel Vetter Date: Wed, 19 Jun 2019 23:20:23 +0200 Message-ID: Subject: Re: [PATCH 1/4] mm: Check if mmu notifier callbacks are allowed to fail To: Jason Gunthorpe Cc: Jerome Glisse , Michal Hocko , Daniel Vetter , Intel Graphics Development , LKML , DRI Development , Linux MM , David Rientjes , Paolo Bonzini , Andrew Morton , =?UTF-8?Q?Christian_K=C3=B6nig?= Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 19, 2019 at 10:42 PM Jason Gunthorpe wrote: > > On Wed, Jun 19, 2019 at 10:18:43PM +0200, Daniel Vetter wrote: > > On Wed, Jun 19, 2019 at 10:13 PM Jason Gunthorpe wrote: > > > On Wed, Jun 19, 2019 at 09:57:15PM +0200, Daniel Vetter wrote: > > > > On Wed, Jun 19, 2019 at 6:50 PM Jason Gunthorpe wrote: > > > > > On Tue, Jun 18, 2019 at 05:22:15PM +0200, Daniel Vetter wrote: > > > > > > On Tue, May 21, 2019 at 11:44:11AM -0400, Jerome Glisse wrote: > > > > > > > On Mon, May 20, 2019 at 11:39:42PM +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. > > > > > > > > > > > > > > > > v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for > > > > > > > > the problematic case (Michal Hocko). > > > > > > > > > > I disagree with this v2 note, the WARN_ON/WARN will trigger checkers > > > > > like syzkaller to report a bug, while a random pr_warn probably will > > > > > not. > > > > > > > > > > I do agree the backtrace is not useful here, but we don't have a > > > > > warn-no-backtrace version.. > > > > > > > > > > IMHO, kernel/driver bugs should always be reported by WARN & > > > > > friends. We never expect to see the print, so why do we care how big > > > > > it is? > > > > > > > > > > Also note that WARN integrates an unlikely() into it so the codegen is > > > > > automatically a bit more optimal that the if & pr_warn combination. > > > > > > > > Where do you make a difference between a WARN without backtrace and a > > > > pr_warn? They're both dumped at the same log-level ... > > > > > > WARN panics the kernel when you set > > > > > > /proc/sys/kernel/panic_on_warn > > > > > > So auto testing tools can set that and get a clean detection that the > > > kernel has failed the test in some way. > > > > > > Otherwise you are left with frail/ugly grepping of dmesg. > > > > Hm right. > > > > Anyway, I'm happy to repaint the bikeshed in any color that's desired, > > if that helps with landing it. WARN_WITHOUT_BACKTRACE might take a bit > > longer (need to find a bit of time, plus it'll definitely attract more > > comments). > > I was actually just writing something very similar when looking at the > hmm things.. > > Also, is the test backwards? Yes, in the last rebase I screwed things up :-/ -Daniel > mmu_notifier_range_blockable() == true means the callback must return > zero > > mmu_notififer_range_blockable() == false means the callback can return > 0 or -EAGAIN. > > Suggest this: > > 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; > } > } > > To express the API invariant. > > Jason -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch