Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp228354iob; Mon, 2 May 2022 17:51:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL51NnnsG7IlgonQPojFpspPMIHpaoOowlUcxapD6TOdps80CCYu0fYtzFswexslJapxYz X-Received: by 2002:a17:90a:ab81:b0:1ca:8a76:cdda with SMTP id n1-20020a17090aab8100b001ca8a76cddamr2054435pjq.26.1651539087106; Mon, 02 May 2022 17:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651539087; cv=none; d=google.com; s=arc-20160816; b=tVxjpu3TFi8cAxPUTANuiRUOV0Q+M0onToRpXok87pgTwYPcjFNLmNH2mZeJOeNKtc JEHUCe5jAT2pr+2T6qFWlOptwJRsvtEduivzGK+NFNDtJoNBnUNAw/liPwGQAgIyITAi hLRh9cfic2ggRTbyt+c198OcfLzGW63B3zFtccc+yetLvw0F4ty+6MDhBFVOmhVP1G5A RIIyQXwkths21QQbo6CskzhpJ5l3lzUccXUCyWW3ss158GJF1+0ibuGOYfMTJkmUqZSS NLShy4uD5RIN5s+3pZaVMXquzTmS0cMNtDrFa96s6MIeowNuMl/yeb3GgSafKESdrDia VK8g== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=urkq2qatwAn+6Hd280+9iWGk6bBN3li5ccN+7xGgYk0=; b=owj+w7SWlQW2E7K0myaeYXe4JuVq1q2XBhS8IZ5omzcKzQ6mL50UHXX54WFMPe86Gx x19xyhMjX9/qiiqerofib/62/88k4N2QotoZ+hg3qNAE4DDZqnSiAUSYPalwtVHLDGSo BrcjceUTh1rKLaDN6jSHg12gSOsPGnkxEr8G0B7/pkUnAmCpijkC+sNyRqsjpbW8bEdL 2/yIPWz4MwBlcLu3CuVY4mDb/VbTq3rkW1qR+VX3bHFpxbnwY9Nst7CieljWEnybTeZx 8fn14IvEz4tSEWtpO55xbED5wIt6ec9p8qyXkwp2cPh64VGxp4EUxPu4hVnysNLmJIeZ cTCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t68-20020a632d47000000b0039d13c0c537si14690191pgt.714.2022.05.02.17.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 641154F45D; Mon, 2 May 2022 17:39:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379567AbiD2SCm (ORCPT + 99 others); Fri, 29 Apr 2022 14:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231160AbiD2SCk (ORCPT ); Fri, 29 Apr 2022 14:02:40 -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 7DDF08FFB7 for ; Fri, 29 Apr 2022 10:59:21 -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 3AA27B8376D for ; Fri, 29 Apr 2022 17:59:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29E19C385A4; Fri, 29 Apr 2022 17:59:18 +0000 (UTC) Date: Fri, 29 Apr 2022 13:59:16 -0400 From: Steven Rostedt To: "Naveen N. Rao" Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, llvm@lists.linux.dev, Michael Ellerman , Nathan Chancellor , Nick Desaulniers Subject: Re: [PATCH v2 2/2] ftrace: recordmcount: Handle sections with no non-weak symbols Message-ID: <20220429135916.47c3e623@gandalf.local.home> In-Reply-To: <1651252324.js9790ngjg.naveen@linux.ibm.com> References: <126aca34935cf1c7168e17970c706e36577094e7.1651166001.git.naveen.n.rao@linux.vnet.ibm.com> <20220428184212.18fbf438@gandalf.local.home> <1651252324.js9790ngjg.naveen@linux.ibm.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri, 29 Apr 2022 23:09:19 +0530 "Naveen N. Rao" wrote: > If I'm understanding your suggestion right: > - we now create a new section in each object file: __mcount_loc_weak, > and capture such relocations using weak symbols there. Yes, but it would be putting the same information it puts into __mcount_loc but also add it here too. That is, it will duplicate the data. > - we then ask the linker to put these separately between, say, > __start_mcount_loc_weak and __stop_mcount_loc_weak Yes, but it will also go in the location between __start_mcount_loc and __stop_mcount_loc. > - on ftrace init, we go through entries in this range, but discard those > that belong to functions that also have an entry between > __start_mcount_loc and __stop_mcount loc. But we should be able to know if it was overridden or not, by seeing if there's another function that was called. Or at least, we can validate them to make sure that they are correct. > > The primary issue I see here is that the mcount locations within the new > weak section will end up being offsets from a different function in > vmlinux, since the linker does not create a symbol for the weak > functions that were over-ridden. The point of this section is to know which functions in __mcount_loc may have been overridden, as they would be found in the __mcount_loc_weak section. And then we can do something "special" to them. > > As an example, in the issue described in this patch set, if powerpc > starts over-riding kexec_arch_apply_relocations(), then the current weak > implementation in kexec_file.o gets carried over to the final vmlinux, > but the instructions will instead appear under the previous function in > kexec_file.o: crash_prepare_elf64_headers(). This function may or may > not be traced to begin with, so we won't be able to figure out if this > is valid or not. If it was overridden, then there would be two entries for function that overrides the weak function in the __mcount_loc section, right? One for the new function, and one that was overridden. Of course this could be more complex if the new function had been marked notrace. I was thinking of doing this just so that we know what functions are weak and perhaps need extra processing. Another issue with weak functions and ftrace just came up here: https://lore.kernel.org/all/20220428095803.66c17c32@gandalf.local.home/ -- Steve