Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1471921ybb; Thu, 2 Apr 2020 01:11:16 -0700 (PDT) X-Google-Smtp-Source: APiQypIupRufdwFTtL2sIiyMbOBCkCU0Et2Tkw+4lnYoxIx9YigqfD3E5ftIq3S4vflJY9/el5lV X-Received: by 2002:aca:34c6:: with SMTP id b189mr1323178oia.63.1585815076701; Thu, 02 Apr 2020 01:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585815076; cv=none; d=google.com; s=arc-20160816; b=q2/6EIHqHlFmyuVXgftgD+KdBjDJrLK9O/V/L7bDfqPjZJGkcPs9H16HAvvQcRXtGS aPsOd2ycZpYa3fC4m8af+vieBlpOte3k3Oe8W8ruH8XEtSnJBWwCtRU42kA7Bt2PujsJ qYr+h/l2XAt0lKkRmTIPSwbB8hn+QF+UyEiRo88xIT4E/9Y5u0Xs9JGw7E15WeKegI6g 4kmnEt9AsvdTuOGP34MkEKXFZ2RnIJXnJpjeqQRzGEyGzaJhz/yu3PXYZQF74EJ7iK92 Xl46Dt4GnRwU2FLgocLzQoIss0Sq6CwyrUCEKHx1MEQ4oxR1xMQ7wS4KVRgFETVjU2Ev G1Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4bE/P5QRiIPVIk+HS8o/GuyaLeRlIHc/vpiFLIW3628=; b=NTRuIFXAgTEQfhPGcMlm+peFk9wpMqIgBUVQNFhn9mm6YvC3CTj92zldSikDoXfqju 8VA7EzLDHygWAKGaHZ4s0dtoRIezXLtj2FeBlzstA+A7f1YV94T6HmtSm6yAAWE7flAA dcaZxCdwfsiW8d6WgPjdoZeabAGOZ/V/6JxUCNcGRDf2h2HHlQONwV1+f3V+QCdpJ46J uDEb0UqB+bPJPPlddPduzk2fGS35XWDz8v4haV4L8zpbPW8q8BbHfEkQ6Df6QUjyb6+R nbBXnirZoY3YBvFs+UR9hdQoKlSDQulZcCEsswLFJKHXeNIXPdX1EudCu/mX5/RJYKn4 iTQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LIvf+o6D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t140si2040649oif.99.2020.04.02.01.11.03; Thu, 02 Apr 2020 01:11:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LIvf+o6D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387595AbgDBIKk (ORCPT + 99 others); Thu, 2 Apr 2020 04:10:40 -0400 Received: from mail-vk1-f193.google.com ([209.85.221.193]:34799 "EHLO mail-vk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387449AbgDBIKk (ORCPT ); Thu, 2 Apr 2020 04:10:40 -0400 Received: by mail-vk1-f193.google.com with SMTP id p123so647979vkg.1 for ; Thu, 02 Apr 2020 01:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4bE/P5QRiIPVIk+HS8o/GuyaLeRlIHc/vpiFLIW3628=; b=LIvf+o6De+0RaBbwtWEoEAptfdZMe0Tu3sJeB1IA9SjLJC/XJdpmGPjoNToMA4Q69P I24Zs/XfThwmpkr2gNrGNryD5rN5zajr/uGIjyCep7d0g+gHWwU6z4NZ4MO04JN3o1wX x1pZdiSk0R63juyw5tB7bWFE9qBhCHLOoRE7HAAZ6I55ak0Yg/YRBbRsADxYJWaM5+5W 391Lc3+RitaL46WTShZHt2EUfib1jpXpxbE3zB9yVBdoMGqWOHKTXxVcNZewuHwdlkIS 4HARo33DpKQS4IUbZrPzZe6hLZ+9SIDoAX9v67GkIlujCC5oZZ/OJsnDZX+gmlryGHtU iX8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4bE/P5QRiIPVIk+HS8o/GuyaLeRlIHc/vpiFLIW3628=; b=sGDp5fFIT/g6w5XNkr7vTaYhYB/mrpmDVYfAlEdGdaLPKQhP4JcCrjShUe9TxrrSdm DscJ5FgCLv9prTBfCikjheXl3E0JgjTNsX1LPbvL3mEy06/P1dBj2qvvQb+NtdluB3om NbH/+HQYsE/E6t/pj/L1WG8j1AWsM1+7+evRu48HsJJ5/wRHXK/CQq5ryRRec/kqhsK+ qRg5zquJP5MUCbZLB/l+x6fPGBWGxld7ZlGei2ZSh6YaiOjl0x0Q0Ij1M7BjQmEemZAV /hF0BjgelSfGGjKvdk5JD2U4zsXG4NGoHFzTrEB1LnU0jPjwx+UZ048q58YUsSgzN9EG 5lwQ== X-Gm-Message-State: AGi0Pubsyd/kGT013lPU3/6IBOLUmiAEHpwyKYeVKdNzo5Gi+esNzxqC 0eTOgqbafJ3Qv4/kjOm3k4F509juFlYOUJ1L4ew= X-Received: by 2002:a1f:a055:: with SMTP id j82mr1181103vke.75.1585815038690; Thu, 02 Apr 2020 01:10:38 -0700 (PDT) MIME-Version: 1.0 References: <20200327155355.18668-1-Eugeniy.Paltsev@synopsys.com> <20200327131020.79e68313@gandalf.local.home> In-Reply-To: From: Claudiu Zissulescu Ianculescu Date: Thu, 2 Apr 2020 11:10:27 +0300 Message-ID: Subject: Re: [RFC] ARC: initial ftrace support To: Vineet Gupta Cc: Steven Rostedt , Eugeniy Paltsev , "linux-snps-arc@lists.infradead.org" , Alexey Brodkin , "linux-kernel@vger.kernel.org" , Ingo Molnar Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, ARC-gcc has two modes to call the mcount routines. When using elf32 configuration, the toolchain is set to use newlib mcount. When configured for linux, gcc toolchain is using a library call to _mcall (single underscore) having blink as input argument. So, using the proper linux toolchain, your patch should work. //C On Thu, Apr 2, 2020 at 4:17 AM Vineet Gupta wrote: > > +CC Claudiu > > On 3/27/20 10:10 AM, Steven Rostedt wrote: > > On Fri, 27 Mar 2020 18:53:55 +0300 > > Eugeniy Paltsev wrote: > > Maybe add a comment that gcc does the heavy lifting: I have following in glibc > > +/* this is very simple as gcc does all the heavy lifting at _mcount call site > + * - sets up caller's blink in r0, so frompc is setup correctly > + * - preserve argument registers for original call */ > > >> +noinline void _mcount(unsigned long parent_ip) > >> +{ > >> + unsigned long ip = (unsigned long)__builtin_return_address(0); > >> + > >> + if (unlikely(ftrace_trace_function != ftrace_stub)) > >> + ftrace_trace_function(ip - MCOUNT_INSN_SIZE, parent_ip, > >> + NULL, NULL); > >> +} > >> +EXPORT_SYMBOL(_mcount); > > > > So, ARCv2 allows the _mcount code to be written in C? Nice! > > Yeah, the gcc backend for -pg was overhauled recently so it is a first class "lib > call" meaning we get all the register save/restore for free as well as caller PC > (blink) as explicit argument to _mcount > > void bar(int a, int b, int c) { > printf("%d\n", a, b, c); > } > > bar: > push_s blink > std.a r14,[sp,-8] > push_s r13 > mov_s r14,r1 > mov_s r13,r0 > mov_s r0,blink > bl.d @_mcount > mov_s r15,r2 > > mov_s r3,r15 <-- restore args for call > mov_s r2,r14 > mov_s r1,r13 > mov_s r0,@.LC0 > ld blink,[sp,12] > pop_s r13 > b.d @printf > ldd.ab r14,[sp,12] > > @Eugeniy, this patch looks ok to me, but a word of caution. This won't work with > elf32 toolchain which some of the build systems tend to use (Alexey ?) > > The above _mcount semantics is only implemented for the linux tool-chains. > elf32-gcc generates "legacy" __mcount (2 underscores, blink not provided as arg) > likely done by Claudiu to keep newlib stuff unchanged. Perhaps elf32 gcc can add a > toggle to get new _mcount. > > And this is conditional to ARCv2 due to future ties into dynamic ftrace and > instruction fudging etc ? We may have to revisit that for BE anyhow given such a > customer lining up. > > -Vineet