Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2163186iof; Tue, 7 Jun 2022 21:51:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyf3jJBUHcgyAoXZkpxr9mrroH6FzlS92nRL+Sii7bAmdMsJ5YNU2q95ktO0dp1a4JEVO4 X-Received: by 2002:a17:90b:4b0a:b0:1e8:6ff0:7ec1 with SMTP id lx10-20020a17090b4b0a00b001e86ff07ec1mr18295566pjb.212.1654663900783; Tue, 07 Jun 2022 21:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663900; cv=none; d=google.com; s=arc-20160816; b=ZMMns4OSR5DEfkFu8B2flWAXlQGKwceJ+Uqehd4d+kjOQ9k4a1gdyqq0crYV6Bmq0L VL1JOm66oHejxldfJFs3yXt5G2N87UK5iuNq/rrO6dkUk5+D4sS27fKQK1RZDyAYiPlc JzqQNJUsgDlyxHt7Q0x49X7dc5/7arg+yyuRSXRRQzc/sTm4YRJnXL9Zl/sKD79Cxg19 E9bbstRQLfth2KCtwMq/R4/TlkObqs+XUp7z1X+mUXCkJ5vNjNR/+nZP0FUP/3cEH2Kl tFzWn/HkMQ5hiiEEkyrAhRF7T2eKDIH1IscOBQo+qNEavgpJd+3NM5KU4z4srY6+KM1p mzgA== 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=yP1QeLL3yA3K4SWeh23q1REqlzVaz6ZUgDpytL1ssxY=; b=mmuyRmxWta865mTNah6f77au/b/ReMpkZ3uqSN4WpAk4VyUEaKnRCfsK2f2OWXSdMg IxsbVIHzw8DDk9wKAZzD+d2yB8npIUvHwrj27IWoLRQw45qU+1iUmGebsbtUIh7ErtRS GjlQtSC1OK1sqq6PP3Sn0P/1BGoiI3j4wHAU1VZp6LGva0U3CfObfhi3dsp01N9AnAqH yDyqDf/3TnOJFHvEcmrWyFjgptTNzUHqET98O6FqbK5zAj0z0tVGFoaD8lCFlBxVQCav 9hp8jO8D+FKszxv4SOw4ExRM/uDB//uNA2/cZJb8OCg/DVrVqp+s1CzLgRRp/qP8qpj9 Dy5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h2aADI7o; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ge7-20020a17090b0e0700b001d2865c095fsi24232143pjb.61.2022.06.07.21.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:51:40 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h2aADI7o; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C0F27354473; Tue, 7 Jun 2022 21:21:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359709AbiFGUot (ORCPT + 99 others); Tue, 7 Jun 2022 16:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357961AbiFGTmg (ORCPT ); Tue, 7 Jun 2022 15:42:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB23D20BDF; Tue, 7 Jun 2022 11:17:31 -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 ams.source.kernel.org (Postfix) with ESMTPS id 77A78B82367; Tue, 7 Jun 2022 18:17:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBB70C385A2; Tue, 7 Jun 2022 18:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625849; bh=g7XB8B2hXhx0t6vm3lGhWMstRlw7oJH8/lHkhtWU6kk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h2aADI7odwPpUUMc0OdBSJLp7atW//f7NOr43hVYCCmUBpgQexNqpWg2kkMIxLQSH QFJvNpmtMtK0MCBug7rBpBOkyZ1g10gSrJmekXwZk5/ROn6/HkVgA1D/pHtph7ZVA3 tDQfjbDnVTQje9EpC7E3v/L2tdTiF8u9Sbso0E8c= 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.17 126/772] s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES Date: Tue, 7 Jun 2022 18:55:18 +0200 Message-Id: <20220607164952.757766395@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 d9d5350cc3ec..bf15da0fedbc 100644 --- a/arch/s390/include/asm/preempt.h +++ b/arch/s390/include/asm/preempt.h @@ -46,10 +46,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