From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00E09C432BE for ; Thu, 26 Aug 2021 14:53:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDCE461026 for ; Thu, 26 Aug 2021 14:53:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242902AbhHZOxx (ORCPT ); Thu, 26 Aug 2021 10:53:53 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:58415 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231458AbhHZOxw (ORCPT ); Thu, 26 Aug 2021 10:53:52 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4GwQnW0gGZz9sTr; Thu, 26 Aug 2021 16:53:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9XwOq-zzMJJ3; Thu, 26 Aug 2021 16:53:03 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4GwQnV6NFyz9sTj; Thu, 26 Aug 2021 16:53:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 723E78B8D1; Thu, 26 Aug 2021 16:53:02 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id cWljRHwm5qtx; Thu, 26 Aug 2021 16:53:02 +0200 (CEST) Received: from [172.25.230.102] (po15451.idsi0.si.c-s.fr [172.25.230.102]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3A3948B8B4; Thu, 26 Aug 2021 16:53:02 +0200 (CEST) Subject: Re: [PATCH v2 2/2] powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto To: Michael Ellerman , Nathan Chancellor Cc: Benjamin Herrenschmidt , Paul Mackerras , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, clang-built-linux@googlegroups.com, llvm@lists.linux.dev References: <389962b1b702e3c78d169e59bcfac56282889173.1618331882.git.christophe.leroy@csgroup.eu> <87h7fcc2m4.fsf@mpe.ellerman.id.au> <3fad8702-278a-d9f9-1882-6958ce570bcc@csgroup.eu> <87sfyw9sel.fsf@mpe.ellerman.id.au> From: Christophe Leroy Message-ID: <5b0984eb-b933-7ea5-462d-283d0fe09424@csgroup.eu> Date: Thu, 26 Aug 2021 16:53:03 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <87sfyw9sel.fsf@mpe.ellerman.id.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 26/08/2021 à 16:45, Michael Ellerman a écrit : > Christophe Leroy writes: >> Le 26/08/2021 à 05:21, Michael Ellerman a écrit : >>> Nathan Chancellor writes: >>>> On Tue, Apr 13, 2021 at 04:38:10PM +0000, Christophe Leroy wrote: >>>>> Using asm goto in __WARN_FLAGS() and WARN_ON() allows more >>>>> flexibility to GCC. >>> ... >>>> >>>> This patch as commit 1e688dd2a3d6 ("powerpc/bug: Provide better >>>> flexibility to WARN_ON/__WARN_FLAGS() with asm goto") cause a WARN_ON in >>>> klist_add_tail to trigger over and over on boot when compiling with >>>> clang: >> >> ... >> >>> >>> This patch seems to fix it. Not sure if that's just papering over it though. >>> >>> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h >>> index 1ee0f22313ee..75fcb4370d96 100644 >>> --- a/arch/powerpc/include/asm/bug.h >>> +++ b/arch/powerpc/include/asm/bug.h >>> @@ -119,7 +119,7 @@ __label_warn_on: \ >>> \ >>> WARN_ENTRY(PPC_TLNEI " %4, 0", \ >>> BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \ >>> - __label_warn_on, "r" (x)); \ >>> + __label_warn_on, "r" (!!(x))); \ >>> break; \ >>> __label_warn_on: \ >>> __ret_warn_on = true; \ >> >> But for a simple WARN_ON() call: >> >> void test(unsigned long b) >> { >> WARN_ON(b); >> } >> >> Without your change with GCC you get: >> >> 00000000000012d0 <.test>: >> 12d0: 0b 03 00 00 tdnei r3,0 >> 12d4: 4e 80 00 20 blr >> >> >> With the !! change you get: >> >> 00000000000012d0 <.test>: >> 12d0: 31 23 ff ff addic r9,r3,-1 >> 12d4: 7d 29 19 10 subfe r9,r9,r3 >> 12d8: 0b 09 00 00 tdnei r9,0 >> 12dc: 4e 80 00 20 blr > > Yeah that's a pity. > > We could do something like below, which is ugly, but would be better > than having to revert the whole thing. Yes looks nice, we already had that kind of stuff in the past, even more ugly. > > Although this doesn't fix the strange warning in drivers/net/ethernet/sfc. What's the warning ? > > So possibly we need a CLANG ifdef around the whole thing, and use the > old style warn for clang. > Christophe