Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4713792ioo; Tue, 31 May 2022 09:57:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvvW4j41jxIQqEBf9N0oD6sIW4whPwXrHdc1J1wUuXpTv2EAVPTolFmAowiPQ/C0PWxncu X-Received: by 2002:a17:902:ccc9:b0:15b:c265:b7a0 with SMTP id z9-20020a170902ccc900b0015bc265b7a0mr61397918ple.107.1654016271986; Tue, 31 May 2022 09:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654016271; cv=none; d=google.com; s=arc-20160816; b=TkeE9/zKW4p7thn/u5M24/hPHmudwH3ljBB98YZ98jxjYmpgIpOmsjwcGp+R0TVHdw XqmNrbm5/j/M55nbtda3SxctDybqwIPFW+WbiQp/tQriPvqIZ0cusou6pmEaWfxCZZaR NgBkW0+Biz3XDdNPLuCiQ6nq1XWULFXItWwPR2lH+CETCXGqcKELxvsoOa8pLa3M59O7 t7hw7qcPu2mtTVEAxhGLlK318zc8BH0bPZnf3/OiBQmE8TpZk/fK/vAZ/bU8v+TDMqwn /RWLiecx2HO1xgYOL5ABFgtFTirHN99DrrgCaak4RJ2aTaP8I0SQCJVMikm3yAnu4X6P YCVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=188nxGF1rreulp4j4oowIUBv99n/LRNrU6f1B3ERvfw=; b=l84cCQj3YP1Cxk1vmZspK3AtxMc7tRwMVB9A+Kq6+4ObvSZxMyUx8XBJzDQhtREQVG lT/u7jpOkau0LjHofoGZMb+EpirDopus12NphWAOfDf8I8Y3h0L42ZngZYM5Sk50qi7b o83Lfz4HIXnXqHpBMCzWKdqZPUV3Jf/IqVBFLLv7lvbLaLz66gxIPvC4rwg4uAVL2OZM 3yJ12FBmOyZ0gQy1CYi83S0chdqsTbmKZVucWe729fRzMWq73L31F31faOCj/gXM/xtt 9o9MGHeZOHGSMuHTMzRFQaYss9a2gCP91EL+JKvrht+RQivqNKJtmI+JJSFqo7AVB8p7 019w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UZr5hZZk; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a631145000000b003f25729acd4si21073632pgr.555.2022.05.31.09.57.38; Tue, 31 May 2022 09:57: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=@kernel.org header.s=k20201202 header.b=UZr5hZZk; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242506AbiE3OhX (ORCPT + 99 others); Mon, 30 May 2022 10:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242326AbiE3OSr (ORCPT ); Mon, 30 May 2022 10:18:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21FD61207DA; Mon, 30 May 2022 06:49:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3122160F14; Mon, 30 May 2022 13:48:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DE54C36AE7; Mon, 30 May 2022 13:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918515; bh=1oaoX4ok9yeMVtkHfkvusLYM5Kis7pHtPy11PUfzcqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UZr5hZZkwh1MBLbeC5nBcAe+Vdj/LdnYJi3bVQNkzZEeLgvLa1Ko2jWT11JSSZq9V 9LIUJx+d46Fwr7rSejc+cdBw/t6ib5kX8sB0xqoVY+0/4/8O2t14GcbovPpU4Qky/I GNFqR3p+uCdOl/Vu/NLc3IcnL3iAgbfAqV9+b76cfQI5jgpk2PhVjdth4d0Jw5Nyn9 bYW158sW0pAuHHFbNzX8lNBdcWyLfbBEJT22//9Z0b+cEYs8hnMAGJW/U+Gg37+TbC At/D05VAjXXBo0X9bLpLIw5nR7ON0Xyuktsm3L1naIw+5aHos1CXDXUOnSIEzVEhcA +DOTO2DMXd5CQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Heiko Carstens , Thomas Richter , Sven Schnelle , Sasha Levin , gor@linux.ibm.com, agordeev@linux.ibm.com, vschneid@redhat.com, linux-s390@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 35/55] s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES Date: Mon, 30 May 2022 09:46:41 -0400 Message-Id: <20220530134701.1935933-35-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530134701.1935933-1-sashal@kernel.org> References: <20220530134701.1935933-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Heiko Carstens [ Upstream commit 63678eecec57fc51b778be3da35a397931287170 ] gcc 12 does not (always) optimize away code that should only be generated if parameters are constant and within in a certain range. This depends on various obscure kernel config options, however in particular PROFILE_ALL_BRANCHES can trigger this compile error: In function ‘__atomic_add_const’, inlined from ‘__preempt_count_add.part.0’ at ./arch/s390/include/asm/preempt.h:50:3: ./arch/s390/include/asm/atomic_ops.h:80:9: error: impossible constraint in ‘asm’ 80 | asm volatile( \ | ^~~ Workaround this by simply disabling the optimization for PROFILE_ALL_BRANCHES, since the kernel will be so slow, that this optimization won't matter at all. Reported-by: Thomas Richter Reviewed-by: Sven Schnelle Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- arch/s390/include/asm/preempt.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/preempt.h b/arch/s390/include/asm/preempt.h index b5ea9e14c017..3dcd8ab3db73 100644 --- a/arch/s390/include/asm/preempt.h +++ b/arch/s390/include/asm/preempt.h @@ -52,10 +52,17 @@ static inline bool test_preempt_need_resched(void) static inline void __preempt_count_add(int val) { - if (__builtin_constant_p(val) && (val >= -128) && (val <= 127)) - __atomic_add_const(val, &S390_lowcore.preempt_count); - else - __atomic_add(val, &S390_lowcore.preempt_count); + /* + * With some obscure config options and CONFIG_PROFILE_ALL_BRANCHES + * enabled, gcc 12 fails to handle __builtin_constant_p(). + */ + if (!IS_ENABLED(CONFIG_PROFILE_ALL_BRANCHES)) { + if (__builtin_constant_p(val) && (val >= -128) && (val <= 127)) { + __atomic_add_const(val, &S390_lowcore.preempt_count); + return; + } + } + __atomic_add(val, &S390_lowcore.preempt_count); } static inline void __preempt_count_sub(int val) -- 2.35.1