Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753016AbdLMAhS (ORCPT ); Tue, 12 Dec 2017 19:37:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:34910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752962AbdLMAhO (ORCPT ); Tue, 12 Dec 2017 19:37:14 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8604620C0F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Tue, 12 Dec 2017 19:37:11 -0500 From: Steven Rostedt To: Jim Wilson Cc: Alan Kao , Palmer Dabbelt , Albert Ou , mingo@redhat.com, patches@groups.riscv.org, linux-kernel@vger.kernel.org, greentime@andestech.com, alankao@andestech.com, pombredanne@nexb.com, kito@andestech.com Subject: Re: [PATCH v2] riscv/ftrace: Add basic support Message-ID: <20171212193711.6e3167ac@gandalf.local.home> In-Reply-To: References: <20171207023110.2622-1-alankao@andestech.com> <20171212070758.GA26787@1a3c108b4593> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1044 Lines: 23 On Tue, 12 Dec 2017 09:47:03 -0800 Jim Wilson wrote: > As Alan mentioned, all gcc does is call mcount with two args, parent > pc and self pc, same as most other linux targets. Most of the > interesting features of prof/gprof profiling happen inside glibc, with > the special start files provided by glibc, and some special functions > like profil(3). I think this is more of a glibc API issue than a gcc > ABI issue. If the glibc API changes, then the kernel support will > have to change too. I checked half a dozen different processor ABIs, > and I didn't find that one documents how mcount works. mcount appears to be totally undocumented in all archs. My way of figuring out what it did was simply reading the glibc code and how it handled it. Note, gcc on some archs supports the -mfentry option added with -pg, which will will not use "mcount" but instead "__fentry__" which comes before the prologue. This allows for ftrace to hijack the function, and this is how live kernel patching is implemented. -- Steve