From patchwork Tue Apr 3 17:58:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10321607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 015EF60318 for ; Tue, 3 Apr 2018 17:59:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D892728C83 for ; Tue, 3 Apr 2018 17:59:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA99528C87; Tue, 3 Apr 2018 17:59:16 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 4488928C83 for ; Tue, 3 Apr 2018 17:59:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C26089CBC; Tue, 3 Apr 2018 17:59:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8B3116E519 for ; Tue, 3 Apr 2018 17:59:11 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id p9so35203992wmc.3 for ; Tue, 03 Apr 2018 10:59:11 -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=JZi6M2qfTEaHsTxa9g2DmvETbT/qPp12Y4rUfdsvk+U=; b=Tf5+9S88vVeYTdyuMzzltt7jZ+zG9XbpM2N/GcbFmQMOQ7K2HhHZkApVzGE/L59pI0 wAv7iCg4kBLpcqOfPtTDZR+6KVQ0/fsjd7oX0ujZOLGlGYYSkOZaOnVWFfffnhrIwP1w 7+XgMofVKT1XuzgS4tMjDfEbvkt9U958yXKEE= 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=JZi6M2qfTEaHsTxa9g2DmvETbT/qPp12Y4rUfdsvk+U=; b=hWe7rsS4ViLeAtX+fiAqPkHRHbPjLIEfz3eHUkloKgv4c9EDc1gXtSLUV5/slvSqvb TtlpX1OuGNeYo1S/gm1yXsv4puxXphyU1RYEYh5tRhABdV+yZ5Gz5CATV2i93IzwlCGd ppEf9u8+6UF9GqHIcZUG421ezZLNWslAfXnwWN2U1IdvWptP1XSMfpiAtiAfJtbAdWe0 r6q7dh6zzPeYqS6zNIA6XSbUf+beD6X1HdLDn5KBCG2yHXH8qt9lbgj0rPVjTrmogfo6 EAUYyoBIhhUvCqqdJ5SMNocrEJkJ4ZHiQHxTUKgPxjRAeQdUWA0biDjDWTucKXbmT3LZ LOeg== X-Gm-Message-State: AElRT7Fg5gNwWcVMrJDAFlXdMHKekr2VH9ThtbKHOKjrfXkKUtxdpYv9 FPPDpGNnDDHFBSZOaFdCrSI4EMg2 X-Google-Smtp-Source: AIpwx4+gAsqZb69maUCZtmIf58IRdUSvIMRu1GWE26WsmP5ERV7X9nN1yENOO0qw6YzoifQ9pA0uww== X-Received: by 10.80.232.195 with SMTP id l3mr17554744edn.307.1522778350283; Tue, 03 Apr 2018 10:59:10 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id g2sm2000604edi.2.2018.04.03.10.59.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Apr 2018 10:59:09 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Tue, 3 Apr 2018 19:58:55 +0200 Message-Id: <20180403175855.30858-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180403174604.30529-1-daniel.vetter@ffwll.ch> References: <20180403174604.30529-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915: WARN if we hit a signal from kernel context 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: , Cc: Daniel Vetter , Matthew Wilcox Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP After a discussion with Wily I got the nagging feeling we might have some cases of nasty busy loops. The window is fairly small since we always have a non-faulting fastpath (using page_fault_dis|enable()) first, usually followed by a pile of pending signal checks, before we go into the slowpath copy_to|from_user that might blow up for real. Test patch to check what CI thinks of this theory. v2: Don't WARN on success (Ville). Cc: Matthew Wilcox Cc: Chris Wilson Cc: Ville Syrjälä Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_gem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 9650a7b10c5f..9766fa152e05 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1902,6 +1902,7 @@ int i915_gem_fault(struct vm_fault *vmf) struct i915_vma *vma; pgoff_t page_offset; unsigned int flags; + bool user_fault = vmf->flags & FAULT_FLAG_USER; int ret; /* We don't use vmf->pgoff since that has the fake offset */ @@ -2017,9 +2018,10 @@ int i915_gem_fault(struct vm_fault *vmf) * handler to reset everything when re-faulting in * i915_mutex_lock_interruptible. */ - case 0: case -ERESTARTSYS: case -EINTR: + WARN_ON(!user_fault); + case 0: case -EBUSY: /* * EBUSY is ok: this just means that another thread