From patchwork Fri Nov 2 09:15:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10665185 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 DFC2B15E9 for ; Fri, 2 Nov 2018 09:15:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB4E42BA77 for ; Fri, 2 Nov 2018 09:15:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFF0E2BA9B; Fri, 2 Nov 2018 09:15:50 +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=ham 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 74E802BA77 for ; Fri, 2 Nov 2018 09:15:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7DA856E555; Fri, 2 Nov 2018 09:15:49 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@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 90CA76E552 for ; Fri, 2 Nov 2018 09:15:47 +0000 (UTC) Received: by mail-ed1-x543.google.com with SMTP id f8-v6so1246250edt.13 for ; Fri, 02 Nov 2018 02:15:47 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l9RQ5iD4W4W0uIvFZ9Pu7IIeWepUMXVSw/+/Qz476uI=; b=CypHSTjnqq8veiPEN6WfYq0eghopbMugmwCKexM//A+iXSVtbExCZD9D/JzFEK5vrP 5UmOAIrBRhA0qLGqtdx7KXWDkb52dYNzxVnqo9ir4dmR6qaslbLQP6LE5BX+ydvGTMEN TjC4JaEViWtYy9k+8Oe6GEOq9f3v5LUHJ6w+yPoRExP2d+OlbiHG65+9mzF95GOYcrPj Zrtq79R3LLsrbe6b+DyGsv42h5P9u53cyqEgmCdqeav9jRueGqNfXiEwfdlZAe36SyA1 sr3oUPCK2Sro6gmcUDvmaocTNceBAlF9tPNgkevtDjp6m1KCSGfChxoJrWTcFK79fsNI FWAQ== X-Gm-Message-State: AGRZ1gKOxOXI+bBHHm2Tg9Kc+TL5aBYisLUal1V5bnUCJGltrBVFUuaY xrDvgO8cosZTZns0VVsdhSa/CaOt3Ro= X-Google-Smtp-Source: AJdET5cSJoh7KMqEXC+pPZ3XfwEutyAnYoZjLX8w+2gPglDiS+vIa4GVBilOQX8TzxygW3HtiXTmLQ== X-Received: by 2002:a17:906:32d9:: with SMTP id k25-v6mr6195155ejk.211.1541150145766; Fri, 02 Nov 2018 02:15:45 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id p19-v6sm5658103ejw.69.2018.11.02.02.15.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 02:15:44 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Fri, 2 Nov 2018 10:15:25 +0100 Message-Id: <20181102091531.7775-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102091531.7775-1-daniel.vetter@ffwll.ch> References: <20181102091531.7775-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 06/12] mm, notifier: Catch sleeping/blocking for !blockable X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP We need to make sure implementations don't cheat and don't have a possible schedule/blocking point deeply burried where review can't catch it. I'm not sure whether this is the best way to make sure all the might_sleep() callsites trigger, and it's a bit ugly in the code flow. But it gets the job done. Cc: Andrew Morton Cc: Michal Hocko Cc: David Rientjes Cc: "Christian König" Cc: Daniel Vetter Cc: "Jérôme Glisse" Cc: linux-mm@kvack.org Signed-off-by: Daniel Vetter --- mm/mmu_notifier.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 744840e5636e..4d56e2645b6c 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -185,7 +185,13 @@ int __mmu_notifier_invalidate_range_start(struct mm_struct *mm, id = srcu_read_lock(&srcu); hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist) { if (mn->ops->invalidate_range_start) { - int _ret = mn->ops->invalidate_range_start(mn, mm, start, end, blockable); + int _ret; + + if (IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP) && !blockable) + preempt_disable(); + _ret = mn->ops->invalidate_range_start(mn, mm, start, end, blockable); + if (IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP) && !blockable) + preempt_enable(); if (_ret) { pr_info("%pS callback failed with %d in %sblockable context.\n", mn->ops->invalidate_range_start, _ret,