Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp257230pxk; Thu, 1 Oct 2020 01:19:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHSyNf25bpIF5sIJYY8+lDuth+RvmmuAjjbxU06M6nhQj7ofNxbP9qlUL+pTwoznCUojs/ X-Received: by 2002:a17:906:a192:: with SMTP id s18mr873110ejy.205.1601540370546; Thu, 01 Oct 2020 01:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601540370; cv=none; d=google.com; s=arc-20160816; b=YD9johfTQ3U/Cqmab77GK9aKScOHymSMIZEoqXUOBlFX4B5txbw0DWpskwXlhbloP0 OnMD2tYvfZ48fsk1IbNxbRK257Kz0NsCFDQeCGT7Ye5oux720/8teVlGEo4Lrq88NVua BSWn5WF05TeOCr5ei+AFBHNvbgfiK2G8vzpjAQrh1zMP3rGXWpiDoQeURaTkK3xWmuSw owOe/wPWNzGSb9tfdc31QcrV48FhUoRDWyG6S6ENN4izhPizXwlAq+cGl73BT1rgeqoh bZowLPRfImwv80i3YLYPtANZnRBpBy3T+khjZ+vIDiWdo9ryD63+9SLoJHibILJJUQnP irTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=aaFFFYU2nU1c1LpxzaEuCrlEv0dNxBBazmDNCKzjWhQ=; b=LxDaGWau8xaFZpmSIvMlBSK6e5s8b1dyCpMO6U1uUj2q1lGlkcsHq/RWAUJlL8qQ3G Ykt/sXGD1M3XisEl8mIWSkINqu/8F85SjMAhb+7vkl1a4NAwHMGmK7JKf2QEmjuI4WSI Z78m/7pJTx9mAd+KTZ4dACi/7rdQHTJ8R0fJixke3AaAoyDN9QkSEr59Tj0Q0Vn4aXnm +/GGs2HfMS7vhVGsSGwNfQTgKrSRo3b8fuUzkJnIit7MZqx1eiUcpTq2nBqxm6sQhPq4 /xGOyvy0nQ8O0gXmYO9dojGBOsgcqintWBcIVVj9D20mtCwqH8R7oeB1I8dEr/qSgw10 4iSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jA8VuHqG; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si2870794eds.157.2020.10.01.01.19.07; Thu, 01 Oct 2020 01:19:30 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=jA8VuHqG; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730534AbgJAIRq (ORCPT + 99 others); Thu, 1 Oct 2020 04:17:46 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:34208 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbgJAIRq (ORCPT ); Thu, 1 Oct 2020 04:17:46 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1601540264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aaFFFYU2nU1c1LpxzaEuCrlEv0dNxBBazmDNCKzjWhQ=; b=jA8VuHqG7dR12X3FlJNmeMd47nnRDcgsJ5n5bOmbpMql9hCd3e0CnHU9VtShqOb5V0lK/Y SkASnX+as95eOAJO+Hfqoidik1erwa5SlXEKo8Iuy+dSZ4ieggN1+8GYNGJrtbHTu8C8eo 6xqamF6nz4wd7VRNaJJSbHCIrwnmIjH/fGDlxS9kD/kJ8SPrltiWc7DZkBqV/ZuEfvhnKw qlvQ5Nv751/xHGIjh+F/87xaHVVsKOPhGRyCVOkTHA+mLjzOW98FTFdhCXoQ7h0E3eon4u N9HM6brDT3RvB7kFiTyXWAd5I8GfTJT2gf6WGPEBpy1CaI4Aq84Ya6zmcqQ9dw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1601540264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aaFFFYU2nU1c1LpxzaEuCrlEv0dNxBBazmDNCKzjWhQ=; b=INF3/uYoiagoxP4R7kr72ColYm0dw1/wNd0cPL1pK1bhqdx4jL1EJPV58QoQLrKwe4tX0E zY3ka4FhKY34RODQ== To: "Singh\, Balbir" , Peter Zijlstra Cc: Lukas Bulwahn , Dave Hansen , Andy Lutomirski , Ingo Molnar , Borislav Petkov , "x86\@kernel.org" , "H. Peter Anvin" , Nathan Chancellor , Nick Desaulniers , "linux-kernel\@vger.kernel.org" , "clang-built-linux\@googlegroups.com" , "kernel-janitors\@vger.kernel.org" , "linux-safety\@lists.elisa.tech" Subject: Re: [PATCH -next for tip:x86/pti] x86/tlb: drop unneeded local vars in enable_l1d_flush_for_task() In-Reply-To: <044e9835-f4fe-6670-90df-15fe376ecadd@amazon.com> References: <20200928124457.27289-1-lukas.bulwahn@gmail.com> <20200929071211.GJ2628@hirez.programming.kicks-ass.net> <20200929083709.GC2651@hirez.programming.kicks-ass.net> <87eemji887.fsf@nanos.tec.linutronix.de> <20200930170316.GB2628@hirez.programming.kicks-ass.net> <87blhni1pg.fsf@nanos.tec.linutronix.de> <20200930183552.GG2628@hirez.programming.kicks-ass.net> <87k0wbgd2s.fsf@nanos.tec.linutronix.de> <19f57cbe-ba33-17d5-440c-2765e670782f@amazon.com> <044e9835-f4fe-6670-90df-15fe376ecadd@amazon.com> Date: Thu, 01 Oct 2020 10:17:43 +0200 Message-ID: <877dsagy1k.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 01 2020 at 10:48, Balbir Singh wrote: > On 1/10/20 9:49 am, Singh, Balbir wrote: >> >> +static void l1d_flush_kill(struct callback_head *ch) >> +{ >> + clear_ti_thread_flag(¤t->thread_info, TIF_SPEC_L1D_FLUSH); >> + force_signal(SIGBUS); >> +} >> + >> void switch_mm(struct mm_struct *prev, struct mm_struct *next, >> struct task_struct *tsk) >> { >> @@ -443,12 +438,14 @@ static void cond_mitigation(struct task_struct *next) >> } >> >> /* >> - * Flush only if SMT is disabled as per the contract, which is checked >> - * when the feature is enabled. >> + * Flush only if SMT is disabled, if flushing is enabled >> + * and we are on an SMT enabled core, kill the task >> */ >> - if (sched_smt_active() && !this_cpu_read(cpu_info.smt_active) && >> - (prev_mm & LAST_USER_MM_L1D_FLUSH)) >> - l1d_flush_hw(); >> + if (unlikely(prev_mm & LAST_USER_MM_L1D_FLUSH)) { >> + if (!this_cpu_read(cpu_info.smt_active)) >> + l1d_flush_hw(); >> + else >> + task_work_add(prev, l1d_flush_kill, true); > > We have no access the to the previous task and mm->owner depends on MEMCG :) > We can do the magic in mm_mangle_tif_spec_bits(), I suppose No, because we don't have access to prev task there either. Interesting problem to solve. Thanks, tglx