Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 18 Jun 2018 09:42:54 -0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fUqgX-0007Hi-B8 for speck@linutronix.de; Mon, 18 Jun 2018 11:42:53 +0200 Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUqgV-0004Q4-64 for speck@linutronix.de; Mon, 18 Jun 2018 09:42:51 +0000 Date: Mon, 18 Jun 2018 11:42:48 +0200 From: Peter Zijlstra Subject: [MODERATED] Re: [patch V3 12/12] x86/apic: Ignore secondary threads if nosmt=force Message-ID: <20180618094248.GF2458@hirez.programming.kicks-ass.net> References: <20180615162801.748896789@linutronix.de> <20180615162948.440477502@linutronix.de> <20180615222214.GN30690@tassilo.jf.intel.com> MIME-Version: 1.0 In-Reply-To: <20180615222214.GN30690@tassilo.jf.intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: speck@linutronix.de List-ID: On Fri, Jun 15, 2018 at 03:22:14PM -0700, speck for Andi Kleen wrote: > > nosmt=3Dforce makes the APIC detection code ignore the secondary SMT sibl= ings > > completely, so they even do not show up as possible CPUs. >=20 > What's the point of this? Please describe a concrete use case > or drop. It's pretty obvious -- if you never have smt enabled, using this saves you on percpu resources. For example, percpu memory is allocated based on possible_mask, so shrinking that by half reduces the amount of memory used for per-cpu allocations by half as well -- which can be quite significant. > Also it doesn't seem to describe what is actually implemented > by this patch. It does; it stops siblings being accounted on @disabled_cpus and possible_mask. > > This is not fully equivalent to disabling SMT in the BIOS because the low > > level SMT enabling in the BIOS can result in partitioning of resources > > between the siblings, which is not undone by just ignoring them. Some CPUs > > can use the full resources when their sibling is not onlined, but this is > > depending on the CPU family and model and it's not well documented whether > > this applies to all partitioned resources. That means depending on the > > workload disabling SMT in the BIOS might result in better performance. >=20 > This paragraph is quite confused and doesn't really match what > the actual micro architecture does. I would recommend to drop it. This is based on text in the optimization manual, see Linus' email on that last round, fully quoted below in case you have trouble finding it. Message-ID: Basically the text seems to suggest core resources can be statically partitioned if HT is enabled by the BIOS, irrespective of the OS actually using the second thread. If this is not the case, the document would need fixing, not only this Changelog. --- On Wed, 6 Jun 2018, speck for Thomas Gleixner wrote: > > nosmt=3Dforce makes the APIC detection code ignore the secondary SMT siblin= gs > completely, so they even do not show up as possible CPUs. This is more or > less equivalent to disabling SMT in the BIOS. So if we go down this route, I do think it should be very clearly documented that the BIOS disable can (and does) end up having resource allocation advantages that we cannot do in software later on. The intel optimization manual is not very clear on what the partitioning rules are. I find: "In general, the buffers for staging instructions between major pipe stages are partitioned. These buffers include =C2=B5op queues after the execution trace cache, the queues after the register rename stage, the reorder buffer which stages instructions for retirement, and the load and store buffers. In the case of load and store buffers, partitioning also provided an easier implementation to maintain memory ordering for each logical processor and detect memory ordering violations" but some of that partitioning may be relaxed if the HT thread is "not active": "In Intel microarchitecture code name Sandy Bridge, the micro-op queue is statically partitioned to provide 28 entries for each logical processor, irrespective of software executing in single thread or multiple threads. If one logical processor is not active in Intel microarchitecture code name Ivy Bridge, then a single thread executing on that processor core can use the 56 entries in the micro-op queue" but I do not know what "not active" means, and how dynamic it is. Some of that partitioning may be entirely static and depend on the early BIOS disabling of HT, and even if we park the cores, the resources will just be wasted. From the above, it does sound like even if some of the instruction queues may be relaxed when one thread is idle (if that is what "not active") means, load and store buffers may be entirely statically partitioned. So I would really wanmt to have a big note along with the "This is more or less equivalent to disabling SMT in the BIOS" because on some loads it might be a case of "less equivalent" than not. Linus