From patchwork Tue Jun 4 21:28:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13685861 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C42814BFAB; Tue, 4 Jun 2024 21:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; cv=none; b=TPIrkKq6b1Es6B41YbNGCLfRBNI3TTrwbpOxpYvZMKoQSwh/B87kr5h50+WI77PbpmopXMG6n5mV3+0Hq6c4GlKnRDsU0I3SGgAKaam8jttgqZJ7nlX5i433ntp0t6dNoDAmBlpVjouUh+nAaUAyEni/QVeU2FMRJS9s24w1v7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; c=relaxed/simple; bh=Ldbg+sdfEohAnkSLIhjaFK1vi72Igfk+qnGb+F/ERbE=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ht1z+TOufFEJhy46OKbWVpS0jk/hc4JmjCis7S/1wHVYAeUlfkRmSKNFq/bWILUy468Cg2oPp4AkTLtCvvcPMRlfXI60YuuidlwkDeQF80z4M1dztB7Ah03qdRQVX+X8dfQd6m4TGOOcpRJXy2/7NPHPTykFhb9VxvSssNv8fzM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F28DDC2BBFC; Tue, 4 Jun 2024 21:28:53 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sEbiA-00000000bDL-2xE8; Tue, 04 Jun 2024 17:28:54 -0400 Message-ID: <20240604212854.564747474@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 04 Jun 2024 17:28:18 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [PATCH 1/5] ftrace: Rename dup_hash() and comment it References: <20240604212817.384103202@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" The name "dup_hash()" is a misnomer as it does not duplicate the hash that is passed in, but instead moves its entities from that hash to a newly allocated one. Rename it to "__move_hash()" (using starting underscores as it is an internal function), and add some comments about what it does. Signed-off-by: Steven Rostedt (Google) Reviewed-by: Masami Hiramatsu (Google) --- kernel/trace/ftrace.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index da7e6abf48b4..9dcdefe9d1aa 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1391,7 +1391,11 @@ ftrace_hash_rec_enable_modify(struct ftrace_ops *ops, int filter_hash); static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops, struct ftrace_hash *new_hash); -static struct ftrace_hash *dup_hash(struct ftrace_hash *src, int size) +/* + * Allocate a new hash and remove entries from @src and move them to the new hash. + * On success, the @src hash will be empty and should be freed. + */ +static struct ftrace_hash *__move_hash(struct ftrace_hash *src, int size) { struct ftrace_func_entry *entry; struct ftrace_hash *new_hash; @@ -1438,7 +1442,7 @@ __ftrace_hash_move(struct ftrace_hash *src) if (ftrace_hash_empty(src)) return EMPTY_HASH; - return dup_hash(src, size); + return __move_hash(src, size); } static int From patchwork Tue Jun 4 21:28:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13685859 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EFF81422AD; Tue, 4 Jun 2024 21:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; cv=none; b=PkCRF/uBIhvugqME3zqObI2fcoLEClH7Ei+YjkVZSc5BgmxhHkbYhhRmDILt5LM7cfNLIw85uLae5GgdTayJ9ptOWScfcH0I/TId2Mi2dpaJo17QJDE8diKyHAgS8k+HkaCaLkLppsi03ygXtEdidiWs6FRBxDblw7rxZN/7K5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; c=relaxed/simple; bh=gzuMoHpSvUC71Fv0Tg5dkH6tkrJ5zCwfPg5xYrrAB6I=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ngj+DHmo8/xEWj9YJBg/0elb+SXl+5e3z2Id0zitkUtWWV2BZnkvXXSbYUIJl77GLyrczJnFMELxdFymqZIev/Qs4IPL0DMH8qRFlq62fNhhjMAw0pvjsNWGRtqlfCCzMFkJMKpvWjOhK+JaCcP2C1G8c/Zz+l7swCOa6hDrTc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02786C4AF07; Tue, 4 Jun 2024 21:28:53 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sEbiA-00000000bDo-3cdN; Tue, 04 Jun 2024 17:28:54 -0400 Message-ID: <20240604212854.725383717@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 04 Jun 2024 17:28:19 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [PATCH 2/5] ftrace: Comment __ftrace_hash_rec_update() and make filter_hash bool References: <20240604212817.384103202@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" The function __ftrace_hash_rec_update() parameter "filter_hash" is only used for true or false (boolean), but is of type int. It already has an "inc" parameter that is boolean. This is confusing, make "filter_hash" boolean as well. While at it, add some documentation to that function especially since it holds the guts of the filtering logic of ftrace. Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 9dcdefe9d1aa..93c7c5fd4249 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1701,8 +1701,20 @@ static bool skip_record(struct dyn_ftrace *rec) !(rec->flags & FTRACE_FL_ENABLED); } +/* + * This is the main engine to the ftrace updates. + * + * It will iterate through all the available ftrace functions + * (the ones that ftrace can have callbacks to) and set the flags + * to the associated dyn_ftrace records. + * + * @filter_hash: True if for the filter hash is udpated, false for the + * notrace hash + * @inc: True to add this hash, false to remove it (increment the + * recorder counters or decrement them). + */ static bool __ftrace_hash_rec_update(struct ftrace_ops *ops, - int filter_hash, + bool filter_hash, bool inc) { struct ftrace_hash *hash; From patchwork Tue Jun 4 21:28:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13685862 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8221514C586; Tue, 4 Jun 2024 21:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; cv=none; b=HanW1ngPgTheoI6CnA1CNQI/VI0L/VT26VKHKzwDONf61QKz2CMXL2OpbXoTe1PalrOaNJrQXbCRc5lBQmrtyV39EBiclUyLjL1lKOM2tYJUE3EHtLXPzk5tm9ZS7NAv9VN95k88lNveRfV23ujH4PPFTe5yKSsaLOc+hmfKKJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; c=relaxed/simple; bh=JhvSJxkMdY2PHLlJ3j/YPU1BE6x6XkU5wBZAtk/6Go4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=u6AwpmUv9jrsaU16hfydixf6eklXSOVksOVMQ3OlmxDl/CYngSdG/X06PZbUAsarFFnbS4mqFoQlNGyPDSbdY8YYv5nRE6DZUFu3+cDHDkj689kK+mCdjOqPA0uMsprns+2lnEbtGKUtAbX3ZC0VYmUN3XBGpt0ebWJ2gZXZXf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23302C4AF0B; Tue, 4 Jun 2024 21:28:54 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sEbiB-00000000bEK-06a2; Tue, 04 Jun 2024 17:28:55 -0400 Message-ID: <20240604212854.883675803@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 04 Jun 2024 17:28:20 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [PATCH 3/5] ftrace: Remove "filter_hash" parameter from ftrace_hash_rec_disable/enable() References: <20240604212817.384103202@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" The functions ftrace_hash_rec_disable() and ftrace_hash_rec_enable() always has 1 passed to its "ftrace_hash" parameter. Remove the parameter and pass in true to __ftrace_hash_rec_update(). Also add some comments to both those functions explaining what they do. Signed-off-by: Steven Rostedt (Google) Acked-by: Mark Rutland Reviewed-by: Masami Hiramatsu (Google) --- kernel/trace/ftrace.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 93c7c5fd4249..de652201c86c 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1895,16 +1895,24 @@ static bool __ftrace_hash_rec_update(struct ftrace_ops *ops, return update; } -static bool ftrace_hash_rec_disable(struct ftrace_ops *ops, - int filter_hash) +/* + * This is called when an ops is removed from tracing. It will decrement + * the counters of the dyn_ftrace records for all the functions that + * the @ops attached to. + */ +static bool ftrace_hash_rec_disable(struct ftrace_ops *ops) { - return __ftrace_hash_rec_update(ops, filter_hash, 0); + return __ftrace_hash_rec_update(ops, true, 0); } -static bool ftrace_hash_rec_enable(struct ftrace_ops *ops, - int filter_hash) +/* + * This is called when an ops is added to tracing. It will increment + * the counters of the dyn_ftrace records for all the functions that + * the @ops attached to. + */ +static bool ftrace_hash_rec_enable(struct ftrace_ops *ops) { - return __ftrace_hash_rec_update(ops, filter_hash, 1); + return __ftrace_hash_rec_update(ops, true, 1); } static void ftrace_hash_rec_update_modify(struct ftrace_ops *ops, @@ -3062,7 +3070,7 @@ int ftrace_startup(struct ftrace_ops *ops, int command) return ret; } - if (ftrace_hash_rec_enable(ops, 1)) + if (ftrace_hash_rec_enable(ops)) command |= FTRACE_UPDATE_CALLS; ftrace_startup_enable(command); @@ -3104,7 +3112,7 @@ int ftrace_shutdown(struct ftrace_ops *ops, int command) /* Disabling ipmodify never fails */ ftrace_hash_ipmodify_disable(ops); - if (ftrace_hash_rec_disable(ops, 1)) + if (ftrace_hash_rec_disable(ops)) command |= FTRACE_UPDATE_CALLS; ops->flags &= ~FTRACE_OPS_FL_ENABLED; From patchwork Tue Jun 4 21:28:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13685863 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A07A14C59C; Tue, 4 Jun 2024 21:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; cv=none; b=mMerd3EdSvw/nhsKJLyjrwWWsMk3uSjkZNOqS5K76fMfl1eL880bFFywc9Sh49MHKO7KwecKzQNFzePzxMV6AVNH9c0Al3iup/Jw+9kIu8TI85zW2GZ8ibTre2q6T1Gr/+VyDbc/LeLB8aydhVMLucbyaqii3CvieRPrfx2bB80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; c=relaxed/simple; bh=VP452e+SSltPUNQ60WPUoVTjGYlGi4NsAMEX2G4U0oQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=sdcSazpmHIG29QKu81dJekjtoMmh2C5ED4q9/E6HRzB/nmXTujVAlIxfy9eR6GrlBOUny22WOmA3qW2p0OW2kqUDTFW05GYICmJLDLrizR07pbVJOakz0Yy1dbSbuecBGoqscZd7NLodmX0C6CFTH0/jKrWubK5GrXw0Ot21vh0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B391C4AF0E; Tue, 4 Jun 2024 21:28:54 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sEbiB-00000000bEo-0nHJ; Tue, 04 Jun 2024 17:28:55 -0400 Message-ID: <20240604212855.046127611@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 04 Jun 2024 17:28:21 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [PATCH 4/5] ftrace: Convert "filter_hash" and "inc" to bool in ftrace_hash_rec_update_modify() References: <20240604212817.384103202@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" The parameters "filter_hash" and "inc" in the function ftrace_hash_rec_update_modify() are boolean. Change them to be such. Also add documentation to what the function does. Signed-off-by: Steven Rostedt (Google) Acked-by: Mark Rutland --- kernel/trace/ftrace.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index de652201c86c..021024164938 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1915,8 +1915,31 @@ static bool ftrace_hash_rec_enable(struct ftrace_ops *ops) return __ftrace_hash_rec_update(ops, true, 1); } +/* + * This function will update what functions @ops traces when its filter + * changes. @filter_hash is set to true when modifying the filter_hash + * and set to false when modifying the notrace_hash. + * + * For example, if the user does: echo schedule > set_ftrace_filter + * that would call: ftrace_hash_rec_update_modify(ops, true, true); + * + * For: echo schedule >> set_ftrace_notrace + * That would call: ftrace_hash_rec_enable(ops, false, true); + * + * The @inc states if the @ops callbacks are going to be added or removed. + * The dyn_ftrace records are update via: + * + * ftrace_hash_rec_disable_modify(ops, filter_hash); + * ops->hash = new_hash + * ftrace_hash_rec_enable_modify(ops, filter_hash); + * + * Where the @ops is removed from all the records it is tracing using + * its old hash. The @ops hash is updated to the new hash, and then + * the @ops is added back to the records so that it is tracing all + * the new functions. + */ static void ftrace_hash_rec_update_modify(struct ftrace_ops *ops, - int filter_hash, int inc) + bool filter_hash, bool inc) { struct ftrace_ops *op; @@ -1939,15 +1962,15 @@ static void ftrace_hash_rec_update_modify(struct ftrace_ops *ops, } static void ftrace_hash_rec_disable_modify(struct ftrace_ops *ops, - int filter_hash) + bool filter_hash) { - ftrace_hash_rec_update_modify(ops, filter_hash, 0); + ftrace_hash_rec_update_modify(ops, filter_hash, false); } static void ftrace_hash_rec_enable_modify(struct ftrace_ops *ops, - int filter_hash) + bool filter_hash) { - ftrace_hash_rec_update_modify(ops, filter_hash, 1); + ftrace_hash_rec_update_modify(ops, filter_hash, true); } /* From patchwork Tue Jun 4 21:28:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13685864 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8FAD14D294; Tue, 4 Jun 2024 21:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; cv=none; b=OpDvC/z97/fvv7MEyHBadHscHAlWNsCc07eHduNKiDGair7XKLJR2l6p1HZp5Tjj/Y+f444g82z809PISFscYE+5CjH99Xr1dycc19NnDHbfpewHKHHP8Svp0UfijgvAJVKHzMQUrpUQLgos684v2Oc1KIb5qfVcq8cZvtTzmac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717536534; c=relaxed/simple; bh=cbZW4vL3SMGQ0M8GRVOAdEPhzxcmYTygyL7401g8GNk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=bFYggO0eTS3Db/336bP9t2o82F8G0GkA7iKuuNiGZyalYUyc4R6JJSubTNghS06VUrZ9gsFJ2x0DV5Gowyceecpglu9T6prJKpsz+GeVT9mGR5MRBBH358CNZ/flH4huyOhamKvXdNrtY2VGzwzkJ7zy+IhmVPfRXaXp9WVDhGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F9D7C4AF0A; Tue, 4 Jun 2024 21:28:54 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sEbiB-00000000bFI-1T5m; Tue, 04 Jun 2024 17:28:55 -0400 Message-ID: <20240604212855.208119464@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 04 Jun 2024 17:28:22 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [PATCH 5/5] ftrace: Add comments to ftrace_hash_move() and friends References: <20240604212817.384103202@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" Describe what ftrace_hash_move() does and add some more comments to some other functions to make it easier to understand. Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 021024164938..2d955f0c688f 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -169,6 +169,7 @@ static inline void ftrace_ops_init(struct ftrace_ops *ops) #endif } +/* Call this function for when a callback filters on set_ftrace_pid */ static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs) { @@ -1317,7 +1318,7 @@ static struct ftrace_hash *alloc_ftrace_hash(int size_bits) return hash; } - +/* Used to save filters on functions for modules not loaded yet */ static int ftrace_add_mod(struct trace_array *tr, const char *func, const char *module, int enable) @@ -1431,6 +1432,7 @@ static struct ftrace_hash *__move_hash(struct ftrace_hash *src, int size) return new_hash; } +/* Move the @src entries to a newly allocated hash */ static struct ftrace_hash * __ftrace_hash_move(struct ftrace_hash *src) { @@ -1445,6 +1447,26 @@ __ftrace_hash_move(struct ftrace_hash *src) return __move_hash(src, size); } +/** + * ftrace_hash_move - move a new hash to a filter and do updates + * @ops: The ops with the hash that @dst points to + * @enable: True if for the filter hash, false for the notrace hash + * @dst: Points to the @ops hash that should be updated + * @src: The hash to update @dst with + * + * This is called when an ftrace_ops hash is being updated and the + * the kernel needs to reflect this. Note, this only updates the kernel + * function callbacks if the @ops is enabled (not to be confused with + * @enable above). If the @ops is enabled, its hash determines what + * callbacks get called. This function gets called when the @ops hash + * is updated and it requires new callbacks. + * + * On success the elements of @src is moved to @dst, and @dst is updated + * properly, as well as the functions determined by the @ops hashes + * are now calling the @ops callback function. + * + * Regardless of return type, @src should be freed with free_ftrace_hash(). + */ static int ftrace_hash_move(struct ftrace_ops *ops, int enable, struct ftrace_hash **dst, struct ftrace_hash *src)