From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751206AbdJGIzI (ORCPT ); Sat, 7 Oct 2017 04:55:08 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:44002 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750852AbdJGIzF (ORCPT ); Sat, 7 Oct 2017 04:55:05 -0400 X-Google-Smtp-Source: AOwi7QAVLXxHjT2/31uADeVZm7Pfa6he5+ooE+W+fFHJf22HfWs1LRJbePxpcOTv13p1ZMN1qmXnkw== Date: Sat, 7 Oct 2017 10:55:00 +0200 From: Ingo Molnar To: Steven Rostedt Cc: Masami Hiramatsu , Kees Cook , Linus Torvalds , Peter Zijlstra , Alexei Starovoitov , Ananth N Mavinakayanahalli , "Paul E . McKenney" , Thomas Gleixner , LKML , "H . Peter Anvin" , Anil S Keshavamurthy , "David S . Miller" , Ian McDonald , Vlad Yasevich , Stephen Hemminger Subject: Re: [RFC PATCH -tip 0/5] kprobes: Abolish jprobe APIs Message-ID: <20171007085500.r7d2hscgotxjyfkg@gmail.com> References: <150724519527.5014.10207042218696587159.stgit@devbox> <20171005195808.2525a155@vmware.local.home> <20171006134959.e50c904ba6f302126cf4418c@kernel.org> <20171006113430.2c31561b@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171006113430.2c31561b@gandalf.local.home> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Steven Rostedt wrote: > On Fri, 6 Oct 2017 13:49:59 +0900 > Masami Hiramatsu wrote: > > > Steve, could you write a documentation how to use ftrace callback? > > I think I should update the Documentation/kprobes.txt so that jprobe > > user can easily migrate on that. > > I decided to do this now. Here's a first draft. What do you think? > > -- Steve > > Using ftrace to hook to functions > ================================= > > Copyright 2017 VMware Inc. > Author: Steven Rostedt > License: The GNU Free Documentation License, Version 1.2 > (dual licensed under the GPL v2) > > Written for: 4.14 > > Introduction > ------------ > > The ftrace infrastructure was originially created to attach hooks to the > beginning of functions in order to record and trace the flow of the kernel. > But hooks to the start of a function can have other use cases. Either > for live kernel patching, or for security monitoring. This document describes > how to use ftrace to implement your own function hooks. > > > The ftrace context > ================== > > WARNING: The ability to add a callback to almost any function within the > kernel comes with risks. A callback can be called from any context > (normal, softirq, irq, and NMI). Callbacks can also be called just before > going to idle, during CPU bring up and takedown, or going to user space. > This requires extra care to what can be done inside a callback. A callback > can be called outside the protective scope of RCU. > > The ftrace infrastructure has some protections agains recursions and RCU > but one must still be very careful how they use the callbacks. > > > The ftrace_ops structure > ======================== > > To register a function callback, a ftrace_ops is required. This structure > is used to tell ftrace what function should be called as the callback > as well as what protections the callback will perform and not require > ftrace to handle. So the text first starts talking about 'hooks' then uses the 'callback' terminology in the rest of th document. Could we please change it all to 'callback'? [ This is a pet peeve of mine as 'hook' gives me the cringe! ;-) ] Thanks, Ingo