Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp746599qtx; Thu, 17 Nov 2022 07:24:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5CHFveHZIAPtURJrrOpmy0TkxuRGjJkH6155LHsU2mD1fGoqZfLBN+mxAhdAEKFnDpDKyC X-Received: by 2002:a17:903:48d:b0:17c:620f:13ac with SMTP id jj13-20020a170903048d00b0017c620f13acmr3338653plb.9.1668698680207; Thu, 17 Nov 2022 07:24:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668698680; cv=none; d=google.com; s=arc-20160816; b=b5Y1Ply+mrhDElV7bHsq0CWlxP6VGep4n0UR4GomfAy3QNMJlosCRnp7uwPeddKZ9y kwW8baci1aAqmeOmOEhWE/ot99L+lD04N0zKAu6u1BcZRkILpKnzWqcL4Mxlo13ogFzT efdpGLZC4iHaYHlyzu6TwYUr48Aj8j2nR0P2TQfIJQWM/tbQXuLW+2jCHsuh7ylR+aWX QhcOLNyLK4kAldYR42hMd5egXdWy7oIA4miz6m9z3lnnJIqdBylfalAM3AXQhRB25T9d TttoTpzml7QSEQjr6Lu/+HMaXt70GQDPYlhR3Qzwbg5gkwlnFUEDAgy2dNfcIZ+gbp1g 220Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sTQGbnXtwhR1dqd+9+FCOoOG3J/X3IYqBIw6cpGO6vA=; b=oOPinrcD2zhk/mzH+XspOslPjSKmbsknOr5XPogIsWkpwMpEQ5qZVMotbq74YDTP5D rSaxPEpWM8i5b5tbKc8wg4bW6gTcKAmpAl0cEqYCMcibAHmkPWWiPp0dfFvHnGwp1i3B ogDunJHSuw8tGvCc9QX1euaBKt13DosvlZysdBsq3sB9qh5oVhYpkBlT+gvVL0iWQx0N UrMCgz/REEXeXhqbn9JZCDTqImFLKe1ThdHipWBbpOUuduCcK3rv7NkjV28s0oUBDhD3 7f+tAP+xUP33U9E5SLX3PBixjIk7c1btsiL39asxDOahxdTIS/86lUXzqnbk2Psp3VOc 3LFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iAZZYVLs; 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 v185-20020a6389c2000000b0043c2b08e6efsi1150313pgd.694.2022.11.17.07.24.25; Thu, 17 Nov 2022 07:24:40 -0800 (PST) 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=iAZZYVLs; 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 S240681AbiKQPVG (ORCPT + 92 others); Thu, 17 Nov 2022 10:21:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240429AbiKQPUL (ORCPT ); Thu, 17 Nov 2022 10:20:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8570D182 for ; Thu, 17 Nov 2022 07:15:47 -0800 (PST) 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 20EFD62011 for ; Thu, 17 Nov 2022 15:15:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B5C7C4314E for ; Thu, 17 Nov 2022 15:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668698146; bh=RwPjK46hBhG/z8KciffmJpXKpjhudjj/pqsOhf2NjpQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iAZZYVLsfizMLK1l17ZafaWzd2HLx8Fqt2UJiYqVORIj1kO6q1KX9JDRj5DQLCH0F hl2iVIhDVqwfkaHQrEKRWnwhYvCjU2gWWq+MPUmUxsWbARYjbTPQ8iqp78lc/JmEIL 6AqAxxWUdpjpJW+4eIxBseZrzg8GfjV5LSjxCNbJTj4H1bmte5weihTpDRB16ztJWk b5V1wf8CLMnOe0OvdethLoxxSaDiYtKNecB0KuM8ejmhzlnsl/hF3fRdMNiSiP+mTT iAh9ODEgYDj83sGVH9xhyiB8AuIEYRNL/uae+iAoKsHTAUjIVb/td8S9QIAek+iaRN VMu2X9DazKgwg== Received: by mail-lf1-f51.google.com with SMTP id a29so3260867lfj.9 for ; Thu, 17 Nov 2022 07:15:46 -0800 (PST) X-Gm-Message-State: ANoB5pmSQ27g4XTOCShuMO7A3xjeQQLzpW39VxaNn8VUB3xgbEvfDqSQ t9s/pqBuaoQQEthn5RvFdLtNb3YA/B1MJhLiinc= X-Received: by 2002:ac2:5ec9:0:b0:4a2:2aad:95c4 with SMTP id d9-20020ac25ec9000000b004a22aad95c4mr1209490lfq.110.1668698144338; Thu, 17 Nov 2022 07:15:44 -0800 (PST) MIME-Version: 1.0 References: <20221114114344.18650-1-jirislaby@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Thu, 17 Nov 2022 16:15:33 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 00/46] gcc-LTO support for the kernel To: Richard Biener Cc: Peter Zijlstra , "Jiri Slaby (SUSE)" , linux-kernel@vger.kernel.org, Alexander Potapenko , Alexander Shishkin , Alexei Starovoitov , Alexey Makhalov , Andrew Morton , Andrey Konovalov , Andrey Ryabinin , Andrii Nakryiko , Andy Lutomirski , Arnaldo Carvalho de Melo , Ben Segall , Borislav Petkov , Daniel Borkmann , Daniel Bristot de Oliveira , Dave Hansen , Dietmar Eggemann , Dmitry Vyukov , Don Zickus , Hao Luo , "H . J . Lu" , "H. Peter Anvin" , Huang Rui , Ingo Molnar , Jan Hubicka , Jason Baron , Jiri Kosina , Jiri Olsa , Joe Lawrence , John Fastabend , Josh Poimboeuf , Juergen Gross , Juri Lelli , KP Singh , Mark Rutland , Martin KaFai Lau , Martin Liska , Masahiro Yamada , Mel Gorman , Miguel Ojeda , Michal Marek , Miroslav Benes , Namhyung Kim , Nick Desaulniers , Oleksandr Tyshchenko , Petr Mladek , "Rafael J. Wysocki" , Sedat Dilek , Song Liu , Stanislav Fomichev , Stefano Stabellini , Steven Rostedt , Thomas Gleixner , Valentin Schneider , Vincent Guittot , Vincenzo Frascino , Viresh Kumar , VMware PV-Drivers Reviewers , Yonghong Song Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 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 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 On Thu, 17 Nov 2022 at 14:55, Richard Biener wrote: > > On Thu, 17 Nov 2022, Ard Biesheuvel wrote: > ... > > We have an __ADDRESSABLE() macro and asmlinkage modifier to annotate > > symbols that may appear to the compiler as though they are never > > referenced. > > > > Would it be possible to repurpose those so that the LTO code knows > > which symbols it must not remove? > > I find > > /* > * Force the compiler to emit 'sym' as a symbol, so that we can reference > * it from inline assembler. Necessary in case 'sym' could be inlined > * otherwise, or eliminated entirely due to lack of references that are > * visible to the compiler. > */ > #define ___ADDRESSABLE(sym, __attrs) \ > static void * __used __attrs \ > __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)&sym; > #define __ADDRESSABLE(sym) \ > ___ADDRESSABLE(sym, __section(".discard.addressable")) > > that should be enough to force LTO keeping 'sym' - unless there's > a linker script that discards .discard.addressable which I fear LTO > will notice, losing the effect. A more direct way would be to attach > __used to 'sym' directly. __ADDRESSABLE doesn't seem to be used > directly but instead I see cases like > > #define __define_initcall_stub(__stub, fn) \ > int __init __stub(void); \ > int __init __stub(void) \ > { \ > return fn(); \ > } \ > __ADDRESSABLE(__stub) > > where one could have added __used to the __stub prototypes instead? > Probably, yes. But my point was not really about the implementation of those things, more about whether we could redefine them to something else that would help the compiler infer that this symbol needs to be retained. asmlinkage in particular seems relevant, which is currently only used for C++ inclusion or for setting regparm{0} on i386.