Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp590934iog; Mon, 13 Jun 2022 08:44:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tAOwDCLUBg41LsuModjtOuvvqxUx8VJUn4vUDZYUi+VJ0SxHUOwvvTImH292WA+8Kt99HR X-Received: by 2002:a05:6402:3046:b0:42e:fee1:c2dd with SMTP id bs6-20020a056402304600b0042efee1c2ddmr378035edb.29.1655135040244; Mon, 13 Jun 2022 08:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655135040; cv=none; d=google.com; s=arc-20160816; b=HdJFOaeQlxxYxS/wvMEqbYXfFYDUJPjFoyFC/UbVBSAcXTW92+5QqiAUOzSwrF+ZQq W0MDOSMqVbRDgWlnzred6JAh+PsHb+Cy3Ruo/P/KuScmdm4Z13bHqkST/3hWgCI3yxSs Ct6nuMy4OvNCfU70tuDqzFNbHXdFqyn2KzPIRKWAzk4hes+4yTchJlmqEm0S5ILIi3D7 Pm4Vx1Q10I023VXv2pzqTfOVdP3D+I4T2vS8d3eR4vWDV1TVqKRQ3Z0+Dw5D2wX/zOqM sMwriXF5ktsdbBELzxKoCWkR5YPVS5uifZJlpayzDxsF59j2xCu05GXv5yfYxi1IApTq 73Ag== 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=188nxGF1rreulp4j4oowIUBv99n/LRNrU6f1B3ERvfw=; b=YOnzvQlVDADri8q7YgrE/MVDGibntamBZKN4YFx+J8IHsyQkpMqaCzFnhsfcKYBzgw YPkUrqtkKT5kZdhJpDMIgqgIstIYPS3OC68Sr0APHjyMJZ0RkCEDiJ5MA/DTKqPnnSob kXMK3IvAVyeVaRs8UmajmkY3lGyg56Q5n12e1tb2KOWHOy1h21EHQ3VYVeKs03mw4o5W ZOy5rWeS/X4iL66B+LJ4SdWD0sNOaV/Te9fw/4KHF/aIFHQAhI+nFEEB+LTjsReJm92G MhWQJhdM4+050ffwVrLQuqMF5iStKOG6CEBoW0r2A5Zg4bdEFuiAjWmwEtGmbvToFWKE 0/CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fN59j++U; 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 mp11-20020a1709071b0b00b0070d00528830si8925277ejc.221.2022.06.13.08.43.34; Mon, 13 Jun 2022 08:44:00 -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=fN59j++U; 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 S1349613AbiFMLAg (ORCPT + 99 others); Mon, 13 Jun 2022 07:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350191AbiFMKyo (ORCPT ); Mon, 13 Jun 2022 06:54:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D63A4E003; Mon, 13 Jun 2022 03:30:07 -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 7173260EF5; Mon, 13 Jun 2022 10:30:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81787C34114; Mon, 13 Jun 2022 10:30:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116206; bh=1oaoX4ok9yeMVtkHfkvusLYM5Kis7pHtPy11PUfzcqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fN59j++UfNpzld4VmBfi95e4j91co+6hXcw50+PsJdGNtTeQlbiqXmLkllM03oGa6 2rOoYpmIeyU7+f9k0MLXQCw/V26Yyky/EhCBTzMCq53HwM2qYQSW+yDej+RyFfgbiw Vz4upnDHIzXZpFNJ2lI2aDBbm1X0agYKHWr+iLzs= 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 5.4 043/411] s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES Date: Mon, 13 Jun 2022 12:05:16 +0200 Message-Id: <20220613094929.802349685@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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 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