Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp705937pxb; Wed, 11 Nov 2020 14:18:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMLv/Mcff/Nh1gWposkmph8h1wuwp8xY6osXReHzy1cR60Wna0/Rr5u6gD+IrOtjyipTp1 X-Received: by 2002:a17:906:6409:: with SMTP id d9mr27074358ejm.344.1605133092647; Wed, 11 Nov 2020 14:18:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605133092; cv=none; d=google.com; s=arc-20160816; b=C3Jpfb0N9aEMLk8eYLwKHuKzWfFXK90+FTRroXoZ1W1+XUl7j+1tTctgxFdNzmwpuR qZn4nWXh1aquCbZ5vMkx6gbztMlINjLmsQtqxHI1r8WITYbs+0XV8urEvGl8SEX+NWZO A9mb3Lwijk+hWXffGqk9vNKIQNNLrkDRGYWZolBezM7yaoHrTdxnJ+Fwc/cQe1NcRb3H huu/kqTs+6ibAeoQkM6gOF8RbDbEA8b0z5xIIzMaKz1UEm/kF8D9242ZrtTvPzBqqoXZ Fg/Kx4Arju4a9t1w92useC/qPAYnW0ogKxWtFjEgJ7mzq5OUsODT7canwopZujCdPLl6 4NSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RtDOB/p+s0A9X3On9XtG12Mhh6t6BoNFjGVm9BD2G84=; b=TEjyr30f1sQtRcx871cIO4pPbmy3RaNkJjUcscQoMS/hryndWsiz8psohfZRYfadUs TyuaWZDWtD+rCwAuv4ylQnq5wyJ+MlvBF9gSYFrud0R88i8Sakn9ukdb7JyAB+NR2J0h I0G8PRJxGmqu7fA2jesiE+FQ0CcFC58I8AVzQ1/AcGxysQh94A46I0KxAXrXhs9XKvgE joj+1WYJCt1g3jOi6DFSUwjarJRLHet9Dvq6oA83DpI5JdtIB/kJn8Zjx0uUAuLnzJnV HxH9dmefpZVcnaf3vhWl/ZUiVgmN7El3vdtqgB1pJdrJdUa01cKxcy6AF2cDerLlvPOF U7ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=DGwiFEp+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt4si2947794ejc.439.2020.11.11.14.17.49; Wed, 11 Nov 2020 14:18:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=DGwiFEp+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbgKKWNw (ORCPT + 99 others); Wed, 11 Nov 2020 17:13:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbgKKWNw (ORCPT ); Wed, 11 Nov 2020 17:13:52 -0500 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45AC3C0613D1 for ; Wed, 11 Nov 2020 14:13:52 -0800 (PST) Received: by mail-io1-xd42.google.com with SMTP id t8so3912881iov.8 for ; Wed, 11 Nov 2020 14:13:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RtDOB/p+s0A9X3On9XtG12Mhh6t6BoNFjGVm9BD2G84=; b=DGwiFEp+pIXNn2Psux0cyQergQCa3Ej+0EIeCsfCaUUcKKh0pLO3n3bwEZQRQVa6N/ SQYalo95fKEdUAIr6cCQmUzzydbYaNIgaHC+3sxqAE3sbfXTVrEw2z4ZyTYDKDpzFrit IO90mexI8UwPoTszY8AxLnktMQAIEiefIMeaQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RtDOB/p+s0A9X3On9XtG12Mhh6t6BoNFjGVm9BD2G84=; b=tuh8XE9IPWHkOBjSuevWi2wH3ThC+rHGLgAMp5H/iUqjMaW8XuJjxznIWJIxJ5drEo oVxG691RChrRSXsmNv7jPQKjYuurJ0nj2s17QWM3wkzGsYoRIJIiXNqJQmE1214I56Sf 3ISoXm1RAcMRgepJGM206YFheKo+6Kijk75861JTyU4OuXbHcFc7I4Sx6bbkC6LcgJyV HpwZJr1FiA3Uefb48QYeGtTPWmdoxSkEQutM74XlrXCbRpl4OVAnoYCZ2jFoxX6V6yDm GRuZa9KZa32ZtmcOJA3h5WjzTtKstmdqh6DrSkKJvlyhnNNagqfBzUq6Yy89U1aSbmkg bffg== X-Gm-Message-State: AOAM533mZOZhqLtewuIff+pQB+xLUaINPLVzrS4Os7X9NBXVcn/by0+i GlSNuCyHsCUPrdRs0brJWllZp/FUQ5p0tNLGfxuelA== X-Received: by 2002:a5e:8f06:: with SMTP id c6mr19923813iok.89.1605132831559; Wed, 11 Nov 2020 14:13:51 -0800 (PST) MIME-Version: 1.0 References: <20201111211011.1381848-1-joel@joelfernandes.org> <20201111211011.1381848-2-joel@joelfernandes.org> In-Reply-To: From: Joel Fernandes Date: Wed, 11 Nov 2020 17:13:40 -0500 Message-ID: Subject: Re: [RFC 1/2] x86/bugs: Disable coresched on hardware that does not need it To: Alexander Graf Cc: Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , Tim Chen , Vineeth Pillai , Aaron Lu , Aubrey Li , Thomas Glexiner , LKML , Ingo Molnar , Linus Torvalds , Frederic Weisbecker , Kees Cook , Greg Kerr , Phil Auld , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , vineeth@bitbyteword.org, Chen Yu , Christian Brauner , Agata Gruza , Antonio Gomez Iglesias , konrad.wilk@oracle.com, Dario Faggioli , Paul Turner , Steven Rostedt , Patrick Bellasi , =?UTF-8?B?YmVuYmppYW5nKOiSi+W9qik=?= , Alexandre Chartre , James.Bottomley@hansenpartnership.com, OWeisse@umich.edu, Dhaval Giani , Junaid Shahid , Jesse Barnes , "Hyser,Chris" , Ben Segall , Josh Don , Hao Luo , "Anand K. Mistry" , Borislav Petkov , Daniel Bristot de Oliveira , Dietmar Eggemann , "H. Peter Anvin" , Ingo Molnar , Juri Lelli , Mel Gorman , Mike Rapoport , Tom Lendacky , Tony Luck , Vincent Guittot , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 11, 2020 at 5:00 PM Alexander Graf wrote: > > > > On 11.11.20 22:14, Joel Fernandes wrote: > > > > Sorry, forgot to CC +Tom Lendacky . Please take a look Tom, thanks. > > > > On Wed, Nov 11, 2020 at 4:10 PM Joel Fernandes (Google) > > wrote: > >> > >> Some hardware such as certain AMD variants don't have cross-HT MDS/L1TF > >> issues. Detect this and don't enable core scheduling as it can > >> needlessly slow the device done. > >> > >> Signed-off-by: Joel Fernandes (Google) > >> --- > >> arch/x86/kernel/cpu/bugs.c | 8 ++++++++ > >> kernel/sched/core.c | 7 +++++++ > >> kernel/sched/sched.h | 5 +++++ > >> 3 files changed, 20 insertions(+) > >> > >> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > >> index dece79e4d1e9..0e6e61e49b23 100644 > >> --- a/arch/x86/kernel/cpu/bugs.c > >> +++ b/arch/x86/kernel/cpu/bugs.c > >> @@ -152,6 +152,14 @@ void __init check_bugs(void) > >> #endif > >> } > >> > >> +/* > >> + * Do not need core scheduling if CPU does not have MDS/L1TF vulnerability. > >> + */ > >> +int arch_allow_core_sched(void) > >> +{ > >> + return boot_cpu_has_bug(X86_BUG_MDS) || boot_cpu_has_bug(X86_BUG_L1TF); > > Can we make this more generic and user settable, similar to the L1 cache > flushing modes in KVM? > > I am not 100% convinced that there are no other thread sibling attacks > possible without MDS and L1TF. If I'm paranoid, I want to still be able > to force enable core scheduling. > > In addition, we are also using core scheduling as a poor man's mechanism > to give customers consistent performance for virtual machine thread > siblings. This is important irrespective of CPU bugs. In such a > scenario, I want to force enable core scheduling. Ok, I can make it new kernel command line option with: coresched=on coresched=secure (only if HW has MDS/L1TF) coresched=off Does that work for you? Others, thoughts? Thanks, - Joel