Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1431360ybi; Sat, 25 May 2019 01:47:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxii5edYnbSl1e1U5+DbaG1JMcbB40A7Q9/4V4VmfHoG0rkZzid92Ma0QWtWbyTN5Hw2oQg X-Received: by 2002:a17:90a:32c1:: with SMTP id l59mr14797097pjb.1.1558774033161; Sat, 25 May 2019 01:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558774033; cv=none; d=google.com; s=arc-20160816; b=O4Db+GZBeTlqFErBYDRvKg7a5+zNDzFEDqgXbXaK52mV5orFxfn+l6xNiV3cKZVlnj 7ajEmFvNUIVR73xMi2MIFdKRsnok+2+ChH+OMu2vOI920PL2KUSFoh21xB36Cpi52r5h gi2SezHnC4hwqZBFN9oV+6IXahHlBd+uLldUgfMGpYB/eUQoIuslcwD+4GDN0diKqYNY jdmBgD/9r+XRY8ZCUXHuTTpqvl8m5S5rjm5gS/frhqP0wslcbiMEM1IsKEs7f3Xn+jeN ArK4rsRa+neDY0/EhOPRaY4dyM7Fh9oq47qgWQBmHfvqsHOycX9vV2w2djSMBFbZXnbY NA3A== 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=RHlHDOqknjqNX23HPSqwaTpe2sMolI3Xi14OVUzSoOw=; b=Oi094YYH3QWB8Dx+AN6pxeG2sUTqpReSyLCsI4db28YrICYBB/e1oUM+WotMqULFUJ zm9lONVzPkeiMsSTunNLGFomfSAL25ulPmzFzTVb11fAetRUje33N9OGbe9ddf/54gy+ N5B4paw8OMqIaGCxkjnkDC98LHu3cXBs4uIS9Q76zTttO/vOxMqJaT47iP9lJtoWTdw4 Fx3GzEvh8MxBwjBxpr8bpD9Kq0iN0SN1+ZUcwsQM/DHlcBmnul/+tmmiehaINr8sVSgB 3UFQ2wUw1EdlWbNPv7ZDJADKtNt0BVhpT121+JcWyAFQeMMjQ6MUHGxSJKYeYA0uT+Ca 7ZWA== 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 b9si6909292pjo.95.2019.05.25.01.46.57; Sat, 25 May 2019 01:47:13 -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 S1726462AbfEYIpz (ORCPT + 99 others); Sat, 25 May 2019 04:45:55 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:44474 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbfEYIpz (ORCPT ); Sat, 25 May 2019 04:45:55 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1hUSJH-0001zt-6b; Sat, 25 May 2019 10:45:47 +0200 Date: Sat, 25 May 2019 10:45:46 +0200 From: Sebastian Andrzej Siewior To: Hugh Dickins Cc: Andrew Morton , Mike Rapoport , Andrea Arcangeli , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Borislav Petkov , Pavel Machek Subject: Re: [PATCH] mm/gup: continue VM_FAULT_RETRY processing event for pre-faults Message-ID: <20190525084546.fap2wkefepeia22f@linutronix.de> References: <1557844195-18882-1-git-send-email-rppt@linux.ibm.com> <20190522122113.a2edc8aba32f0fad189bae21@linux-foundation.org> <20190522194322.5k52docwgp5zkdcj@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-05-24 15:22:51 [-0700], Hugh Dickins wrote: > I've now run a couple of hours of load successfully with Mike's patch > to GUP, no problem; but whatever the merits of that patch in general, > I agree with Andrew that fault_in_pages_writeable() seems altogether > more appropriate for copy_fpstate_to_sigframe(), and have now run a > couple of hours of load successfully with this instead (rewrite to taste): so this patch instead of Mike's GUP patch fixes the issue you observed? Is this just a taste question or limitation of the function in general? I'm asking because it has been suggested and is used in MPX code (in the signal path but .mmap) and I'm not aware of any limitation. But as I wrote earlier to akpm, if the MM folks suggest to use this instead I am happy to switch. > --- 5.2-rc1/arch/x86/kernel/fpu/signal.c > +++ linux/arch/x86/kernel/fpu/signal.c > @@ -3,6 +3,7 @@ > * FPU signal frame handling routines. > */ > > +#include > #include > #include > > @@ -189,15 +190,7 @@ retry: > fpregs_unlock(); > > if (ret) { > - int aligned_size; > - int nr_pages; > - > - aligned_size = offset_in_page(buf_fx) + fpu_user_xstate_size; > - nr_pages = DIV_ROUND_UP(aligned_size, PAGE_SIZE); > - > - ret = get_user_pages_unlocked((unsigned long)buf_fx, nr_pages, > - NULL, FOLL_WRITE); > - if (ret == nr_pages) > + if (!fault_in_pages_writeable(buf_fx, fpu_user_xstate_size)) > goto retry; > return -EFAULT; > } > > (I did wonder whether there needs to be an access_ok() check on buf_fx; > but if so, then I think it would already have been needed before the > earlier copy_fpregs_to_sigframe(); but I didn't get deep enough into > that to be sure, nor into whether access_ok() check on buf covers buf_fx.) There is an access_ok() at the begin of copy_fpregs_to_sigframe(). The memory is allocated from user's stack and there is (later) an access_ok() for the whole region (which can be more than the memory used by the FPU code). > Hugh Sebastian