Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6125321rwp; Mon, 17 Jul 2023 15:34:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGV5OHMjEDCq7sxNvQVhF6Ys7Ae82XqQ7t66AQsPa392PHnZCDnJiefk0vZZ/HNStssV3V5 X-Received: by 2002:a17:906:1d9:b0:993:da91:6e0c with SMTP id 25-20020a17090601d900b00993da916e0cmr13833259ejj.3.1689633291553; Mon, 17 Jul 2023 15:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689633291; cv=none; d=google.com; s=arc-20160816; b=UWdRBN4+Ke9KNatVlNANtKM/6Fa66d2Zmtf8HxsRA2gEYxn+GYXjJ1ZH7/oJ8jHtph jU3cCPZJHTXmHqoO9JE4u0NPenShbGFLPaK+qOrYwgX35y1l+UiYXILjDtfq/rCsy8E0 W23GnjyN0ilRe2GqVgGy7qjGnsN1ozdxsRfqWLMPcf3VIzFJxAgOIIrhxT81IzXXVE2Q 9Wx7rPIAN132xhS8ALaAuLRUora8GmPhX5yva1SEs0yvLba8UxlfGwoR8qPA2a7DlyrP Ix3tCow8MbqNn7YRZc51eR12NNYueirnWh5p6tYR2+nmChyXlxLWP4AbDZ3swlOiVTbP 3+uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=H0nRdgPIxPY9h+6ob+XM6W1276R2kR6LVZcGXL+V7xQ=; fh=0J2ZgXFWSKkJ44+IdfmlyoF4R3kPMUfsHTwkCS5OYsw=; b=HUimsNcJhLwL8CJ0aVajNOUX0w92tw/9tJTFHKnK0MAv220lDDmF2ZRl4qgeDadAix /gVtaLpZgokH0mcDk0rFJqXLArIKFidivIM4FUp6d3d53yz9HFa1L0GDCGsF9U6acEur GgnNhy47fQ6XSr0JTxhcOEIPOvSia5CzM9sPyK5GB4dOFF4U0AHhB3ZpHf3REHDTaIkF FjluphJxPgLIlP6s+GUeEZJ95XaqB4mxHnrYjNdr+3BqNvW30dYjJxOmcGBD9rgxz3WY Epntuiw6FQngnfWzf1qVIwvto5CLD9Qn14hbX51vEShiNGpfdwCW4U45HdIP8RIo06S1 1WRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=S2DUQ4oH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m15-20020a1709061ecf00b00993629dea0csi252119ejj.134.2023.07.17.15.34.26; Mon, 17 Jul 2023 15:34:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=S2DUQ4oH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbjGQWSI (ORCPT + 99 others); Mon, 17 Jul 2023 18:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbjGQWSH (ORCPT ); Mon, 17 Jul 2023 18:18:07 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92897B2 for ; Mon, 17 Jul 2023 15:18:06 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-768197bad1cso232409085a.1 for ; Mon, 17 Jul 2023 15:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689632285; x=1692224285; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=H0nRdgPIxPY9h+6ob+XM6W1276R2kR6LVZcGXL+V7xQ=; b=S2DUQ4oHtpsxG9NzvglBSXoaL0mMF9/6onvQd/rprjmlG4A110LPmzn4x57zH0j4cv wFWOxPjsT2lIU8hdbOFj3MGp5vBHpoX3t8W8HEYf1fa1CITtlCYQcwLKVT4Tqsna8QDZ 8340z+Kj7hkU3dhoASUDr/BUPdCoMdHYrAEczd9KlNCVDnpltv3fJ79lLNQjbWdVFV4g 2Tvg/nH3szhBjxkSgyRhS2p/GyCUatgbxGzdowZL9DcLBVeX7XtXZxByu3UBoLuFKSe2 ifwLSg9wA1quMluShQUZhz9yBq3IbJ+f1GrQvRpXlTbRmqohIoF8P78eABb2veT4GnRD KAdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689632285; x=1692224285; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H0nRdgPIxPY9h+6ob+XM6W1276R2kR6LVZcGXL+V7xQ=; b=FqNNcgqxOcyKTE6Ye801XNv2wCx2EIM0WQbHLOAWIVfPwobWvkWBTICl74JOQ96xox NkkKSxbkOxvme5FbMGuAJp3+8DfX8sR47WlzGeaguGcoRqvlOQRqdQHNzld9h8m5C4RD grXQbipv/DFl234/rTWo4x8mZHbxcn97pmh75qvX/aZ6n56bOE+SMNJNqHwz/GF2A7Xn gov3OgCxMeXaPbUDkyJCWtSeOnKowBQK9ajHnNv/CG+wtB4mahjnT1pFkW1fE4JiioZ2 LV8q/wHRuG4OYBw4Sw3mSgx/Z9uYc2EAHHNMGA6afM/YDQGBSCdvo3+JuH0OC8IEEbf8 YFFw== X-Gm-Message-State: ABy/qLb8yT0zppQWEi69nBcKs7BOQ16DdwGR1Hvdn3/0BWgd11oVa3Fo qQbzHgGz5K1oQYGPdSaRreFt5QALeK0LnFEAbOjHZQ== X-Received: by 2002:a05:620a:410:b0:766:fd2c:fca1 with SMTP id 16-20020a05620a041000b00766fd2cfca1mr16751394qkp.75.1689632285573; Mon, 17 Jul 2023 15:18:05 -0700 (PDT) MIME-Version: 1.0 References: <20230717220435.57640-1-yury.norov@gmail.com> In-Reply-To: <20230717220435.57640-1-yury.norov@gmail.com> From: Nick Desaulniers Date: Mon, 17 Jul 2023 15:17:54 -0700 Message-ID: Subject: Re: [PATCH v2] lib/bitmap: workaround const_eval test build failure To: Yury Norov Cc: linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Andy Shevchenko , Alexander Lobakin , Maxim Kuvyrkov , Rasmus Villemoes , Nathan Chancellor , Tom Rix , oe-kbuild-all@lists.linux.dev, kernel test robot Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 17, 2023 at 3:04=E2=80=AFPM Yury Norov w= rote: > > When building with Clang, and when KASAN and GCOV_PROFILE_ALL are both > enabled, the test fails to build [1]: > > >> lib/test_bitmap.c:920:2: error: call to '__compiletime_assert_239' dec= lared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(re= s) > BUILD_BUG_ON(!__builtin_constant_p(res)); > ^ > include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_O= N' > BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition= ) > ^ > include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_= ON_MSG' > #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > ^ > include/linux/compiler_types.h:352:2: note: expanded from macro 'compi= letime_assert' > _compiletime_assert(condition, msg, __compiletime_assert_, __C= OUNTER__) > ^ > include/linux/compiler_types.h:340:2: note: expanded from macro '_comp= iletime_assert' > __compiletime_assert(condition, msg, prefix, suffix) > ^ > include/linux/compiler_types.h:333:4: note: expanded from macro '__com= piletime_assert' > prefix ## suffix(); = \ > ^ > :185:1: note: expanded from here > __compiletime_assert_239 > > Originally it was attributed to s390, which now looks seemingly wrong. Th= e > issue is not related to bitmap code itself, but it breaks build for a giv= en > configuration. > > Disabling the const_eval test under that config may potentially hide othe= r > bugs. Instead, workaround it by disabling GCOV for the test_bitmap unless > the compiler will get fixed. > > [1] https://github.com/ClangBuiltLinux/linux/issues/1874 > > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-kbuild-all/202307171254.yFcH97ej-lkp@i= ntel.com/ > Fixes: dc34d5036692 ("lib: test_bitmap: add compile-time optimization/eva= luations assertions") > Co-developed-by: Nathan Chancellor > Signed-off-by: Nathan Chancellor > Signed-off-by: Yury Norov Thanks for the patch. I hope to see if this is fixable in the compiler soon, so that we can replace this with a compiler version check should this be fixable (and then fixed) in the compiler. For now, we will track this in the above github link. Reviewed-by: Nick Desaulniers > --- > lib/Makefile | 6 ++++++ > lib/test_bitmap.c | 8 ++++---- > 2 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/lib/Makefile b/lib/Makefile > index 42d307ade225..1ffae65bb7ee 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -82,7 +82,13 @@ obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_key_ba= se.o > obj-$(CONFIG_TEST_DYNAMIC_DEBUG) +=3D test_dynamic_debug.o > obj-$(CONFIG_TEST_PRINTF) +=3D test_printf.o > obj-$(CONFIG_TEST_SCANF) +=3D test_scanf.o > + > obj-$(CONFIG_TEST_BITMAP) +=3D test_bitmap.o > +ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_KASAN),yy) > +# FIXME: Clang breaks test_bitmap_const_eval when KASAN and GCOV are ena= bled > +GCOV_PROFILE_test_bitmap.o :=3D n > +endif > + > obj-$(CONFIG_TEST_UUID) +=3D test_uuid.o > obj-$(CONFIG_TEST_XARRAY) +=3D test_xarray.o > obj-$(CONFIG_TEST_MAPLE_TREE) +=3D test_maple_tree.o > diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c > index 187f5b2db4cf..4a678de9c350 100644 > --- a/lib/test_bitmap.c > +++ b/lib/test_bitmap.c > @@ -1161,6 +1161,10 @@ static void __init test_bitmap_print_buf(void) > } > } > > +/* > + * FIXME: Clang breaks compile-time evaluations when KASAN and GCOV are = enabled. > + * To workaround it, GCOV is force-disabled in Makefile for this configu= ration. > + */ > static void __init test_bitmap_const_eval(void) > { > DECLARE_BITMAP(bitmap, BITS_PER_LONG); > @@ -1186,11 +1190,7 @@ static void __init test_bitmap_const_eval(void) > * the compiler is fixed. > */ > bitmap_clear(bitmap, 0, BITS_PER_LONG); > -#if defined(__s390__) && defined(__clang__) > - if (!const_test_bit(7, bitmap)) > -#else > if (!test_bit(7, bitmap)) > -#endif > bitmap_set(bitmap, 5, 2); > > /* Equals to `unsigned long bitopvar =3D BIT(20)` */ > -- > 2.39.2 > > --=20 Thanks, ~Nick Desaulniers