Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp72972pxb; Wed, 25 Aug 2021 20:27:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlqiQgQLMcIkq6Pa6wv9wQLh8BGwXaAT1gzFhS8F6s2gvFeCAWWwUFYlE2sbLujndwlbCF X-Received: by 2002:a05:6e02:d0f:: with SMTP id g15mr1119389ilj.71.1629948451015; Wed, 25 Aug 2021 20:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629948451; cv=none; d=google.com; s=arc-20160816; b=TQ4GeoTSiVp9Abzbu+nqRby9pBtHAafCjdlBhW0FiEKup/9RsIsxhZKKf1RmXYi2u0 NVkCE5CepM/vFzFrerga+karxwBU2bheMBabU27+k9SvsrScz8kwU9Pebwx3cMr5gClP 6zhd7U+h2AOIcvtGfsVSiICauInXanhVihpPE9MZ6bgdrwLDabt8AremO1Ikg4nj7CEC J8aGDNCkrZKXkhV77zKeWQBprY9OToG/G61/3m45r02pHOq70l63PaH543yajXIseIqu qAUFBC42l5xL/DMOCnu//kk7x039TkcKNxAmV1Kfq0OjncFcRsoXjFH4HzcZI9rHGb+M MBnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id :mime-version:in-reply-to:references:cc:to:subject:from:date :dkim-signature; bh=gTlQCJHQbFHWNH1/OUl4/6XKO8pY5t2nEBNZMA5JnuM=; b=jRDfIw2CY/F6W6tpdtCQ7/sxGJcdT/V2nDvNJfNWFrRYZUvbcQdOROmzvCjT88vUSF MM4gvRMxOVgT1JqJ8jt+M3bdQknrGC57DYcaN7Bu1KK1LIYy1qNmObs6iUVXalQW0rCB BewF3MSiAaFXf2TYg2Ocx9R0dABRyclk/aPRIN0htVd3ngwYBnUGL+QD3IhK4v99KBff e2ASLLzERcHfN2DBYYGFe3jBolhTJahvl+BujU+KJj6SLw5xgojPPnEGYOzzTzTpuPz+ f6J8V/cRKkeWDjZhR/I6pQHamfZfIhXJnk/dTYy/Xb4Y/1595k6CcgY0DxHH+XhfhPfA dDhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=agl6gwgI; 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=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si1377603jam.111.2021.08.25.20.27.19; Wed, 25 Aug 2021 20:27:31 -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=@gmail.com header.s=20161025 header.b=agl6gwgI; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbhHZD1H (ORCPT + 99 others); Wed, 25 Aug 2021 23:27:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbhHZD1G (ORCPT ); Wed, 25 Aug 2021 23:27:06 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67529C061757 for ; Wed, 25 Aug 2021 20:26:20 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id j10-20020a17090a94ca00b00181f17b7ef7so5602174pjw.2 for ; Wed, 25 Aug 2021 20:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=gTlQCJHQbFHWNH1/OUl4/6XKO8pY5t2nEBNZMA5JnuM=; b=agl6gwgInLeQrzWMkp3jywI1vMjb4RiB+d/PJei+WDcwfCro/MnwPd4edz/dLv1ngH +qQ8u7Es8xXG2FmMqiNWQHLQprou/umjrMyvj8yYPnELjsnHOyLVBN2cIxWkGjV7Skdo SvQE6aCqYcKDlWVL4yNXhj/iw6eK/qFeS5eef/oTyEZoz5T/s2Dl/S832NFRhWzCMRce bRraNuTJKtckKPVBjRNQ3+LOjChwXN3dGhIYlIDqODqe35NzRg4Njd8vJPdqbfZNZu0o zyZRdHTSEP8q1TACyi4qu3pxdTyAMSxmQ8xDq8lHM+Tx1EaWgER4CtTUMmrR5TCycplJ C/jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=gTlQCJHQbFHWNH1/OUl4/6XKO8pY5t2nEBNZMA5JnuM=; b=bybUsG+i1kAXaPGaBmaxo+xjstNKHrtamGAXcBkncNeojsNLSD+cI9mTEuWTTU3IkR sY0tDIThdpV87KtEbaSIwCwfqqQCijJkbhip/RCXCVBZ+wCylsJQL3tYa4HDLAPvnoxa LZMlBa90oo4GCYD2wWpGMVGYnPVZh1hoAg5uIa3yJ5RtCPRlsRv/0cyzMiFeHsTtukoz tENgcpsZi5uhlXSYvk0MdSTEPmKpGLw4Fcu5j0p8hzU/4U9Ijg19aO5ZRa+cfb9KVnVz bKL6C3+6QU5kDSBWnD4E1/KeudJJNRuqXIvHirGYZbBnpIfekFpSSHW7xlfgSwMgVY2r Ehnw== X-Gm-Message-State: AOAM532ZftXdd5uXmCDkiUFpNcykmSdROT+KGC8OXw3qkx3D9chCXcyb Xvs+LWJNeqviRjYOLpYtx/ZLIBUt79A= X-Received: by 2002:a17:902:dcc9:b0:134:92c7:3cb6 with SMTP id t9-20020a170902dcc900b0013492c73cb6mr1697569pll.79.1629948379830; Wed, 25 Aug 2021 20:26:19 -0700 (PDT) Received: from localhost (193-116-119-33.tpgi.com.au. [193.116.119.33]) by smtp.gmail.com with ESMTPSA id l14sm6684825pjq.13.2021.08.25.20.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 20:26:19 -0700 (PDT) Date: Thu, 26 Aug 2021 13:26:14 +1000 From: Nicholas Piggin Subject: Re: [PATCH v2 1/2] powerpc/bug: Remove specific powerpc BUG_ON() and WARN_ON() on PPC32 To: Segher Boessenkool Cc: Benjamin Herrenschmidt , Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Paul Mackerras References: <1628834356.pr4zgn1xf1.astroid@bobo.none> <20210818150653.GJ1583@gate.crashing.org> In-Reply-To: <20210818150653.GJ1583@gate.crashing.org> MIME-Version: 1.0 Message-Id: <1629946707.f6ptz0tgle.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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= =20 >> 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). >=20 > I thought only *taken* branches are just one per cycle? Taken branches are fetched by the front end at one per cycle (assuming=20 they hit the BTAC), but all branches have to be executed by BR at one=20 per cycle. On POWER9 BR even has to execute some other things like mflr as well, but at least that's improved on POWER10. Trap is executed at 4 per cycle and will never use branch table entries=20 or alias with a non-tagged predictor and mispredict. > And those > branches are only taken for the exceptional condition (or the case where > we do not care about performance, anyway, if we do have an error most of > the time ;-) ) It's not that big a deal, but trap is really the best instruction for=20 this. >=20 >> On typical ppc32 CPUs, maybe it's a more obvious win. As you say there >> is the CFAR issue as well which makes it a problem for 64s. It would >> have been nice if it could use the same code though. >=20 > On 64-bit the code looks better for the no-error path as well. >=20 >> Maybe one day gcc's __builtin_trap() will become smart enough around >> conditional statements that it it generates better code and tries to >> avoid branches. >=20 > Internally *all* traps are conditional, in GCC. It also can optimise > them quite well. There must be something in the kernel macros that > prevents good optimisation. I did take a look at it at one point. One problem is that the kernel needs the address of the trap instruction=20 to create the entry for it. The other problem is that __builtin_trap=20 does not return so it can't be used for WARN. LLVM at least seems to=20 have a __builtin_debugtrap which does return. The first problem seems like the show stopper though. AFAIKS it would=20 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. Thanks, Nick