Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751012AbdIITiC (ORCPT ); Sat, 9 Sep 2017 15:38:02 -0400 Received: from mail.skyhub.de ([5.9.137.197]:38218 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750805AbdIITiB (ORCPT ); Sat, 9 Sep 2017 15:38:01 -0400 Date: Sat, 9 Sep 2017 21:37:50 +0200 From: Borislav Petkov To: Andy Lutomirski Cc: Linus Torvalds , Markus Trippelsdorf , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , LKML , Ingo Molnar , Tom Lendacky , Rik van Riel Subject: Re: Current mainline git (24e700e291d52bd2) hangs when building e.g. perf Message-ID: <20170909193750.l5o5xtquogmscmom@pd.tnic> References: <20170909163225.GA290@x4> <20170909170537.6xmxtzwripplhhwi@pd.tnic> <20170909172352.GA290@x4> <20170909173633.4ttfk7maooxkcwum@pd.tnic> <20170909181445.GA281@x4> <20170909182952.itqad4ryngjwrgqf@pd.tnic> <20170909190948.xydyega7i2rjnlqt@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1409 Lines: 32 On Sat, Sep 09, 2017 at 12:28:30PM -0700, Andy Lutomirski wrote: > I propose the following fix. If PCID is on, then, in > enter_lazy_tlb(), we switch to init_mm with the no-flush flag set. > (And we give init_mm its own dedicated ASID to keep it simple and fast > -- no need to use the LRU ASID mapping to assign one dynamically.) We > clear the bit in mm_cpumask. That is, we more or less just skip the > whole lazy TLB optimization and rely on PCID CPUs having reasonably > fast CR3 writes. No extra IPIs. I suppose I need to benchmark this. > It will certainly slow down workloads that rapidly toggle between a > user thread and a kernel thread because it forces serialization on > each mm switch, but maybe that's not so bad. Sounds ok so far. > If PCID is off, then we leave the old CR3 value when we go lazy, and > we also leave the flag in mm_cpumask set. When a flush is requested, > we send out the IPI and switch to init_mm (and flush because we have > no choice). IOW, the no-PCID behavior goes back to what it used to > be. Ok, question: why can't we load the new CR3 value too, immediately? Or are we saying, we might get to return to the same CR3 we had before we were lazy so we won't need to do an unnecessary CR3 write with the same value. A microoptimization, if you will. Yes? -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.