Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp493394pxb; Thu, 26 Aug 2021 07:45:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx55SOI4xN4evPG6T8sCqZ+JQel8togSDtyiXrt0+09+pBMGFg4JJbMsIXDK8g8Zr1GWOoM X-Received: by 2002:a02:374f:: with SMTP id r76mr335142jar.24.1629989119309; Thu, 26 Aug 2021 07:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629989119; cv=none; d=google.com; s=arc-20160816; b=YAgp/GsoB/PNB0A7/5SPnYDksyTw6G2pFmxE4hNDFiMFhhoUHq9YD2kxIbVaGTZknV Sbz0KMjDRSRL+J1J2F9pgFJ8hch213n6qIV8qZclXJiyO9UvqIVXQ7OrUP2bQDXwpNw/ 75srgD7o8/QKkZ8hkl5f3tMa3N4ZFv0nqdOCQmWOvfirA1tbe6jSTrCAF6bZrq+l2DGn JAz4Wc9cbzXw3cB6usJ1QV+4U/aqz/XnesG45ifV0vSiUOzryKoGuwsRruapdNtdbRX+ 8RdxS7ILTxEZaTFPvuIBQUyMqjPBhEBpcNq9eAJsqD6FS+6iHX7NXbzfwKHhS6hurCF9 TLsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=NYhm6oxIIbFgOYjwbDCHQa/wyFx/8iZXiPrCv0v646w=; b=apXKE5m0AthN50Poevk5jAwxwTtUpTJ1Dp2E9C/tlAJsYm6+A2dIkgr7dnQEL+iGbU tq5AIzM+1XnohLd03PWvKN1ibNRTa113X5U4AOIx4XhJqcpAGwkhHMDORkuCfgHG0Hdr Cw9SJcLbgcUC0te7JMvP+nBiAsHDvU3RiZUWADz56IUTmQq746uGdgMpm/bJcrGhVv/h zHcFfM4oe0ZAxmTNGGpfBdY2JWDxYVsSsgUGq70K37S+TbOCrdzXnl2w/6sNWNy2gOCZ /UJW8w1Mvhsjb81cYFE3dYPvX2j9JGd+1rdZWaiaRg5aULeulc+MZO182r7CsL+K4Kot 73fA== ARC-Authentication-Results: i=1; mx.google.com; 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 p35si2342684jal.123.2021.08.26.07.45.07; Thu, 26 Aug 2021 07:45:19 -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; 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 S242840AbhHZOo1 (ORCPT + 99 others); Thu, 26 Aug 2021 10:44:27 -0400 Received: from gate.crashing.org ([63.228.1.57]:46263 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbhHZOo1 (ORCPT ); Thu, 26 Aug 2021 10:44:27 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 17QEb8u8022174; Thu, 26 Aug 2021 09:37:08 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 17QEb8T2022173; Thu, 26 Aug 2021 09:37:08 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 26 Aug 2021 09:37:08 -0500 From: Segher Boessenkool To: Nicholas Piggin Cc: Benjamin Herrenschmidt , Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Paul Mackerras Subject: Re: [PATCH v2 1/2] powerpc/bug: Remove specific powerpc BUG_ON() and WARN_ON() on PPC32 Message-ID: <20210826143708.GC1583@gate.crashing.org> References: <1628834356.pr4zgn1xf1.astroid@bobo.none> <20210818150653.GJ1583@gate.crashing.org> <1629946707.f6ptz0tgle.astroid@bobo.none> <20210826124901.GY1583@gate.crashing.org> <1629983260.5jkx2jf0y8.astroid@bobo.none> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1629983260.5jkx2jf0y8.astroid@bobo.none> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 26, 2021 at 11:57:52PM +1000, Nicholas Piggin wrote: > Excerpts from Segher Boessenkool's message of August 26, 2021 10:49 pm: > > On Thu, Aug 26, 2021 at 01:26:14PM +1000, Nicholas Piggin wrote: > >> Excerpts from Segher Boessenkool's message of August 19, 2021 1:06 am: > >> > On Fri, Aug 13, 2021 at 04:08:13PM +1000, Nicholas Piggin wrote: > >> >> This one possibly the branches end up in predictors, whereas conditional > >> >> trap is always just speculated not to hit. Branches may also have a > >> >> throughput limit on execution whereas trap could be more (1 per cycle > >> >> vs 4 per cycle on POWER9). > >> > > >> > I thought only *taken* branches are just one per cycle? > >> > >> Taken branches are fetched by the front end at one per cycle (assuming > >> they hit the BTAC), but all branches have to be executed by BR at one > >> per cycle > > > > This is not true. (Simple) predicted not-taken conditional branches are > > just folded out, never hit the issue queues. And they are fetched as > > many together as fit in a fetch group, can complete without limits as > > well. > > No, they are all dispatched and issue to the BRU for execution. It's > trivial to construct a test of a lot of not taken branches in a row > and time a loop of it to see it executes at 1 cycle per branch. (s/dispatched/issued/) Huh, this was true on p8 already. Sorry for my confusion. In my defence, this doesn't matter for performance on "real code". > > Correctly predicted simple conditional branches just get their prediction > > validated (and that is not done in the execution units). Incorrectly > > predicted branches the same, but those cause a redirect and refetch. > > How could it validate prediction without issuing? It wouldn't know when > sources are ready. In the backend. But that is just how it worked on older cores :-/ > >> The first problem seems like the show stopper though. AFAIKS it would > >> need a special builtin support that does something to create the table > >> entry, or a guarantee that we could put an inline asm right after the > >> builtin as a recognized pattern and that would give us the instruction > >> following the trap. > > > > I'm not quite sure what this means. Can't you always just put a > > > > bla: asm(""); > > > > in there, and use the address of "bla"? > > Not AFAIKS. Put it where? After wherever you want to know the address after. You will have to make sure they stay together somehow. It is much easier to get the address of something, not the address after it. If you know it is just one insn anyway, that isn't hard to handle either (even if prefixed insns exist). > > If not, you need to say a lot > > more about what you actually want to do :-/ > > We need to put the address (or relative offset) of the trap instruction > into an entry in a different section. Basically this: > > __builtin_trap(); > asm ("1: \n\t" > " .section __bug_table,\"aw\" \n\t" > "2: .4byte 1b - 2b - 4 \n\t" > " .previous"); > > Where the 1: label must follow immediately after the trap instruction, > and where the asm must be emitted even for the case of no-return traps > (but anything following the asm could be omitted). The address *after* the trap insn? That is much much harder than the address *of* the trap insn. Segher