Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2276726rdb; Wed, 21 Feb 2024 02:38:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW4ghQWV5ksxMPbYkoGpk/GoUTESa8KWiqVjeXFQQLKt4bOaiI3dfTJ8DEPsKqq/HDYd0JVRv9bqxCDkDi2tBNFkkwToSP9xT/7VX/Big== X-Google-Smtp-Source: AGHT+IFcCN/Ubie7XzU+tuIO6mv/KVIvGP7S96H2g5sNnuoHI/r3kSauPAIk6Zs8A2dJLszy99vE X-Received: by 2002:a05:6a21:3a94:b0:1a0:694c:c467 with SMTP id zv20-20020a056a213a9400b001a0694cc467mr28678829pzb.14.1708511930132; Wed, 21 Feb 2024 02:38:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708511930; cv=pass; d=google.com; s=arc-20160816; b=fhO9kApT4bej6chYUfLmn8mUd3lpHhRsPDSnGAOKg+CeH4GQqfdRdwhhukdBCamW2A 0q+sqgreMOMntsz6LTaKI2eFnRlvtHqcHdgM1+r7oycwAqqts1RN2XJzFRqQP4baXeQ8 1vWoghNuRzBbwdWi1foc3rTbm9UJSSOi5nAkE05C7T9j1G3TjxVVPVOxmSsKgobzdCGX CZQqINACCbcUqs3QF0dhHTkDc+pEK3T/RMx2Y8cn3kGIshV6HRTKshdnBh0JAAFGBtrq dMwlZsolpec7ZdqfHNGB/ATZsIrryrZPkknBIsCtZcX3YUwgDyCTuua43rMJqdGZ9JQr 9QDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=cnKoPzhACftS9EnEu9/ynu2qMvlchm1lfMLjCdPuVQo=; fh=ArIt70/TjITxwxbH9QNjnmfN5U3PZ/Cj+hp7MSEVSEY=; b=y7m+ikXduQ+wtqMj1GNiG4HFfog7OBxPCQQQvcYwWVyCvOCxey8xekm3Vw4KZ8tdro LXMMOptGwxMIgiotNUDlDzCZsH6kSwO0ZbvwfN+YwjawJCGTlb9hHujSS+gSVEgwnlZs eqRDXyAT5VnWzeVHxQis43+jw5CwgfR6NZMS+s/bJzg2Ic5OgbBox/N+sl2prv9zHRkq zNtNhW/QPI9dFgm6irCmKZFHxP95PkcxQ5dRWUekZz1YN4IexS2BQvxJDtYxGb+kwusf t/jhUn/k3fJF+L3LmNeOBVzz8R2xFfhgnvFTyHJrKnXabBwJKMas9zwiMYuiDDt2lseo 72Pw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=TfsZaFTD; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-74545-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74545-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k126-20020a633d84000000b005d79125d04dsi7859174pga.726.2024.02.21.02.38.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 02:38:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74545-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=TfsZaFTD; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-74545-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74545-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D197E281CBF for ; Wed, 21 Feb 2024 10:38:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C862320DC5; Wed, 21 Feb 2024 10:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="TfsZaFTD" Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A722A1EB45 for ; Wed, 21 Feb 2024 10:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708511923; cv=none; b=esaGiWN9XdKA0YinR0Or+4j4JOdTAIid40Br9/sLyH+11DOAf5mYF+IwC4Xpnatoz+n9b114XGnnRp5VQrx/mT0u4aui7hIO/nUIah/M+mOQo8bzx7jaQbUa3vD0el47AdlXwz4qJFD2gOk8XuQ2MTp5w/ET2DdhAVhLpdtbSnw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708511923; c=relaxed/simple; bh=HBTD9NpgqM7kq4SO3bpEXJ5Bp3ofQRfsZKZeHA7Ambw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PGeuWDwc5ZGdFr8hzZXNXlWGSUELyKeofKKBeNh8o2uTGiCaMcN1v/iouqBFDt/p1Md+j1rHfHGRXjjXZ7mdqWDhaFVNKxMK11Exk3A2E1QWTAEqMlZ1otUcUvEC1nEmf6noudA6/Fwtoj3eYaBljJrtdyFVD3VX8zpK8aBKIhA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=TfsZaFTD; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-564fe0273e4so459999a12.2 for ; Wed, 21 Feb 2024 02:38:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708511920; x=1709116720; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=cnKoPzhACftS9EnEu9/ynu2qMvlchm1lfMLjCdPuVQo=; b=TfsZaFTDBogozp2cAgzkSMybRGAUN9RDlIjzgiP5UO0OpFN7X32ox+OgPxXumY1FbW POZQVDD+UIWzWEPZwHKfqKyUH0ROr9svS6vtom1werFfvZuToAwMaBb5uL8mLbNbkbgY 19tx8dGHEwogBxdNlz3g+HA9guvKCjaChhsk8FDKFzEeO59se+1vu1iFnYUcnMpkZRgd S1gFPd27fdasdLl+4BpiavF1Wb2U6m0yJE6pvc6/dmMwERdCecvUNOqePQtLZ0YB9B7y F+ItuctFxJjnf2lHONeRmEaFE6WVP0HJK6snwY2ywAXvTMNwAWC0Cqd7wnKcnT/W2r2S Gd/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708511920; x=1709116720; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cnKoPzhACftS9EnEu9/ynu2qMvlchm1lfMLjCdPuVQo=; b=vg8tLQU+w1481MqqcLhUiWaUra+iXq+39Q/hBnldv+5Qcmngh2p7TI8XM9/EyWu9hn rtYUnHqHq4ZFpSAEnyiwSM0fjLpcRLVUJmIfxQJVfs2bVxT/6taJ39IUNIugAyNGbkGS OAo5IfmCDIZA8MeMZRx2aaPjk2Mc/1RdE3pmfftNGTBw2hdkyfnrFlwdGAkl3dw4I5ux AZB4dJOil3Zqcb4aO4TPbQShGbTqmjNwEjbTFruhTTkWUPXUKB4S9/pSYs1n/1emPgsh E0tTa3z24MmIfL16sLc34C+L8bHtZ2sSPgz6xouQ38qK/Y+TVAW3ZfHmTZJgOMQBKJHr jppQ== X-Forwarded-Encrypted: i=1; AJvYcCXiePM/1rXKPv+B6NEAUikbUkF6UGMM3QXTt/2/b8XNt+3yHxHuHsiX9HkNHa/XwPBLj+c0UNMdT5nWcJlJgo9XPXrYOtUlOeer1L+I X-Gm-Message-State: AOJu0YwG7NAloRzov2akaQXWPEzlwgI8JS9s0kCdU4npSWpEJ5SSfglF snL/KN25eofmsc0N3mZiT3beTg07Zt4pXSJdSZs1glktTdlWJ6BitS/PEd+wmjM= X-Received: by 2002:a17:907:b9ca:b0:a3f:2247:bb59 with SMTP id xa10-20020a170907b9ca00b00a3f2247bb59mr1776452ejc.61.1708511919896; Wed, 21 Feb 2024 02:38:39 -0800 (PST) Received: from [10.100.51.161] (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id j10-20020a170906474a00b00a3e50e01612sm3853825ejs.62.2024.02.21.02.38.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Feb 2024 02:38:39 -0800 (PST) Message-ID: <9b067ec7-34e2-437b-a41b-319aaee4c7e6@suse.com> Date: Wed, 21 Feb 2024 11:38:38 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] kbuild: Use -fmin-function-alignment when available Content-Language: en-US To: Masahiro Yamada Cc: nathan@kernel.org, nicolas@fjasle.eu, mark.rutland@arm.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240215151642.8970-1-petr.pavlu@suse.com> From: Petr Pavlu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2/20/24 14:39, Masahiro Yamada wrote: > On Fri, Feb 16, 2024 at 12:16 AM Petr Pavlu wrote: >> >> GCC recently added option -fmin-function-alignment, which should appear >> in GCC 14. Unlike -falign-functions, this option causes all functions to >> be aligned at the specified value, including the cold ones. >> >> Detect availability of -fmin-function-alignment and use it instead of >> -falign-functions when present. Introduce CC_HAS_SANE_FUNCTION_ALIGNMENT >> and make the workarounds for the broken function alignment conditional >> on this setting. >> >> Signed-off-by: Petr Pavlu >> --- > > [snip] > >> index dfb963d2f862..5a6fed4ad3df 100644 >> --- a/kernel/exit.c >> +++ b/kernel/exit.c >> @@ -1920,7 +1920,10 @@ EXPORT_SYMBOL(thread_group_exited); >> * >> * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88345#c11 >> */ >> -__weak __function_aligned void abort(void) >> +#ifndef CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT >> +__function_aligned >> +#endif >> +__weak void abort(void) >> { >> BUG(); > > > > > > __function_aligned is conditionally defined in > include/linux/compiler_types.h, and then it is > conditionally used in kernel/exit.c > > This is unreadable. > > > > > You may want to move CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT > to include/linux/compiler_types.h, as this is more > aligned with what you did for __cold. > > > > if !defined(CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT) && \ > CONFIG_FUNCTION_ALIGNMENT > 0 > #define __function_aligned __aligned(CONFIG_FUNCTION_ALIGNMENT) > #else > #define __function_aligned > #endif > > > > > > However, an even more elegant approach is to unify > the two #ifdef blocks because __cold and __function_aligned > are related to each other. > > > > #if defined(CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT) || \ > (CONFIG_FUNCTION_ALIGNMENT == 0) > #define __cold __attribute__((__cold__)) > #define __function_aligned > #else > #define __cold > #define __function_aligned __aligned(CONFIG_FUNCTION_ALIGNMENT) > #endif I didn't want to make __function_aligned conditional on CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT because the macro has a fairly general name. One could decide to mark a variable as __function_aligned and with the above code, it would no longer produce an expected result when -fmin-function-alignment is available. __function_aligned was introduced c27cd083cfb9 ("Compiler attributes: GCC cold function alignment workarounds") only for aligning the abort() function and has not been so far used anywhere else. If the above unification is preferred, I think it would be good to additionally rename the macro in order to prevent the mentioned misuse, perhaps to __force_function_alignment. #if defined(CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT) || \ (CONFIG_FUNCTION_ALIGNMENT == 0) #define __cold __attribute__((__cold__)) #define __force_function_alignment #else #define __cold #define __force_function_alignment __aligned(CONFIG_FUNCTION_ALIGNMENT) #endif Would this be ok? -- Thanks, Petr