Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 16 Feb 2019 02:00:43 -0000 Received: from mga11.intel.com ([192.55.52.93]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gupHV-0000GG-Sc for speck@linutronix.de; Sat, 16 Feb 2019 03:00:42 +0100 Date: Fri, 15 Feb 2019 18:00:39 -0800 From: Andi Kleen Subject: [MODERATED] Re: [PATCH v5 14/27] MDSv5 3 Message-ID: <20190216020039.GG16922@tassilo.jf.intel.com> References: <8b89fce6dd87638a00078082141d3ce5fe13d0ea.1547858934.git.ak@linux.intel.com> MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: > Lets look at the different scenarios: > > process A -> process A Thread switch in same process, > do nothing > > process A -> process B Switches mm -> set percpu flush > > process A -> kernel Do nothing (rely on lazy mm) > kernel -> process B Switches mm -> set percpu flush > kernel -> kernel do nothing > kernel -> process A if lazy mm -> set percpu flush I revisited this now. I think your proposal is to unconditionally set the per cpu flag in switch_mm. But this doesn't handle the following case: process A -> kernel -> process A In this case we want to flush because of the kernel thread (e.g. might contain crypto) but switch_mm is never called. I'll stay with the previous version for now. I did some updates to the logic. It now uses per cpu state, and also clears when coming out of idle. This is needed because the CPU coming out of idle might inherit some SMT state from the sibling. This actually simplifies the logic nicely, so it's very straight forward now. -Andi