From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935729AbeCACIO (ORCPT ); Wed, 28 Feb 2018 21:08:14 -0500 Received: from exmail.andestech.com ([59.124.169.137]:65513 "EHLO ATCSQR.andestech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932134AbeCACIN (ORCPT ); Wed, 28 Feb 2018 21:08:13 -0500 Date: Thu, 1 Mar 2018 10:05:08 +0800 From: Alan Kao To: Steven Rostedt CC: Palmer Dabbelt , Albert Ou , "sw-dev@groups.riscv.org" , "linux-kernel@vger.kernel.org" , "Greentime Ying-Han =?utf-8?B?SHUo6IOh6Iux5ryiKQ==?=" , "Zong Zong-Xian =?utf-8?B?TGko5p2O5a6X5oayKQ==?=" Subject: Re: ftrace: Proposal for an Alternative RecordMcount framework Message-ID: <20180301020507.GA24550@andestech.com> References: <20180227100425.GB20904@andestech.com> <20180227161252.25162d81@vmware.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180227161252.25162d81@vmware.local.home> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [10.0.1.85] X-DNSRBL: X-MAIL: ATCSQR.andestech.com w2125Nao048859 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 28, 2018 at 05:12:52AM +0800, Steven Rostedt wrote: > On Tue, 27 Feb 2018 18:04:26 +0800 > Alan Kao wrote: > > > 1. During the final linking stages, do "objdump vmlinux.o | grep ..." [2] > > Note, doing it at that stage takes the longest time. It makes small > changes much longer to compile. That said... > What if we can have some option to *disable* all the recordmcount.pl lauches after every .o? There will be only an oneshot grep for a near-complete vmlinux binary. > > 2. Form the output as an ELF objecj > > 3. Link the object to __mcount_loc_start symbol > > 4. Done > > > > With the similar reason as the patch [3], we should mark _mcount to be > > a weak symbol to prevent it from being relaxed later. > > > > We would like to know your opinion and comments on this. > > Thanks! > > What about just having your arch use recordmcount.c instead? It doesn't > do any grepping. It is an elf reader and modifier and modifies the .o > file directly. Thanks for the hint. But after a quick scan, it seems that recordmcount.c processes .o files in a per-file basis, which means that we will still suffer from the linker relaxation problem. > > Note, I will be rewriting that code in the near future too, to > consolidate it with objtool. > > -- Steve Please allow me to state the problem more clearly here. I hope this helps. 1. locations of mcount are recorded in a per-file basis. 2. to optimize the binary, the linker turns on some aggressive options, including relaxation. 3. the optimizations changes the original offset. 4. already recorded mcount call-sites no longer point to their real positions. 5. still a linked vmlinux is made. 6. dynamic ftrace breaks the real logic in the kernel space, panics happen. Thanks, Alan