Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3335274ybd; Tue, 25 Jun 2019 00:27:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMS6Ap/Qf2Uh0DAGYJI/DDmbE6Vp+dYvjoV/2LoNYu+jnLgvjNeDQotZ2/7c8PaecaQeyB X-Received: by 2002:a17:902:724:: with SMTP id 33mr149311662pli.49.1561447658138; Tue, 25 Jun 2019 00:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561447658; cv=none; d=google.com; s=arc-20160816; b=Px5cBZxRBQTMtOHPxD/l3b3PVqIoWJXEcpMYPW1isDP6W4o/0quFExX7aa+qhKajfy s3xFLDTizOKr3jvij0dgRr+bkC/Bz80s8zVFLoVp/InOXbMF4gm1Ix3uSXL2hzGWrBkz vCRZ5RNnYuB5dWak4mS0vuZO3GDGm6vG0lScqbUHOT+mcC2LLfAgtaFl2Ye7Axf+GWE8 xRoRAbOBaYm6VNDVdB3g6Fx33RysxYrXyiux3BvEgCS0glcynREaqRoFKhB+jjC3c9Vj gAXPf1H+lP1z01s77z+hWPIt/LPKHRSTPePTkSUTzMzzqe30lUs0HsBdss1chkMAM2GM fwqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=iqExqOnSByAn43v7WYpp5lu2pzQH++GcWPRRvqxzR9E=; b=rd0hoX3JE1ymUp56zvoAalXzVvsYfa+laEZXLjD387VS+E0Br/r7HXti7WoarviaKN dMbKXjSS0iC+nQFHheLAIFJosL1FfYviuYBfLVN1Gg7XkbDwFjYHUpiV/vNqh2Xtpisc HUbRtwkrZBJF7ipLTXqS7kIRVpeYKrx8fqYoNF4xLzaXNopQc/tzSF5CbhlEg954S6uz W/aq0LkY0gcmiwhBL0sHOu9o5iXgMINvQy876ra5a39EP4r9AWESe3/Wd4fpG1tx9ki0 +ClrErWq8qtsoLtLsN2oOO3CQJn7QBGaNjWwoNM05ajP1wU+KN2dWYYQhqQRP+oAZVjP H1fQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19si12549523pgg.20.2019.06.25.00.27.21; Tue, 25 Jun 2019 00:27:38 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728290AbfFYFba (ORCPT + 99 others); Tue, 25 Jun 2019 01:31:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34588 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbfFYFb3 (ORCPT ); Tue, 25 Jun 2019 01:31:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 290548E223; Tue, 25 Jun 2019 05:31:05 +0000 (UTC) Received: from xz-x1 (unknown [10.66.60.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9BB435D9C3; Tue, 25 Jun 2019 05:30:49 +0000 (UTC) Date: Tue, 25 Jun 2019 13:30:47 +0800 From: Peter Xu To: Linus Torvalds Cc: Linux-MM , Linux List Kernel Mailing , David Hildenbrand , Hugh Dickins , Maya Gokhale , Jerome Glisse , Pavel Emelyanov , Johannes Weiner , Martin Cracauer , Denis Plotnikov , Shaohua Li , Andrea Arcangeli , Mike Kravetz , Marty McFadden , Mike Rapoport , Mel Gorman , "Kirill A . Shutemov" , "Dr . David Alan Gilbert" Subject: Re: [PATCH v5 02/25] mm: userfault: return VM_FAULT_RETRY on signals Message-ID: <20190625053047.GC10020@xz-x1> References: <20190620022008.19172-1-peterx@redhat.com> <20190620022008.19172-3-peterx@redhat.com> <20190624074250.GF6279@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 25 Jun 2019 05:31:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 24, 2019 at 09:31:42PM +0800, Linus Torvalds wrote: > On Mon, Jun 24, 2019 at 3:43 PM Peter Xu wrote: > > > > Should we still be able to react on signal_pending() as part of fault > > handling (because that's what this patch wants to do, at least for an > > user-mode page fault)? Please kindly correct me if I misunderstood... > > I think that with this patch (modulo possible fix-ups) then yes, as > long as we're returning to user mode we can do signal_pending() and > return RETRY. > > But I think we really want to add a new FAULT_FLAG_INTERRUPTIBLE bit > for that (the same way we already have FAULT_FLAG_KILLABLE for things > that can react to fatal signals), and only do it when that is set. > Then the page fault handler can set that flag when it's doing a > user-mode page fault. > > Does that sound reasonable? Yes that sounds reasonable to me, and that matches perfectly with TASK_INTERRUPTIBLE and TASK_KILLABLE. The only thing that I am a bit uncertain is whether we should define FAULT_FLAG_INTERRUPTIBLE as a new bit or make it simply a combination of: FAULT_FLAG_KILLABLE | FAULT_FLAG_USER The problem is that when we do set_current_state() with either TASK_INTERRUPTIBLE or TASK_KILLABLE we'll only choose one of them, but never both. Here since the fault flag is a bitmask then if we introduce a new FAULT_FLAG_INTERRUPTIBLE bit and use it in the fault flags then we should probably be sure that FAULT_FLAG_KILLABLE is also set when with that (since IMHO it won't make much sense to make a page fault "interruptable" but "un-killable"...). Considering that TASK_INTERRUPTIBLE should also always in user-mode page faults so this dependency seems to exist with FAULT_FLAG_USER. Then I'm thinking maybe using the combination to express the meaning that "we would like this page fault to be interruptable, even for general userspace signals" would be nicer? AFAIK currently only handle_userfault() have such code to handle normal signals besides SIGKILL, and it was trying to detect this using this rule already: return_to_userland = (vmf->flags & (FAULT_FLAG_USER|FAULT_FLAG_KILLABLE)) == (FAULT_FLAG_USER|FAULT_FLAG_KILLABLE); Then if we define that globally and officially then we can probably replace this simply with: return_to_userland = vmf->flags & FAULT_FLAG_INTERRUPTIBLE; What do you think? Thanks, -- Peter Xu