Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp626439iog; Mon, 13 Jun 2022 09:24:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uR3RG+DTU04eD8OGKif8iCNIX71X4tC9XdTeapb1aqnhQN25ObcL+p8r0eNXx2psBhNBbE X-Received: by 2002:a17:902:7607:b0:168:bdec:7d2f with SMTP id k7-20020a170902760700b00168bdec7d2fmr583411pll.60.1655137454861; Mon, 13 Jun 2022 09:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137454; cv=none; d=google.com; s=arc-20160816; b=vP+Gf12Mc3/2VLQ2zlBVc+r3wNFmfUg9HNSDGAAOgdcoyJvaRxBXqRLupJcDyjVwwf SyuU9p6wrTRfRr+IP8lMECCmdPH1wALpLPRHxa08D6yTALXZiiPmJr9XZZhEjmmiUD3p buXwjb0mG/p73Rd/aLsjX38QoZiyVo/vH2MADl/irXbUeuqSMlfF3dxrupC6fNnioG0D 1ys6JHmyAAf5n1FIh7JvwPqj+0vACBwv6Nc0McQA4svMhXayauLLnwbz6748sbzbQKsP FnKXjNN9pWw+XiX2nlwyGGlfVYFzrMtudOqc1eHUm9eKLFj2ftTMjbS3BoYf9/vn12sC rOCw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U5rgEzZliUf0u0YMQpEulshYqe3AIcN3DBaE5JAj8qg=; b=TronX6GSHccHEg8w9PG3j0Tt8mNOEIhqB8mtFtpsmhYG/us34x2rl80hRNARiD3cEQ v6ao2zSZZzmVTJZadsREuT+XNslvi5B/hyaBZjutkx+mIB7tmLssJ+ElPw/EhgS91xC4 5EG1suC0wp4byv/1ovxdhpTE+Jv8PkBoeAgYN53t/3w2OAOcD2ZajCOGcWXNnrYjMjnW IJQaFrj9mbPj+1x0V1WPull+aQ3lkI0WSLCmdRjJcCu59cLbgEo5qnLl36ZZ9S2A4Lj1 5Guk5n4jWC5pBAYSivzEXZJFi73PLezzenq+AJX2tBsZbGkRqmCf17NFKvC6fwobcodP 5/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WOEKFkHI; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w13-20020a170902d70d00b001674d61c1c7si9400007ply.400.2022.06.13.09.24.00; Mon, 13 Jun 2022 09:24:14 -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=@linuxfoundation.org header.s=korg header.b=WOEKFkHI; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345542AbiFMKgH (ORCPT + 99 others); Mon, 13 Jun 2022 06:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346137AbiFMKeV (ORCPT ); Mon, 13 Jun 2022 06:34:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17C3C302; Mon, 13 Jun 2022 03:22:21 -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 C65E860B8E; Mon, 13 Jun 2022 10:22:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF415C34114; Mon, 13 Jun 2022 10:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115740; bh=o5pO4LCMS5/b+2fU+WThBdm9r/1xafoD8Nszr9ODGqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WOEKFkHIG2GRBGSBjhZZnBYFzut5oMeLNjWv4D3k7ZzH1hRc7oCAeMN8vC7sxA5cC iPaNn2FHLzjHq4DygZuyHI8AKdtfx36H2WdWAO4/KHnisQksmsw8zF2tEid/6nOV3A KpaW6LY7O22FG94ToT7ZHxx3zub83R1n+7NO7qwc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Sven Schnelle , Heiko Carstens , Sasha Levin Subject: [PATCH 4.14 024/218] s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES Date: Mon, 13 Jun 2022 12:08:02 +0200 Message-Id: <20220613094914.026938824@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 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 23a14d187fb1..1aebf09fbcd8 100644 --- a/arch/s390/include/asm/preempt.h +++ b/arch/s390/include/asm/preempt.h @@ -50,10 +50,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