linux-openrisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sahil Siddiq <icegambit91@gmail.com>
To: Stafford Horne <shorne@gmail.com>
Cc: Linux OpenRISC <linux-openrisc@vger.kernel.org>,
	Miao Chen <chenmiao.ku@gmail.com>
Subject: Re: Queries regarding ftrace's implementation for OpenRISC-linux
Date: Sat, 10 May 2025 13:48:33 +0530	[thread overview]
Message-ID: <51b89c55-ee58-461d-a2a0-5c8dd8ba77e7@gmail.com> (raw)
In-Reply-To: <aB5Qe9EpVSYAf60G@antec>

Hi,

On 5/10/25 12:29 AM, Stafford Horne wrote:
> On Fri, May 09, 2025 at 12:10:57AM +0530, Sahil Siddiq wrote:
>> Hi Stafford,
>>
>> Thank you for your response.
>>
>> On 5/6/25 8:33 PM, Stafford Horne wrote:
>>> On Sat, May 03, 2025 at 09:44:54PM +0530, Sahil Siddiq wrote:
>>>> Hi,
>>>>
>>>> I have been looking into implementing ftrace for OpenRISC-linux. Based on what I have
>>>> understood from the ftrace design document [1], mcount will have to be implemented in
>>>> the kernel for ftrace to work.
>>>
>>> Thats right.
>>>
>>>> While this document is outdated, I did come across an article in the Linux Journal [2]
>>>> that explains the use of fentry instead of mcount in the implementation of ftrace. It
>>>> states that fentry is a powerful alternative to mcount. To make use of fentry, GCC's
>>>> -pg flag needs to be used along with the -mfentry flag. Simply calling -pg results in
>>>> mcount being used.
>>>>
>>>> Should it be possible for ftrace to make use of either option (fentry and mcount) when
>>>> implementing it for OpenRISC? Or should it only use fentry (or mcount)? mcount still
>>>> seems to be used in other architectures (I have only checked MIPS, RISC-V, LoongArch
>>>> and ARM so far).
>>>
>>> I think we should stick to mcount for now.  As I understand fentry is mainly and x86
>>> feature now.  We should be able to get it done with mcount, as you say that is
>>> what is what is used by other architectures like riscv.
>>
>> Going ahead with mcount would be relatively simpler especially since mcount is already
>> supported in OpenRISC. I must point out, though, that I overlooked the following
>> developments that have been made for other architectures:
>>
>> 1. Ftrace with fentry for s390. [1]
>> 2. Optimizing function trace for RISC-V. [2]
>>
>>> Another point is that for ftrace to work it uses a kind live patching [1] to turn
>>> the mcount calls to NOPs when the kernel boots up.  Then when we turn on tracing
>>> the code is patched to enable the mcount call.
>>>
>>> This live patching covers:
>>>
>>>    - kprobes - adds single instruction break points into kernel code
>>>    - static keys - allows for static branches, i.e. the check for cache enabled can
>>>      be done once then code re-written to to make certain checks go away.  We
>>>      could use this for cache availability checks.
>>>    - jump_label - low level support for code patching
>>>
>>> I think before going to far with ftrace we should look more into OpenRISC's
>>> roadmap for all of these.
>>
>> Understood. As a first step, I think it should be possible to support some of the
>> features in the debug subsystem - k(ret)probes, u(ret)probes, optprobes. Jump_labels
>> and perf-related features (e.g. kprobes-event) can be built on top of them.
>>
>> What are your thoughts on this?
> 
> I think its good, we should start working on this.  Also, there is another
> person who is interested in working on these features.  I will ask him to reply
> on this with his thoughts and see if there is a way we can split up the work.
> 
> But please start your progress as you can.
> 

Sure. Based on what I have understood from the synopsis of the GSoC proposal [1],
the focus will initially be on jump_labels. So, I'll start going through kprobes
in the meantime.

Thanks,
Sahil

[1] https://summerofcode.withgoogle.com/programs/2025/projects/qYsJ8YEg


  reply	other threads:[~2025-05-10  8:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-03 16:14 Queries regarding ftrace's implementation for OpenRISC-linux Sahil Siddiq
2025-05-06 15:03 ` Stafford Horne
2025-05-08 18:40   ` Sahil Siddiq
2025-05-09 18:59     ` Stafford Horne
2025-05-10  8:18       ` Sahil Siddiq [this message]
2025-09-09  4:26         ` KProbes " Sahil Siddiq
2025-09-11  9:52           ` Stafford Horne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51b89c55-ee58-461d-a2a0-5c8dd8ba77e7@gmail.com \
    --to=icegambit91@gmail.com \
    --cc=chenmiao.ku@gmail.com \
    --cc=linux-openrisc@vger.kernel.org \
    --cc=shorne@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).