Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp523751pxb; Thu, 12 Aug 2021 23:50:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWm1wnfcuNjqEV1HnY/ONa6tIrXMobU3rP+IyNiGyEuOJx9GUevOrxoMi3/KKPHWGHzOmO X-Received: by 2002:a17:906:318c:: with SMTP id 12mr1058780ejy.28.1628837410779; Thu, 12 Aug 2021 23:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628837410; cv=none; d=google.com; s=arc-20160816; b=hd9Q5ImZGqWXcOdjfpemgBmH3Qz7f+o6/CqPxh/xs/TZsPZRQ4vJgB62G8FgBmd8yn 7aTy+SZi/EeoStTAaob3Nh5cnhsmoHJuzi1sov5o7Bl+EXrcJii84NI3M05w/gQWkdxQ PjRP56nIMmaXJcYaUYsgnHGAFM0RU4GxqU9Jrf5lY5GHoM+3ZHKmIT7P/P5vC5LsaF+o 0dOEPkP1VFDeNjC6sRfxm7ZDVbEZVUIi+EZguf9xGTJkdZ0Ne/VUA0OYSp+cBFpukQsq lUUuBHAAAG6t+kUr5nEXmDBPmwMavaq7GCTCdMupQGc0ZLBpMb37aJApFG93tz3EKMXb aC/A== 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=3Plf9kYprckAlJtYbb7SyhR3dTcw+NdeOwPa/nQw2qQ=; b=GKc8mKflv50hC7T04NWQS8+Nw5YL/xMLCoK2SH6Y2fNi53KkxecLcswxnStytVJV1O Emt7yfk1ZkPnNmXGm0mrjjN2Z5gRhKalpJyr2f4eoQpPOpwxlfD3QuBNPc/v51PjDtS3 QCFvhpLIhxMnMullbVaiwaDXwopb28iGvX7iHxm9cjLO9jm0vlcK56t5mm+7LPSUadJT sx8g5Rnt5IDF+sBNMNDx5557RJQwiYsBAWLU77tp9WJdjUykP09Ax/HcNjp4O185NRrq eEk6w6ToFJ728bjlnsvGIx0/l4ao4RM5SV3N2KtE+iOYnzlpOBBWdrPCpG63MWl4kBSi Velg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uh320nEJ; 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 l17si840143edw.336.2021.08.12.23.49.35; Thu, 12 Aug 2021 23:50:10 -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=uh320nEJ; 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 S238819AbhHMGU3 (ORCPT + 99 others); Fri, 13 Aug 2021 02:20:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238646AbhHMGU2 (ORCPT ); Fri, 13 Aug 2021 02:20:28 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 560A0C061756 for ; Thu, 12 Aug 2021 23:20:02 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d17so10501147plr.12 for ; Thu, 12 Aug 2021 23:20:02 -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=3Plf9kYprckAlJtYbb7SyhR3dTcw+NdeOwPa/nQw2qQ=; b=uh320nEJ2La0l2ayXToOEW/pFFNDV4IY+u1oTBcLjMAFVRSG3DAPfo/hPs+T7LiKFI dly3bhsDBpKtyQRzECa444UPfQVrIB3XDQXtPifiYLDJkREE4qAQZunXeaiX4qxO3uAz CE6fUWMzZDQ7NsW3nBfncRxjGIgKPSgd89onfG4mPkDt0WNiWtplH9sw+JWpjcsRif0b lrOU/mBCAlrAZUob8UR3RLm3cVtRilQ0PU2RTX9BsF4Yi/FPpxD4PprjhOKGzOjdLUcc tHiy/gjnnpvJ+SwLoxwavleSITLsTGBh5VarwFOoH9e82cCKLUAE93OetgTrgUMLm1Uo jMaA== 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=3Plf9kYprckAlJtYbb7SyhR3dTcw+NdeOwPa/nQw2qQ=; b=G4JkkJ4jC+UnpxCn5fY7ijFKWVsp/mtgyelDr/8QhNEm3+mzpK+DF75DblKpqunXw+ Ig3wa4uDpStJKnias2J1wAtJoAcHCwcj645oPEqpeXXJhTu0cmD3pwrK67z9ypl/raz6 AGZTBTOAHR8e+w9/jlX/KUQOFBtRV/BNtiHntEW8Woh9c46mY6LPpy/akEHT/EjYzanK eHkdIbdRhLFELvcv6tk6ztMqJAfFI3ScrsSYVoUI4vRvuQ2H+12WF1sPrTMWy7lSjxix v2HSoHGvapkN0fEkFCfP0FU3WP14EdYlN+NrCmMg6wel48sqKpRdr0y4btxnt3A10cg9 tpfA== X-Gm-Message-State: AOAM5324l64cPea5kjhsm1kXNlKFELvCMnhLTHwZEl1veUG5VG7wbulu 7YughQo2L/eJ1GHw49Ks3fc= X-Received: by 2002:a17:90a:db09:: with SMTP id g9mr1068009pjv.205.1628835601865; Thu, 12 Aug 2021 23:20:01 -0700 (PDT) Received: from localhost (60-242-208-220.static.tpgi.com.au. [60.242.208.220]) by smtp.gmail.com with ESMTPSA id y23sm810874pfb.130.2021.08.12.23.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 23:20:01 -0700 (PDT) Date: Fri, 13 Aug 2021 16:19:56 +1000 From: Nicholas Piggin Subject: Re: [PATCH v2 2/2] powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto To: Benjamin Herrenschmidt , Christophe Leroy , Michael Ellerman , Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <389962b1b702e3c78d169e59bcfac56282889173.1618331882.git.christophe.leroy@csgroup.eu> In-Reply-To: <389962b1b702e3c78d169e59bcfac56282889173.1618331882.git.christophe.leroy@csgroup.eu> MIME-Version: 1.0 Message-Id: <1628834900.ecs68prq9x.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 Christophe Leroy's message of April 14, 2021 2:38 am: > Using asm goto in __WARN_FLAGS() and WARN_ON() allows more > flexibility to GCC. >=20 > For that add an entry to the exception table so that > program_check_exception() knowns where to resume execution > after a WARNING. Nice idea. How much does it bloat the exception table? How easy would it be to make a different exception table for unimportant stuff like WARN_ON faults? >=20 > Here are two exemples. The first one is done on PPC32 (which > benefits from the previous patch), the second is on PPC64. >=20 > unsigned long test(struct pt_regs *regs) > { > int ret; >=20 > WARN_ON(regs->msr & MSR_PR); >=20 > return regs->gpr[3]; > } >=20 > unsigned long test9w(unsigned long a, unsigned long b) > { > if (WARN_ON(!b)) > return 0; > return a / b; > } >=20 > Before the patch: >=20 > 000003a8 : > 3a8: 81 23 00 84 lwz r9,132(r3) > 3ac: 71 29 40 00 andi. r9,r9,16384 > 3b0: 40 82 00 0c bne 3bc > 3b4: 80 63 00 0c lwz r3,12(r3) > 3b8: 4e 80 00 20 blr >=20 > 3bc: 0f e0 00 00 twui r0,0 > 3c0: 80 63 00 0c lwz r3,12(r3) > 3c4: 4e 80 00 20 blr >=20 > 0000000000000bf0 <.test9w>: > bf0: 7c 89 00 74 cntlzd r9,r4 > bf4: 79 29 d1 82 rldicl r9,r9,58,6 > bf8: 0b 09 00 00 tdnei r9,0 > bfc: 2c 24 00 00 cmpdi r4,0 > c00: 41 82 00 0c beq c0c <.test9w+0x1c> > c04: 7c 63 23 92 divdu r3,r3,r4 > c08: 4e 80 00 20 blr >=20 > c0c: 38 60 00 00 li r3,0 > c10: 4e 80 00 20 blr >=20 > After the patch: >=20 > 000003a8 : > 3a8: 81 23 00 84 lwz r9,132(r3) > 3ac: 71 29 40 00 andi. r9,r9,16384 > 3b0: 40 82 00 0c bne 3bc > 3b4: 80 63 00 0c lwz r3,12(r3) > 3b8: 4e 80 00 20 blr >=20 > 3bc: 0f e0 00 00 twui r0,0 >=20 > 0000000000000c50 <.test9w>: > c50: 7c 89 00 74 cntlzd r9,r4 > c54: 79 29 d1 82 rldicl r9,r9,58,6 > c58: 0b 09 00 00 tdnei r9,0 > c5c: 7c 63 23 92 divdu r3,r3,r4 > c60: 4e 80 00 20 blr >=20 > c70: 38 60 00 00 li r3,0 > c74: 4e 80 00 20 blr One thing that would be nice for WARN_ON_ONCE is to patch out the trap after the program interrupt. I've seen sometimes the WARN_ON_ONCE starts firing a lot and slows down the kernel. That gets harder to do if the trap is now part of the control flow. I guess that's less important case for performance though. And in theory you might be able to replace the trap with an equivalent cmp and branch (but that's probably going too over engineering it). Thanks, Nick