Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6857334ybi; Wed, 29 May 2019 14:31:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzp1bbAKMpqjKbGAOGtRVOTyDQkKfL8pGy5hZ7Dj8meBmzKYc3BORD3iCJ3SZEE19ghQvwq X-Received: by 2002:a63:e04:: with SMTP id d4mr80754pgl.331.1559165494989; Wed, 29 May 2019 14:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559165494; cv=none; d=google.com; s=arc-20160816; b=J2qLLVZofWiBxyTNNEkmS1jldQv5xoo66jep21xuBmX96ZjBu34TQD0/y1d4H2P4Ej h3eKSoyveJ2IGbNSw0zefetBKA7Njk1IvwjbEKg0iJLqLfofRydjGESq8lHPVDYS/D34 oBi0t9m7pdDSGDNI8bxJi6mO1lG82/WaPnltO5bKtkUlQf96RP8DALrKCGS0xmKneIAc 16hhSfWFZ27O7zPWC+jJQdiR/HOi5gsdBgT6lTaT55yRbI4wX+MFurKu52ywU3s7xM+x gcgHk0rEsrYNP9JegYit3o1Dcp5jd4dlQA7NJmR6XVrT5LLzGivbuaPpe9KsmbwpTe2B jFqg== 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; bh=BGYvDwhdmt7WdDi34L3OoKLpPPp794FZrBkuhyUn1ww=; b=DBSkUHhtVY9YsVtZlds44pCtWOWbhpNT9gM4cSbv+WWSaNzQqyHQ+lRjJl6ocCi1yE bA5lyAGw6b0CqInYAbFVfs6QQ43DKt4Ujd3v/1hmkEn0NPptAcchDBxpz/3IT2pWxvox LbK1UOVBQXpuB+YL+bbF0nGIealK5Y2ByDIKO+FE5vXsSMk23megr8TzeUxBVdl+pqWb Ji+wh98yMg53RQLx/avfLmlYeYnn3EHFZjtAl+1CroclA/MHlLDnl5aBaTpjw0Flno4G 57S/1Sqd4eQJ7Tob+1aYx2jSIOz0iCAv7BEgeBHRA7Ua8r4SlCywisZPvpLpKQFVEFVq tqFg== 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 z18si913458pgv.229.2019.05.29.14.31.18; Wed, 29 May 2019 14:31:34 -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 S1726688AbfE2V3W convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 May 2019 17:29:22 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:64309 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726189AbfE2V3W (ORCPT ); Wed, 29 May 2019 17:29:22 -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 16725551-1500050 for multiple; Wed, 29 May 2019 22:29:06 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Andrew Morton , Sebastian Andrzej Siewior From: Chris Wilson In-Reply-To: <20190529072540.g46j4kfeae37a3iu@linutronix.de> Cc: Hugh Dickins , x86@kernel.org, Mike Rapoport , Andrea Arcangeli , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Borislav Petkov , Pavel Machek , Dave Hansen References: <20190526173325.lpt5qtg7c6rnbql5@linutronix.de> <20190528211826.0fa593de5f2c7480357d3ca5@linux-foundation.org> <20190529072540.g46j4kfeae37a3iu@linutronix.de> Message-ID: <155916534299.2252.10999808950517357760@skylake-alporthouse-com> User-Agent: alot/0.6 Subject: Re: [PATCH v2] x86/fpu: Use fault_in_pages_writeable() for pre-faulting Date: Wed, 29 May 2019 22:29:03 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Sebastian Andrzej Siewior (2019-05-29 08:25:40) > From: Hugh Dickins > > Since commit > > d9c9ce34ed5c8 ("x86/fpu: Fault-in user stack if copy_fpstate_to_sigframe() fails") > > we use get_user_pages_unlocked() to pre-faulting user's memory if a > write generates a pagefault while the handler is disabled. > This works in general and uncovered a bug as reported by Mike Rapoport. > It has been pointed out that this function may be fragile and a > simple pre-fault as in fault_in_pages_writeable() would be a better > solution. Better as in taste and simplicity: That write (as performed by > the alternative function) performs exactly the same faulting of memory > that we had before. This was suggested by Hugh Dickins and Andrew > Morton. > > Use fault_in_pages_writeable() for pre-faulting of user's stack. > > Fixes: d9c9ce34ed5c8 ("x86/fpu: Fault-in user stack if copy_fpstate_to_sigframe() fails") > Suggested-by: Andrew Morton > Signed-off-by: Hugh Dickins > [bigeasy: patch description] > Signed-off-by: Sebastian Andrzej Siewior I am able to reliably hit the bug here by putting the system under mempressure, and afterwards processes would die as the exit. This patch also greatly reduces cycletest latencies while under that mempressure, ~320ms -> ~16ms (on a bxt while also spinning on i915.ko). Tested-by: Chris Wilson -Chris