From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B379BC433EF for ; Thu, 23 Jun 2022 14:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231841AbiFWOUH (ORCPT ); Thu, 23 Jun 2022 10:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230470AbiFWOUE (ORCPT ); Thu, 23 Jun 2022 10:20:04 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A93CF43EFB for ; Thu, 23 Jun 2022 07:20:03 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9965912FC; Thu, 23 Jun 2022 07:20:03 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.26.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 012A13F66F; Thu, 23 Jun 2022 07:20:01 -0700 (PDT) Date: Thu, 23 Jun 2022 15:19:59 +0100 From: Mark Rutland To: Ard Biesheuvel Cc: Peter Zijlstra , Steven Rostedt , X86 ML , Linux Kernel Mailing List , Josh Poimboeuf , Christophe Leroy , "Naveen N . Rao" , Miroslav Benes , Nathan Chancellor , Nick Desaulniers Subject: Re: [RFC][PATCH] ftrace,objtool: PC32 based __mcount_loc Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 21, 2022 at 06:27:39PM +0200, Ard Biesheuvel wrote: > On Fri, 17 Jun 2022 at 13:40, Mark Rutland wrote: > > > > On Fri, Jun 17, 2022 at 01:24:53PM +0200, Peter Zijlstra wrote: > > > > > > Hi, > > > > > > I recently noticed that __mcount_loc is 64bit wide, containing absolute > > > addresses. Since __mcount_loc is a permanent section (not one we drop > > > after boot), this bloats the kernel memory usage for no real purpose. > > > > > > The below patch adds __mcount_loc_32 and objtool support to generate it. > > > This saves, on an x86_64-defconfig + FTRACE, 23975*4 ~= 94K of permanent > > > storage. > > > > We have a similar issue on arm64, which is exacerbated by needing ABS64 > > relocations (24 bytes per entry!) adding significant bloat when FTRACE is > > enabled. > > > > It'd be really nice if going forwards compilers could expose an option to > > generate PC32/PREL32 entries directly for this. > > As opposed to generating absolute references today? Or as opposed to > having to rely on our own tooling? Both; My prefrence would be the compiler had the option to generate these entries as relative at compile-time, without needing a binary post-processing step. That said, from my PoV this is one of the things that I think it's somewhat reasonable for objtool to do, as it's arguably akin to the build-time sort, and doesn't require deep knowledge of the control flow, etc. Thanks, Mark.