Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2004201imm; Thu, 14 Jun 2018 07:19:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLCS3YEObPMBjDsroT3EK+vuw68JD/fUSY5ceR8dtQmBi28GZGHVEAF9pa/pxsrsPbAwg5A X-Received: by 2002:a62:fb05:: with SMTP id x5-v6mr9771415pfm.210.1528985962537; Thu, 14 Jun 2018 07:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528985962; cv=none; d=google.com; s=arc-20160816; b=C1DEYnaURfpenmGkMeI23ufut/ufBb7aeTGvydPsqbqDWz+Dvu2Y7TkxMCZS8Nu8fp rrONMrrtDv8iZMOqV8j+XNZkKsgLTfgsCJPPcjKpM87b0Wkv1p/m3tMLYtuye61aFb+I dU5cTd0tpAz7TgG1Rt3gLoWzPXYSUkln4BcmKeCgCjbpkZnFrhEA4/IM5tnE8EPxYcGn bKaM0kfjs9E17du79HpNak3nC3abUpmg5dGPajr+6FEWS8cMoNXvATh8O/MSom/3XzmW fYSv+9Xb6Dq+X/jpGg0446sWSDF1/uJ50/Gc59KEsyTQvhdgak9NdTPMjY9D1V4klogi taIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=1nObYcqhWFc9tyTNFXQbC5YghQKIWM27v6YwlV/3A24=; b=L7PtqZn68ryAy3xrpjkpMo6490p143u5Eho2L6RuMxz4h8b4Y70CofxgR7B3ah2rnz yZS2ueWOsdv9nwIjiYAg8IETmpTe3ImqeaAFUUIBSMzNjnr6GM8eQKkxfqXNxjs6N7AX +utfvHugBuZpibzxPDMvUgcIqDX70jhGqmFN0jIx8xKVtwfu4eKonvo3bfCZcBf7FS1l kyHi1JuXiDu96ZYnY433whAGYbMLJ6H1YanoaOffxmMSFpUsOWGy5oVA6x3fElE7ytUn Ewe3JQHLm4Y0X9iOc1dq5lo2Eg9e8q/BiXZUjWr1o6G3W/usS42EyeLJ3BP4ZaRNFlAe AdQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1U+vJ30J; 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 k2-v6si4433396pgc.321.2018.06.14.07.19.07; Thu, 14 Jun 2018 07:19:22 -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; dkim=pass header.i=@kernel.org header.s=default header.b=1U+vJ30J; 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 S966294AbeFNOQ5 (ORCPT + 99 others); Thu, 14 Jun 2018 10:16:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:55120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966270AbeFNONh (ORCPT ); Thu, 14 Jun 2018 10:13:37 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E1A620864; Thu, 14 Jun 2018 14:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528985617; bh=aLaPIcGqQO3aCDLnIDHqLmofCvstZOQgW6f2P/UBThM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1U+vJ30Jwfo9geG1CkW8NmzhQKNZRE515l2W3oe1GZ0BjuWujRk+XnPXH5zoIx1lO grvTkqeBzCu7HQHYwoIBruMgCFPUBvcir31JKt3Y/K5BM8tBKXdSZNh6Zj/yoTCRRw PCkcBf6/GKGCzWpNr+on6/bpgkLiYQ0Dx7Ym9QOU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Lutomirski , Andy Lutomirski , Borislav Petkov , Dave Hansen , Fenghua Yu , "H. Peter Anvin" , Linus Torvalds , Oleg Nesterov , Peter Zijlstra , Quentin Casasnovas , Rik van Riel , Sai Praneeth Prakhya , Thomas Gleixner , yu-cheng yu , Ingo Molnar Subject: [PATCH 4.4 06/24] x86/fpu: Default eagerfpu=on on all CPUs Date: Thu, 14 Jun 2018 16:05:01 +0200 Message-Id: <20180614132724.737334115@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180614132724.483802160@linuxfoundation.org> References: <20180614132724.483802160@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andy Lutomirski commit 58122bf1d856a4ea9581d62a07c557d997d46a19 upstream. We have eager and lazy FPU modes, introduced in: 304bceda6a18 ("x86, fpu: use non-lazy fpu restore for processors supporting xsave") The result is rather messy. There are two code paths in almost all of the FPU code, and only one of them (the eager case) is tested frequently, since most kernel developers have new enough hardware that we use eagerfpu. It seems that, on any remotely recent hardware, eagerfpu is a win: glibc uses SSE2, so laziness is probably overoptimistic, and, in any case, manipulating TS is far slower that saving and restoring the full state. (Stores to CR0.TS are serializing and are poorly optimized.) To try to shake out any latent issues on old hardware, this changes the default to eager on all CPUs. If no performance or functionality problems show up, a subsequent patch could remove lazy mode entirely. Signed-off-by: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Quentin Casasnovas Cc: Rik van Riel Cc: Sai Praneeth Prakhya Cc: Thomas Gleixner Cc: yu-cheng yu Link: http://lkml.kernel.org/r/ac290de61bf08d9cfc2664a4f5080257ffc1075a.1453675014.git.luto@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/fpu/init.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -252,7 +252,10 @@ static void __init fpu__init_system_xsta * not only saved the restores along the way, but we also have the * FPU ready to be used for the original task. * - * 'eager' switching is used on modern CPUs, there we switch the FPU + * 'lazy' is deprecated because it's almost never a performance win + * and it's much more complicated than 'eager'. + * + * 'eager' switching is by default on all CPUs, there we switch the FPU * state during every context switch, regardless of whether the task * has used FPU instructions in that time slice or not. This is done * because modern FPU context saving instructions are able to optimize @@ -263,7 +266,7 @@ static void __init fpu__init_system_xsta * to use 'eager' restores, if we detect that a task is using the FPU * frequently. See the fpu->counter logic in fpu/internal.h for that. ] */ -static enum { AUTO, ENABLE, DISABLE } eagerfpu = AUTO; +static enum { ENABLE, DISABLE } eagerfpu = ENABLE; /* * Find supported xfeatures based on cpu features and command-line input. @@ -340,15 +343,9 @@ static void __init fpu__init_system_ctx_ */ static void __init fpu__init_parse_early_param(void) { - /* - * No need to check "eagerfpu=auto" again, since it is the - * initial default. - */ if (cmdline_find_option_bool(boot_command_line, "eagerfpu=off")) { eagerfpu = DISABLE; fpu__clear_eager_fpu_features(); - } else if (cmdline_find_option_bool(boot_command_line, "eagerfpu=on")) { - eagerfpu = ENABLE; } if (cmdline_find_option_bool(boot_command_line, "no387"))