From patchwork Mon May 20 21:39:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10952375 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 29D131395 for ; Mon, 20 May 2019 21:39:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18AFB27F93 for ; Mon, 20 May 2019 21:39:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CB2C28759; Mon, 20 May 2019 21:39:57 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B567A27F93 for ; Mon, 20 May 2019 21:39:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 947D48919E; Mon, 20 May 2019 21:39:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id A047089148 for ; Mon, 20 May 2019 21:39:53 +0000 (UTC) Received: by mail-ed1-x543.google.com with SMTP id g57so25912704edc.12 for ; Mon, 20 May 2019 14:39:53 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=DucpRdkRgOoCBrOy6KiJUJJfWEr/7+ZCIIaJ4AvhfB0=; b=ZEsYg3FdMvIEeSLhEd8yXBaY52myPl7iINhNe4ozc+8+A4z902mUwXbZ/F/WaQVCGo A6e4ulEqrDOon3xPwOK+ZyxeVieg5wIDJ5TfWy7axiycfteTeWJJidhehO6W6qPtWmge OSWKqqiRxv1SD1mGf1+nLIcH/G26rx/7WmVpl4hnXHOt3Np60JBRNLKnkp++6dPyyJKr ifQcpPHLW2ctB9bA/sWS9cIy1k9x5c5qIJB9rpo7wwxE94cIoHQov2zJ7xapojJ92ewn zKUxIT2XT7f7kX4AnYGrH6W0sBv+XhP5SlTNh1W0TE2zGHJi3zQHRuqzZbMfdsecats6 pPyA== X-Gm-Message-State: APjAAAXmFCFpYCNGQknhl5DtdQmcvlw4nt1bPk36XcD6vtWb5n0ZC8FO P1vA3X8OxiMOi9UOKphTIaSD5cblyX0= X-Google-Smtp-Source: APXvYqzzZ2kpVp8haHdbToY3y03B93IZ2fARLhOO1vyR6C1AaG3mgxQcALaUAvLZsqLVYAWfP3KDjg== X-Received: by 2002:a50:b865:: with SMTP id k34mr79563563ede.16.1558388391895; Mon, 20 May 2019 14:39:51 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id v27sm3285772eja.68.2019.05.20.14.39.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 14:39:51 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 1/4] mm: Check if mmu notifier callbacks are allowed to fail Date: Mon, 20 May 2019 23:39:42 +0200 Message-Id: <20190520213945.17046-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DucpRdkRgOoCBrOy6KiJUJJfWEr/7+ZCIIaJ4AvhfB0=; b=HKq8DuysKW6hx7l8Yig0NV9UpMzIOK98ALTyHYlWExOE6Pc4XsceN9CwZTMEZ+y6cw Cotb3dp0LmPi/TnfsGu9Mc8wGpsj9yCkmJXIekv1AWGWZdRazvo+2R7pulay1RKnKq5x V5EN38iDPb1UvcB2ERZ4RtefPoEDwb5qTXLcw= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Hocko , Daniel Vetter , Daniel Vetter , Intel Graphics Development , LKML , Linux MM , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Rientjes , Paolo Bonzini , Andrew Morton , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. 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 Reviewed-by: Christian König Signed-off-by: Daniel Vetter Reviewed-by: Jérôme Glisse --- mm/mmu_notifier.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index ee36068077b6..c05e406a7cd7 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -181,6 +181,9 @@ 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-" : ""); + if (!mmu_notifier_range_blockable(range)) + pr_warn("%pS callback failure not allowed\n", + mn->ops->invalidate_range_start); ret = _ret; } }