Received: by 10.213.65.68 with SMTP id h4csp3467334imn; Tue, 3 Apr 2018 05:35:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx481gIjNJHDhkBr80xZ0QfbR3WUSL6UX/yDwt7fLemVJ6+XOLkWTk70O2UY3JDWYqxObZ9nX X-Received: by 2002:a17:902:a701:: with SMTP id w1-v6mr13836079plq.109.1522758907402; Tue, 03 Apr 2018 05:35:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522758907; cv=none; d=google.com; s=arc-20160816; b=Cv/uzeUI/Lhfmaz3cX0d6UM8WRx78qmPbjH7LFqStzkqE7UxQUKNePYMW5INdR1du/ 7xm67CdEysDwT5jvxP39WxLbAWaGBqnYyi2E0XmqevNOm98MjlnOAov5oPrQZb1FCDtN lgUUaZIDbBKiCK7d/+I7oQ5Ullf9SQMVWbaealkrovPIucyTVjJYZ1351VMagFUk25Pi tq5pmb3zuruwNQwef5mGgNg1F13k1J5ymh5cfFfsGGeBBd1tHJFPVk/NgrMtu9E/LiL6 2kO5RlvaEhwujSlk8AKvHMbinEPg9htw3WHvVCeLciZwwRtVnjHfz9cKxKe2zDYcWPGE Shog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:arc-authentication-results; bh=dDvMDFYgV+SerUtxbk5I3tRmdH64XFR/WV9eTLlEWrc=; b=jSXyZ5iLChm5rAEbjDTH0SrB12p/shptTWJWK08rb2wsoC3gRbuqdKo/wM04HL62jC Vo9kFMCj8rQNs4++m3roWLJFda230bSf4/j0QHjVv0XlW5WDtNRk0ytG+jKGxOIBNmVM DuF0ih4NFmLvLQZ9Jegs0dvUVOJkr0QmGPGlL728UlInuUgGc5MUWZOGP9zRDp5Mx+5+ 481CCcOEQDhUimDp2URq63lQDEJPO5JMVN+9chAMO5ylHqfT3rGkeEQsH8f+RPqu4dZ3 hEXWYLrrV31VENtw4nezZY4JRERHo4piasOvEo11+JtvHUuFX16z3G2g5/x1E8k0XgCg 4Wxg== ARC-Authentication-Results: i=1; mx.google.com; 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 x3si2106826pfa.66.2018.04.03.05.34.53; Tue, 03 Apr 2018 05:35:07 -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; 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 S932205AbeDCMdV convert rfc822-to-8bit (ORCPT + 99 others); Tue, 3 Apr 2018 08:33:21 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:49631 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932100AbeDCMdU (ORCPT ); Tue, 3 Apr 2018 08:33:20 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 11245700-1500050 for multiple; Tue, 03 Apr 2018 13:33:18 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Matthew Wilcox , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, "Souptick Joarder" From: Chris Wilson In-Reply-To: <20180402141058.GL13332@bombadil.infradead.org> Cc: linux-kernel@vger.kernel.org References: <20180402141058.GL13332@bombadil.infradead.org> Message-ID: <152275879566.32747.9293394837417347482@mail.alporthouse.com> User-Agent: alot/0.3.6 Subject: Re: Signal handling in a page fault handler Date: Tue, 03 Apr 2018 13:33:15 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Matthew Wilcox (2018-04-02 15:10:58) > > Souptick and I have been auditing the various page fault handler routines > and we've noticed that graphics drivers assume that a signal should be > able to interrupt a page fault. In contrast, the page cache takes great > care to allow only fatal signals to interrupt a page fault. > > I believe (but have not verified) that a non-fatal signal being delivered > to a task which is in the middle of a page fault may well end up in an > infinite loop, attempting to handle the page fault and failing forever. > > Here's one of the simpler ones: > > ret = mutex_lock_interruptible(&etnaviv_obj->lock); > if (ret) > return VM_FAULT_NOPAGE; > > (many other drivers do essentially the same thing including i915) > > On seeing NOPAGE, the fault handler believes the PTE is in the page > table, so does nothing before it returns to arch code at which point > I get lost in the magic assembler macros. I believe it will end up > returning to userspace if the signal is non-fatal, at which point it'll > go right back into the page fault handler, and mutex_lock_interruptible() > will immediately fail. So we've converted a sleeping lock into the most > expensive spinlock. I'll ask the obvious question: why isn't the signal handled on return to userspace? > I don't think the graphics drivers really want to be interrupted by > any signal. Assume the worst case and we may block for 10s. Even a 10ms delay may be unacceptable to some signal handlers (one presumes). For the number one ^C usecase, yes that may be reduced to only bother if it's killable, but I wonder if there are not timing loops (e.g. sigitimer in Xorg < 1.19) that want to be able to interrupt random blockages. -Chris