From nobody Thu Feb 12 21:49:29 2026 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 809B5195988 for ; Thu, 6 Jun 2024 12:11:00 +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=1717675860; cv=none; b=q2QRixQIV2+0PUM84kIL25KDVMgz5B6yevMMPnfJNttqEEhwfRDXQZtGejF178TfpBtOItG2PqtsswkYIcT71dd2Pr/FT3pCJHlSHooqZAWrIhGM6b/xy0rriMQy56ebK8/2xlj+r4+e73chwXHS4fW90tOiDZ5cGN87eYg4z70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675860; c=relaxed/simple; bh=PNceJ0fe4F1UTs7lOuAfilYYz36/N4ma7OLgumFm98I=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=GrwV+SLph3lwa4rSc5/ZeRRHKM50mpk3IVhlYbk+1dUJvL5Am2Kk1EaTn87hGsMfKB3aMYjqSsUre7TJCZdVXJhqirrUo9t7ceru4tNUJMIhL5HOqQKqYC7Knpa/qGa5eSwMKvjQMrZSwfOfLEvokuC2hAAcTtHz3YkMyKWsPFc= 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 237EFC4AF08; Thu, 6 Jun 2024 12:11:00 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxQ-00000000nIt-2veA; Thu, 06 Jun 2024 08:11:04 -0400 Message-ID: <20240606121104.557984575@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:05 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 01/15] ftrace: Add back ftrace_update_trampoline() to ftrace_update_pid_func() References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The update to the ops trampoline done by the function ftrace_update_trampoline() was accidentally removed from ftrace_update_pid_func(). Add it back. Link: https://lore.kernel.org/linux-trace-kernel/20240605205337.6115e9a5@ga= ndalf.local.home Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Fixes: df3ec5da6a1e ("function_graph: Add pid tracing back to function grap= h tracer") Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index da7e6abf48b4..897d7541041c 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -402,6 +402,7 @@ static void ftrace_update_pid_func(void) if (op->flags & FTRACE_OPS_FL_PID) { op->func =3D ftrace_pids_enabled(op) ? ftrace_pid_func : op->saved_func; + ftrace_update_trampoline(op); } } while_for_each_ftrace_op(op); =20 --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 C81FB19599A for ; Thu, 6 Jun 2024 12:11:00 +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=1717675860; cv=none; b=AQUVw/12oPKgo2xoaq/lV9Zk//XHL/41n2ieJCwHr/em+8abIzgu2IZDlsSToeSrB3swvMC8N4tIrMmwo82sTmvOJjhzKQXAUkotM6Y8eMG4h9aDoEC4udhbhEmx+l4skLnT3mWBCTgPi1JbaajVQ38lU2rxvpc7baILbQYC0pQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675860; c=relaxed/simple; bh=Rspk0buCUkwvxU8eo6olbM8rLVcIyG11H0MjJgWcYCo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=HHVHb7cmZ7lR5a3MovbV12lWzadrUGUg6+3G0ctpHkQcmbbZEDjMk0UT6ySMLIYNRoEapDarBoe9A+1UBt19VEefIDBtf8NEgwYJwVJGXqAkI1A0ABn9kFXfVbQqUwRtRGtzD15+p8eZlpmfRp6ysbYhbRjsY0M6GGACG4ygz60= 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 5B6EBC4AF1A; Thu, 6 Jun 2024 12:11:00 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxQ-00000000nJN-3c1Y; Thu, 06 Jun 2024 08:11:04 -0400 Message-ID: <20240606121104.719232091@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:06 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 02/15] ftrace/selftests: Fix pid test with function graph not showing pids References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The pid filtering test will set the pid filters and make sure that both function and function_graph tracing honors the filters. But the function_graph tracer test was failing because the PID was not being filtered properly. That's because the funcgraph-proc option wasn't getting set. Without that option the PID is not shown. Instead we get: + cat trace # tracer: function_graph # # CPU DURATION FUNCTION CALLS # | | | | | | | 3) ! 143.685 us | kernel_clone(); 3) ! 127.055 us | kernel_clone(); 1) ! 127.170 us | kernel_clone(); 3) ! 126.840 us | kernel_clone(); When we should be getting: + cat trace # tracer: function_graph # # CPU TASK/PID DURATION FUNCTION CALLS # | | | | | | | | | 4) bash-939 | # 1070.009 us | kernel_clone(); 4) bash-939 | # 1116.903 us | kernel_clone(); 5) bash-939 | ! 976.133 us | kernel_clone(); 5) bash-939 | ! 954.012 us | kernel_clone(); The test looks for the pids it is filtering and will fail if it can not find them. Without fungraph-proc option set, it will not be displayed and the test will fail. Link: https://lore.kernel.org/all/Zl9JFnzKGuUM10X2@J2N7QTR9R3/ Link: https://lore.kernel.org/linux-trace-kernel/20240604152550.0c01d7cd@ga= ndalf.local.home Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Fixes: 35b944a997e2 ("selftests/ftrace: Add function_graph tracer to func-f= ilter-pid test") Reported-by: Mark Rutland Signed-off-by: Steven Rostedt (Google) Tested-by: Mark Rutland --- tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.t= c b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc index c6fc9d31a496..8dcce001881d 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc @@ -8,6 +8,7 @@ # Also test it on an instance directory =20 do_function_fork=3D1 +do_funcgraph_proc=3D1 =20 if [ ! -f options/function-fork ]; then do_function_fork=3D0 @@ -28,6 +29,7 @@ fi =20 if [ $do_funcgraph_proc -eq 1 ]; then orig_value2=3D`cat options/funcgraph-proc` + echo 1 > options/funcgraph-proc fi =20 do_reset() { --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 171C6195F08 for ; Thu, 6 Jun 2024 12:11:00 +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=1717675861; cv=none; b=eVH+uDKX1tUeixnbgYQFaD8pTxMVSN9eI6teQEewuaaGxAghTZS6nxmeNqxr043EZcGix9Aw34W1KFH6v64aaEobeX4ygtOzib4al9u2O+knG11v40SU8vJYUnT2GGWi/2pqW8NtCv7CfyUiP88L+Tqs3cBK64ag4K80OEyrPDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675861; c=relaxed/simple; bh=c9qk2ba39DxvpoLJ7rt1t9FBbO0uYm2kZ33GQZpUTfQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ZD45h7VhZLiPjPppZDCYoNJyuxngA/rYSTkL/Ao0KYfadrKZn/B2tl7j0wIXs4CEr5zU4m7Y0UjKJzr0glYDay95EnI/VxhUdQrY1pcw0WLQZmR9CsY54Wd52JD4sNF7ux77PO63eHjZ4AljOIryN5OWDd/ysIfL75hFRs3Ux0w= 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 8880BC4AF60; Thu, 6 Jun 2024 12:11:00 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxR-00000000nJr-04Tq; Thu, 06 Jun 2024 08:11:05 -0400 Message-ID: <20240606121104.879342374@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:07 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 03/15] ftrace: Rename dup_hash() and comment it References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Link: https://lore.kernel.org/linux-trace-kernel/20240605180408.537723591@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (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 897d7541041c..f4b253d20df8 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1392,7 +1392,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); =20 -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 n= ew 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; @@ -1439,7 +1443,7 @@ __ftrace_hash_move(struct ftrace_hash *src) if (ftrace_hash_empty(src)) return EMPTY_HASH; =20 - return dup_hash(src, size); + return __move_hash(src, size); } =20 static int --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 3D993195F1C for ; Thu, 6 Jun 2024 12:11:01 +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=1717675861; cv=none; b=Tl8KnIpL2edqlhlTK03sl2SVEJuTcpZS87nbtzVrNOuwNpYFwx5pzqWKDEzG8AS7lkM6Gt+4P5PvSO2M9hQcU/FURs/3JlMP1lvz8OfjSgBveFfx4O52CQHeSLkzuOh8w17gVAJgstz5AUVFfwRHfnvkoa7Zl8azJLhkrQds7hk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675861; c=relaxed/simple; bh=W4l6MfqT8UKz1IsW80Cwa7ibONhnzaZC8uRE0CV67ig=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=dA5rLE+FshybQLGRr/oMI9bgapfqsLTswjqzHMXGncfTab6pGdQSNakN5JVZTirmCNTe8rXLkC2yqMJIWi+Zz7SIHVWspINxrX9rr1P9H1z/thVHbWnX9mPrHUl1OBCZCrDnOI4urh8lXZXdzgCRm26xF2lQwZmyuQmrp+IfOqg= 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 B57A8C4DDE1; Thu, 6 Jun 2024 12:11:00 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxR-00000000nKM-0jbN; Thu, 06 Jun 2024 08:11:05 -0400 Message-ID: <20240606121105.037365034@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:08 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 04/15] ftrace: Remove "ftrace_hash" parameter from __ftrace_hash_rec_update() References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" While adding comments to the function __ftrace_hash_rec_update() and trying to describe in detail what the parameter for "ftrace_hash" does, I realized that it basically does exactly the same thing (but differently) if it is set or not! If it is set, the idea was the ops->filter_hash was being updated, and the code should focus on the functions that are in the ops->filter_hash and add them. But it still had to pay attention to the functions in the ops->notrace_hash, to ignore them. If it was cleared, it focused on the ops->notrace_hash, and would add functions that were not in the ops->notrace_hash but would still keep functions in the "ops->filter_hash". Basically doing the same thing. In reality, the __ftrace_hash_rec_update() only needs to either remove the functions associated to the give ops (if "inc" is set) or remove them (if "inc" is cleared). It has to pay attention to both the filter_hash and notrace_hash regardless. Remove the "filter_hash" parameter from __filter_hash_rec_update() and comment the function for what it really is doing. Link: https://lore.kernel.org/linux-trace-kernel/20240605180408.691995506@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 102 ++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index f4b253d20df8..abcdffa4d572 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1384,10 +1384,8 @@ alloc_and_copy_ftrace_hash(int size_bits, struct ftr= ace_hash *hash) return NULL; } =20 -static void -ftrace_hash_rec_disable_modify(struct ftrace_ops *ops, int filter_hash); -static void -ftrace_hash_rec_enable_modify(struct ftrace_ops *ops, int filter_hash); +static void ftrace_hash_rec_disable_modify(struct ftrace_ops *ops); +static void ftrace_hash_rec_enable_modify(struct ftrace_ops *ops); =20 static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops, struct ftrace_hash *new_hash); @@ -1475,11 +1473,11 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable, * Remove the current set, update the hash and add * them back. */ - ftrace_hash_rec_disable_modify(ops, enable); + ftrace_hash_rec_disable_modify(ops); =20 rcu_assign_pointer(*dst, new_hash); =20 - ftrace_hash_rec_enable_modify(ops, enable); + ftrace_hash_rec_enable_modify(ops); =20 return 0; } @@ -1702,12 +1700,21 @@ static bool skip_record(struct dyn_ftrace *rec) !(rec->flags & FTRACE_FL_ENABLED); } =20 +/* + * This is the main engine to the ftrace updates to the dyn_ftrace records. + * + * It will iterate through all the available ftrace functions + * (the ones that ftrace can have callbacks to) and set the flags + * in the associated dyn_ftrace records. + * + * @inc: If true, the functions associated to @ops are added to + * the dyn_ftrace records, otherwise they are removed. + */ static bool __ftrace_hash_rec_update(struct ftrace_ops *ops, - int filter_hash, bool inc) { struct ftrace_hash *hash; - struct ftrace_hash *other_hash; + struct ftrace_hash *notrace_hash; struct ftrace_page *pg; struct dyn_ftrace *rec; bool update =3D false; @@ -1719,35 +1726,16 @@ static bool __ftrace_hash_rec_update(struct ftrace_= ops *ops, return false; =20 /* - * In the filter_hash case: * If the count is zero, we update all records. * Otherwise we just update the items in the hash. - * - * In the notrace_hash case: - * We enable the update in the hash. - * As disabling notrace means enabling the tracing, - * and enabling notrace means disabling, the inc variable - * gets inversed. */ - if (filter_hash) { - hash =3D ops->func_hash->filter_hash; - other_hash =3D ops->func_hash->notrace_hash; - if (ftrace_hash_empty(hash)) - all =3D true; - } else { - inc =3D !inc; - hash =3D ops->func_hash->notrace_hash; - other_hash =3D ops->func_hash->filter_hash; - /* - * If the notrace hash has no items, - * then there's nothing to do. - */ - if (ftrace_hash_empty(hash)) - return false; - } + hash =3D ops->func_hash->filter_hash; + notrace_hash =3D ops->func_hash->notrace_hash; + if (ftrace_hash_empty(hash)) + all =3D true; =20 do_for_each_ftrace_rec(pg, rec) { - int in_other_hash =3D 0; + int in_notrace_hash =3D 0; int in_hash =3D 0; int match =3D 0; =20 @@ -1759,26 +1747,17 @@ static bool __ftrace_hash_rec_update(struct ftrace_= ops *ops, * Only the filter_hash affects all records. * Update if the record is not in the notrace hash. */ - if (!other_hash || !ftrace_lookup_ip(other_hash, rec->ip)) + if (!notrace_hash || !ftrace_lookup_ip(notrace_hash, rec->ip)) match =3D 1; } else { in_hash =3D !!ftrace_lookup_ip(hash, rec->ip); - in_other_hash =3D !!ftrace_lookup_ip(other_hash, rec->ip); + in_notrace_hash =3D !!ftrace_lookup_ip(notrace_hash, rec->ip); =20 /* - * If filter_hash is set, we want to match all functions - * that are in the hash but not in the other hash. - * - * If filter_hash is not set, then we are decrementing. - * That means we match anything that is in the hash - * and also in the other_hash. That is, we need to turn - * off functions in the other hash because they are disabled - * by this hash. + * We want to match all functions that are in the hash but + * not in the other hash. */ - if (filter_hash && in_hash && !in_other_hash) - match =3D 1; - else if (!filter_hash && in_hash && - (in_other_hash || ftrace_hash_empty(other_hash))) + if (in_hash && !in_notrace_hash) match =3D 1; } if (!match) @@ -1884,24 +1863,21 @@ static bool __ftrace_hash_rec_update(struct ftrace_= ops *ops, return update; } =20 -static bool ftrace_hash_rec_disable(struct ftrace_ops *ops, - int filter_hash) +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, 0); } =20 -static bool ftrace_hash_rec_enable(struct ftrace_ops *ops, - int filter_hash) +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, 1); } =20 -static void ftrace_hash_rec_update_modify(struct ftrace_ops *ops, - int filter_hash, int inc) +static void ftrace_hash_rec_update_modify(struct ftrace_ops *ops, int inc) { struct ftrace_ops *op; =20 - __ftrace_hash_rec_update(ops, filter_hash, inc); + __ftrace_hash_rec_update(ops, inc); =20 if (ops->func_hash !=3D &global_ops.local_hash) return; @@ -1915,20 +1891,18 @@ static void ftrace_hash_rec_update_modify(struct ft= race_ops *ops, if (op =3D=3D ops) continue; if (op->func_hash =3D=3D &global_ops.local_hash) - __ftrace_hash_rec_update(op, filter_hash, inc); + __ftrace_hash_rec_update(op, inc); } while_for_each_ftrace_op(op); } =20 -static void ftrace_hash_rec_disable_modify(struct ftrace_ops *ops, - int filter_hash) +static void ftrace_hash_rec_disable_modify(struct ftrace_ops *ops) { - ftrace_hash_rec_update_modify(ops, filter_hash, 0); + ftrace_hash_rec_update_modify(ops, 0); } =20 -static void ftrace_hash_rec_enable_modify(struct ftrace_ops *ops, - int filter_hash) +static void ftrace_hash_rec_enable_modify(struct ftrace_ops *ops) { - ftrace_hash_rec_update_modify(ops, filter_hash, 1); + ftrace_hash_rec_update_modify(ops, 1); } =20 /* @@ -3051,7 +3025,7 @@ int ftrace_startup(struct ftrace_ops *ops, int comman= d) return ret; } =20 - if (ftrace_hash_rec_enable(ops, 1)) + if (ftrace_hash_rec_enable(ops)) command |=3D FTRACE_UPDATE_CALLS; =20 ftrace_startup_enable(command); @@ -3093,7 +3067,7 @@ int ftrace_shutdown(struct ftrace_ops *ops, int comma= nd) /* Disabling ipmodify never fails */ ftrace_hash_ipmodify_disable(ops); =20 - if (ftrace_hash_rec_disable(ops, 1)) + if (ftrace_hash_rec_disable(ops)) command |=3D FTRACE_UPDATE_CALLS; =20 ops->flags &=3D ~FTRACE_OPS_FL_ENABLED; --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 44847195F23 for ; Thu, 6 Jun 2024 12:11:01 +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=1717675861; cv=none; b=V/35l2V8HBr3Ay8m5nbO7ecQErLM7IavFFgKX/zlyZb8BE0Mm5xtgAL23GQ3lGiwrdqEfoEojSaFHUkA5DxRcwQYEh938rFyZAS4GtD+aqJ+vVcCU/6EVjzzNhCCzwcT1lHveuY0OjTNHaScaTsg//NhlL0IO1qT6Dm76d/qf/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675861; c=relaxed/simple; bh=UQmRInHjs4WMU28q1p/Y/++JZxg0i2kAsZIONMTIPYM=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=o0XPjZdjrkTmx6Cc2uyjMHMOHsOcTzhhrEhLzMOr8sHrbYXVgpXdEhGWH7jtO/cGtmkKw/eyMJK75DPE/QgioXYtttFFT22LkMzTGHLSlE1Wb/iyHqZQeVkmozYJfQux/gRQ/DiMvrf5pKAcQL7zQv5EgmzdWoAB5TbszOk9blw= 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 C8E56C4DDF4; Thu, 6 Jun 2024 12:11:00 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxR-00000000nKq-1NW6; Thu, 06 Jun 2024 08:11:05 -0400 Message-ID: <20240606121105.194409809@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:09 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 05/15] ftrace: Add comments to ftrace_hash_rec_disable/enable() References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" Add comments to describe what the functions ftrace_hash_rec_disable() and ftrace_hash_rec_enable() do. Also change the passing of the "inc" variable to __ftrace_hash_rec_update() to a boolean value as that is what it is supposed to take. Link: https://lore.kernel.org/linux-trace-kernel/20240605180408.857333430@g= oodmis.org Cc: Mathieu Desnoyers Cc: Andrew Morton Acked-by: Mark Rutland Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index abcdffa4d572..4140d0ce25f1 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1863,14 +1863,24 @@ static bool __ftrace_hash_rec_update(struct ftrace_= ops *ops, return update; } =20 +/* + * 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, 0); + return __ftrace_hash_rec_update(ops, false); } =20 +/* + * 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, 1); + return __ftrace_hash_rec_update(ops, true); } =20 static void ftrace_hash_rec_update_modify(struct ftrace_ops *ops, int inc) --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 5825C195F27 for ; Thu, 6 Jun 2024 12:11:01 +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=1717675861; cv=none; b=rWlytpwh8ewySoFO2n5cNSfyTmn4P3Kw5TAk9gHwxbTWd/8HKk0UZmpw2sjBcviWvKyi/5o9qORdCrArJgm+qTuIiBuXwyGkHNKQyKtGJb6QQVRSCIlxLwyJmGDmyKft9VaB0b4oFkYfrdRoQYNfetWvCTt2ZAaWgJoAYm1gpIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675861; c=relaxed/simple; bh=H4J/vOPaYGRMPo4WfrxbkfzY1t5g0RPt7rHCPw01rI8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=diSz4rRUzwh2DEwVXvd/1hLrlGW+6384KsXZMQka++Fm2vlsuv2qBb12r6k9ahRzZqoIcgC/13rCA7ycla9ij9p/pESLAkSVPb2/ZitGmPi/obO8Aywo0WKlreefoE4Kq5Uk+HhyBdlrhCGsTSBmedftE7GBbWt+FnfRFMFngKc= 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 0E6AFC4DE0B; Thu, 6 Jun 2024 12:11:01 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxR-00000000nLK-23op; Thu, 06 Jun 2024 08:11:05 -0400 Message-ID: <20240606121105.350727218@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:10 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 06/15] ftrace: Convert "inc" parameter to bool in ftrace_hash_rec_update_modify() References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The parameter "inc" in the function ftrace_hash_rec_update_modify() is boolean. Change it to be such. Also add documentation to what the function does. Link: https://lore.kernel.org/linux-trace-kernel/20240605180409.021080462@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4140d0ce25f1..256b5e07c39a 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1883,7 +1883,24 @@ static bool ftrace_hash_rec_enable(struct ftrace_ops= *ops) return __ftrace_hash_rec_update(ops, true); } =20 -static void ftrace_hash_rec_update_modify(struct ftrace_ops *ops, int inc) +/* + * This function will update what functions @ops traces when its filter + * changes. + * + * The @inc states if the @ops callbacks are going to be added or removed. + * When one of the @ops hashes are updated to a "new_hash" the dyn_ftrace + * records are update via: + * + * ftrace_hash_rec_disable_modify(ops); + * ops->hash =3D new_hash + * ftrace_hash_rec_enable_modify(ops); + * + * 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, bool inc) { struct ftrace_ops *op; =20 @@ -1907,12 +1924,12 @@ static void ftrace_hash_rec_update_modify(struct ft= race_ops *ops, int inc) =20 static void ftrace_hash_rec_disable_modify(struct ftrace_ops *ops) { - ftrace_hash_rec_update_modify(ops, 0); + ftrace_hash_rec_update_modify(ops, false); } =20 static void ftrace_hash_rec_enable_modify(struct ftrace_ops *ops) { - ftrace_hash_rec_update_modify(ops, 1); + ftrace_hash_rec_update_modify(ops, true); } =20 /* --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 5A3F2195F2A for ; Thu, 6 Jun 2024 12:11:01 +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=1717675861; cv=none; b=HwUkRUaI+iENkTnY5GR3K6HmAK0/IMCXfav0Ptke8noGyZ5dhFrDAyFDRm5WuocrBAz/8Kg5BSocgFLTAEYICGxbiTQpogruGbbzoKdXnE/kWdO9Sknt8quTQvmbDjQpqh84jxghXKtE1WdxVWsPE3bgHRrm/lMEIVRs8TygM5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675861; c=relaxed/simple; bh=NJYbbejIctt8G+auynjs7BQD1BTTaaHXR8rDk7HRzc0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=FpQVlr6OG4/h0DiZxwvsjMPerZmePQhjtJ7R3pVbPUJlltSYxGRlSfBr9Y8iDwHplziohePMOW8WxuyDZg5Pff1sZcY1DdXPEPRbGcnH4ejiSTrxlrcodzbwQexZI3O9oPQW52ZgUlmkKaYraN528JQRn3SjyXSqbNhCXbhd19k= 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 24A94C4AF0C; Thu, 6 Jun 2024 12:11:01 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxR-00000000nLo-2ink; Thu, 06 Jun 2024 08:11:05 -0400 Message-ID: <20240606121105.511202862@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:11 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 07/15] ftrace: Add comments to ftrace_hash_move() and friends References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Link: https://lore.kernel.org/linux-trace-kernel/20240605180409.179520305@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Acked-by: Masami Hiramatsu (Google) 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 256b5e07c39a..9c4d01b1bb68 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -169,6 +169,7 @@ static inline void ftrace_ops_init(struct ftrace_ops *o= ps) #endif } =20 +/* 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) { @@ -1318,7 +1319,7 @@ static struct ftrace_hash *alloc_ftrace_hash(int size= _bits) return hash; } =20 - +/* 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) @@ -1430,6 +1431,7 @@ static struct ftrace_hash *__move_hash(struct ftrace_= hash *src, int size) return new_hash; } =20 +/* Move the @src entries to a newly allocated hash */ static struct ftrace_hash * __ftrace_hash_move(struct ftrace_hash *src) { @@ -1444,6 +1446,26 @@ __ftrace_hash_move(struct ftrace_hash *src) return __move_hash(src, size); } =20 +/** + * 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) --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 95B7B195FCD for ; Thu, 6 Jun 2024 12:11:01 +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=1717675861; cv=none; b=k3jIySiJ1H1JwbnL8yIsPfrw3kLoJ6Q1jbhp7qvBTfbTqyIrk620Qm3vKgoNwEq5vj2fqL/CC4BU7r/Gxg7TYeA4hJPE0V4T07Ij+1fRF86788sdtq2m7P8tMbyLEkF4PiWoBXQYrmp7pvx2OMWnxV2wXiIZ+FjZEAWFjkAPACs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675861; c=relaxed/simple; bh=iVZzamMFw4KSf7EJWCT9D8ewRTw/E7zgRCVheMa8EUU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=NB7Jy5weE6FawZ/6GoOvIbvqfJlwV1QrEl/0g1aKxHJnE77qlpc8op+k6yKAA73oWkHLRkoKxO22pdt/UkvO+pjODF5uMM1bbRT2jX4bGrmW/6GqgGY96UQF4pNP4wu3roossrnTphmAJQmyeOdpVtu37rL1zAqp+YVTRTc6cuk= 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 48262C4DDE4; Thu, 6 Jun 2024 12:11:01 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxR-00000000nMK-3Oit; Thu, 06 Jun 2024 08:11:05 -0400 Message-ID: <20240606121105.667743331@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:12 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 08/15] ftrace: Declare function_trace_op in header to quiet sparse warning References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" Sparse complains that function_trace_op is not static but is not declared in a header file. It is used only in assembly code. But add it to a header so that sparse no longer complains: kernel/trace/ftrace.c:99:19: warning: symbol 'function_trace_op' was not d= eclared. Should it be static? Link: https://lore.kernel.org/linux-trace-kernel/20240605202708.289105647@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- include/linux/ftrace.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 9f61556a9491..4135dc171447 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -1131,6 +1131,9 @@ extern void ftrace_graph_init_task(struct task_struct= *t); extern void ftrace_graph_exit_task(struct task_struct *t); extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu); =20 +/* Used by assembly, but to quiet sparse warnings */ +extern struct ftrace_ops *function_trace_op; + static inline void pause_graph_tracing(void) { atomic_inc(¤t->tracing_graph_pause); --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 9D0AC195FD5 for ; Thu, 6 Jun 2024 12:11:01 +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=1717675861; cv=none; b=fBYuvHgOamWqPfQR6uGw395ItfnPeEvygfy0sL4oZkwxKmE5UQAR8ed2K5IfsB9AL09qMRMzSotSh7H1s2K2Ukc4790ye0fKqAKJZ8XBXesacM+jRmrDQvhkFTT9WtXtewjj3Wqsoef98HkvHH5CmwUz0zhgZCY3hURMFCFQvGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675861; c=relaxed/simple; bh=1USSILCftAKY2knoh2V0QYMEyPvdlS6a70pxmpzW/yw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=EpuAarIEyb2svTlrS5OS+vXoBsc/X+318Les7ma7+fzu/Rn5+VlEosUiXOvWI1MbtnCG4ilngJRh1+NxPi+ye4colemJSaz+D6KEbozqvRyGarPxoAmB1T6ovvPk1QXcT+hYzpwPVEr+shpDCm4vOJweffow6F1gi24u9wfHLEM= 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 7A59BC4DDE5; Thu, 6 Jun 2024 12:11:01 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxR-00000000nMp-440Z; Thu, 06 Jun 2024 08:11:05 -0400 Message-ID: <20240606121105.828859387@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:13 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 09/15] ftrace: Assign ftrace_list_end to ftrace_ops_list type cast to RCU References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" Use a type cast to convert ftrace_list_end to RCU when assigning ftrace_ops_list. This will quiet the sparse warning: kernel/trace/ftrace.c:125:59: warning: incorrect type in initializer (diff= erent address spaces) kernel/trace/ftrace.c:125:59: expected struct ftrace_ops [noderef] __rc= u *[addressable] [toplevel] ftrace_ops_list kernel/trace/ftrace.c:125:59: got struct ftrace_ops * Link: https://lore.kernel.org/linux-trace-kernel/20240605202708.450784356@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 9c4d01b1bb68..034242675e7b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -122,7 +122,7 @@ static int ftrace_disabled __read_mostly; =20 DEFINE_MUTEX(ftrace_lock); =20 -struct ftrace_ops __rcu *ftrace_ops_list __read_mostly =3D &ftrace_list_en= d; +struct ftrace_ops __rcu *ftrace_ops_list __read_mostly =3D (struct ftrace_= ops __rcu *)&ftrace_list_end; ftrace_func_t ftrace_trace_function __read_mostly =3D ftrace_stub; struct ftrace_ops global_ops; =20 --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 AB3A3195FD9 for ; Thu, 6 Jun 2024 12:11:01 +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=1717675861; cv=none; b=b7GijvImqRRsC221s/LHHd8VzashDopQ7blopQ4wrS/vUbVVzjLHqUjsF6j49s2Wp4CxargN8wsPEe1cbZIh5NmLZJcdk+ilml03PTHFXEWt/TcQeRAcuP9gxjyUbTcHg18dLLZ765UpoU9cjI+AitDX0UimESGuIABcayA2obw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675861; c=relaxed/simple; bh=HjlzeB6C1CgYsE+B087pV2CKhW5luo4DRzutqhcqgpk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=i369FUzWJdJUIFCVzBpPjdTgTr+FKlsXqq68NrTA03xBhLu/GpZfnCU9ARRvMJO89RYGWo8bAAtkaLNHCsSGuocV83iIOkfI7IrPePu72/+mXmgLJBg5Yr3/fwL2AL2TbbiwEGxl/6tX1U9sk9ylR/UcAWzqalMqjzsEL6Tfivg= 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 9486EC4AF5F; Thu, 6 Jun 2024 12:11:01 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxS-00000000nNK-0Vu2; Thu, 06 Jun 2024 08:11:06 -0400 Message-ID: <20240606121105.987880939@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:14 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 10/15] ftrace: Assign RCU list variable with rcu_assign_ptr() References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" Use rcu_assign_ptr() to assign the list pointer as it is marked as RCU, and this quiets the sparse warning: kernel/trace/ftrace.c:313:23: warning: incorrect type in assignment (dif= ferent address spaces) kernel/trace/ftrace.c:313:23: expected struct ftrace_ops [noderef] __= rcu * kernel/trace/ftrace.c:313:23: got struct ftrace_ops * Link: https://lore.kernel.org/linux-trace-kernel/20240605202708.613471310@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 034242675e7b..4aeb1183ea9f 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -311,7 +311,7 @@ static int remove_ftrace_ops(struct ftrace_ops __rcu **= list, lockdep_is_held(&ftrace_lock)) =3D=3D ops && rcu_dereference_protected(ops->next, lockdep_is_held(&ftrace_lock)) =3D=3D &ftrace_list_end) { - *list =3D &ftrace_list_end; + rcu_assign_pointer(*list, &ftrace_list_end); return 0; } =20 --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 3D9D1197524 for ; Thu, 6 Jun 2024 12:11:01 +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=1717675862; cv=none; b=DuZsRdtWuVAY4Oa58LMkt68K1Z8QTe92zwUJTywM9YPmcP1j2OK1IK1whXLTWsnTAv/uhLBa18luAI7M6ebAohiBhwLrpSOv/PQiuqHXCGKgB8rWF4ca+amR5YWOW0NV6BgoMXKPNccCyHkWKQnbKZMyzNyEKYP05JaQcuWOxkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675862; c=relaxed/simple; bh=Mh8Nc2PUn8WQF6A4kwG6AMoIRiTAM/kSAgU2FgOhyiU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=F/6XJX8i9nE+225KVKyPnofudNDVmaMam2rrZCwsCF534ZF94Jd/cJCNUTaENIT2kis6rL0pZco0LGc12Oijd9QftzvsZ3qxjbxUCvwvPl0ScCWiLjalzsP7FFk2vTGpkW1SNMnED0R7InRBc25B5Au3zZfA3vUzpoQJagaiqnE= 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 C1567C32782; Thu, 6 Jun 2024 12:11:01 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxS-00000000nNo-1Avm; Thu, 06 Jun 2024 08:11:06 -0400 Message-ID: <20240606121106.141319090@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:15 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , kernel test robot Subject: [for-next][PATCH 11/15] ftrace: Fix prototypes for ftrace_startup/shutdown_subops() References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The ftrace_startup_subops() was in the wrong header, and both functions were not defined on !CONFIG_DYNAMIC_FTRACE. Link: https://lore.kernel.org/linux-trace-kernel/20240605202708.773583114@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Fixes: 5fccc7552ccbc ("ftrace: Add subops logic to allow one ops to manage = many") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202406051524.a12JqLqx-lkp@int= el.com/ Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace_internal.h | 9 +++++++++ kernel/trace/trace.h | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/trace/ftrace_internal.h b/kernel/trace/ftrace_internal.h index bfba10c2fcf1..4bb1e881154a 100644 --- a/kernel/trace/ftrace_internal.h +++ b/kernel/trace/ftrace_internal.h @@ -15,6 +15,7 @@ extern struct ftrace_ops global_ops; int ftrace_startup(struct ftrace_ops *ops, int command); int ftrace_shutdown(struct ftrace_ops *ops, int command); int ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs); +int ftrace_startup_subops(struct ftrace_ops *ops, struct ftrace_ops *subop= s, int command); int ftrace_shutdown_subops(struct ftrace_ops *ops, struct ftrace_ops *subo= ps, int command); =20 #else /* !CONFIG_DYNAMIC_FTRACE */ @@ -39,6 +40,14 @@ ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip= , void *regs) { return 1; } +static inline int ftrace_startup_subops(struct ftrace_ops *ops, struct ftr= ace_ops *subops, int command) +{ + return -EINVAL; +} +static inline int ftrace_shutdown_subops(struct ftrace_ops *ops, struct ft= race_ops *subops, int command) +{ + return -EINVAL; +} #endif /* CONFIG_DYNAMIC_FTRACE */ =20 #ifdef CONFIG_FUNCTION_GRAPH_TRACER diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index b37402e3f0c9..8783bebd0562 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1186,7 +1186,6 @@ extern int ftrace_set_filter(struct ftrace_ops *ops, = unsigned char *buf, int len, int reset); extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf, int len, int reset); -extern int ftrace_startup_subops(struct ftrace_ops *ops, struct ftrace_ops= *subops, int command); #else struct ftrace_func_command; =20 --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 3D989197523 for ; Thu, 6 Jun 2024 12:11:01 +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=1717675862; cv=none; b=KvIpcKEmw9LkZYB4eZ3vwRtWBPy6vz/hDjTPL2ePPKJtEx5jHCdQv4CMLb9VGg/X2Cp54MbiRbD2VJTfT3APCoLhtFh7zyxP+L3NWGlqQxPciWX9YUUa+oShZJ1d4gN623M66ykEQyPu3TwarL6o16DLpZAJ2TTiTymu1M5J/oE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675862; c=relaxed/simple; bh=O4Z8RIZmGILc7wFuWKxh23fcOr7gMxekIIMSeGbJnB0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=UgR5RRyGmV5I+ZgGdnUprj/ZOp0NZ9EQ7fe9ylT+W1pN/zII36dlOebTs7C08nlwpXd5xoBDAgL3cSXjur59FJYwDNGMtdDmCj0AECzI8lM6pPqTnQrdtMCjAZKwjGShCpcVjtesfFrrNtqZEX+Dv2Z3KvzasaBmWGe9Wt/QLn8= 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 D8865C4AF5F; Thu, 6 Jun 2024 12:11:01 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxS-00000000nOK-1qO2; Thu, 06 Jun 2024 08:11:06 -0400 Message-ID: <20240606121106.299363966@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:16 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , kernel test robot Subject: [for-next][PATCH 12/15] function_graph: Make fgraph_do_direct static key static References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The static branch key "fgraph_do_direct" was not declared static but is only used in one file. Change it to a static variable. Link: https://lore.kernel.org/linux-trace-kernel/20240605202708.936515302@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Fixes: cc60ee813b503 ("function_graph: Use static_call and branch to optimi= ze entry function") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202406051711.dS1sQZ9n-lkp@int= el.com/ Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/fgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 4bf91eebbb08..63d828054c79 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -515,7 +515,7 @@ static struct fgraph_ops fgraph_stub =3D { static struct fgraph_ops *fgraph_direct_gops =3D &fgraph_stub; DEFINE_STATIC_CALL(fgraph_func, ftrace_graph_entry_stub); DEFINE_STATIC_CALL(fgraph_retfunc, ftrace_graph_ret_stub); -DEFINE_STATIC_KEY_TRUE(fgraph_do_direct); +static DEFINE_STATIC_KEY_TRUE(fgraph_do_direct); =20 /** * ftrace_graph_stop - set to permanently disable function graph tracing --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 612AF19752B for ; Thu, 6 Jun 2024 12:11:02 +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=1717675862; cv=none; b=Vo04ryZySfb2bIMZfrsUDFcD/5F+VjHzF+v7iQ/st2Hp2svLD3w0hDCk9f/r99ValxBnBhcN5iZAKcBWs9RGd5bWS0A1AQs1LfGs7+0TQx38ATctC3D32uAKVTQ2j8XC1B57u1AXCnH1eW7x2Zgq3gjCJzlet8bT+sgkKXRTTYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675862; c=relaxed/simple; bh=Vhl003s+9gkJi2wM8NFrJTGXuCSJLdVofnWPtxpbJjQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=RqzA6lfWzF/wYOQtslY+61qKEAS1eifWq1NcdhKFRqLdgFweDyeOfkVmeA9S5sa3Q/+WOWv72hML5UsZ2RiAWHyRttJdTMmLbzgyA4JaTHsevUWoB3IeLOp4dEu6kdOymGHPSSrmTM5HFUo1//LsHoOWC95se/fHV6YjfIZHIm8= 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 06F37C4AF48; Thu, 6 Jun 2024 12:11:02 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxS-00000000nOp-2WDi; Thu, 06 Jun 2024 08:11:06 -0400 Message-ID: <20240606121106.459468755@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:17 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , kernel test robot Subject: [for-next][PATCH 13/15] function_graph: Do not update pid func if CONFIG_DYNAMIC_FTRACE not enabled References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The ftrace subops is only defined if CONFIG_DYNAMIC_FTRACE is enabled. If it is not, function tracing is extremely limited, and the subops in the ftrace_ops structure is not defined (and will fail to compile). If DYNAMIC_FTRACE is not enabled, then function graph filtering will not work (as it shouldn't). Link: https://lore.kernel.org/linux-trace-kernel/20240605202709.096020676@g= oodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Fixes: df3ec5da6a1e7 ("function_graph: Add pid tracing back to function gra= ph tracer") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202406051855.9VIYXbTB-lkp@int= el.com/ Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/fgraph.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 63d828054c79..c0e428c87ea5 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -1177,6 +1177,7 @@ void fgraph_update_pid_func(void) if (!(graph_ops.flags & FTRACE_OPS_FL_INITIALIZED)) return; =20 +#ifdef CONFIG_DYNAMIC_FTRACE list_for_each_entry(op, &graph_ops.subop_list, list) { if (op->flags & FTRACE_OPS_FL_PID) { gops =3D container_of(op, struct fgraph_ops, ops); @@ -1186,6 +1187,7 @@ void fgraph_update_pid_func(void) static_call_update(fgraph_func, gops->entryfunc); } } +#endif } =20 /* Allocate a return stack for each task */ --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 8906919596A for ; Thu, 6 Jun 2024 12:11:02 +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=1717675862; cv=none; b=bb0bT7myTeadtnomn457TBskuSVUO78gR5S5labj93WXaO0wT34kerxIYOuXcgzBNhKDjfEvOMptJsVBtWYftAtSCg5ufRgUC9Ul4m9apBbUl12Vttf8C+DKPrLtnqBwXPDIriX3I+XX88+FBHLj4iNBKLDOxrPdEeRbBMDuHEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675862; c=relaxed/simple; bh=5LVh91AFmjjDLQKZB1oxRIdLI2t5YNNMCvA9sshgB5Y=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Gfnyp9bVqNkxEDUht9m2YLjW2YUCagpBnRC++Hacye1UuEB6yC31d/430ICcF5+36e/T07OArPqci0bpzhuMQtLeJmeyZZ5he+uAZc0K5VWqzZk1Mjf8nB1+z/ibSkOnzP18KHbP0mS6ZaSwwY+opK761iBTZWslLInBySChG7o= 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 34F9EC4AF68; Thu, 6 Jun 2024 12:11:02 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxS-00000000nPK-3Cmr; Thu, 06 Jun 2024 08:11:06 -0400 Message-ID: <20240606121106.626743588@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:18 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Tatsuya S Subject: [for-next][PATCH 14/15] ftrace: Hide one more entry in stack trace when ftrace_pid is enabled References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tatsuya S On setting set_ftrace_pid, a extra entry generated by ftrace_pid_func() is shown on stack trace(CONFIG_UNWINDER_FRAME_POINTER=3Dy). [004] ..... 68.459382: =3D> 0xffffffffa00090af =3D> ksys_read =3D> __x64_sys_read =3D> x64_sys_call =3D> do_syscall_64 =3D> entry_SYSCALL_64_after_hwframe To resolve this issue, increment skip count in function_stack_trace_call() if pids are set. Link: https://lore.kernel.org/linux-trace-kernel/20240528032604.6813-3-tats= uya.s2862@gmail.com Signed-off-by: Tatsuya S [ Rebased to current tree ] Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_functions.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index 13bf2415245d..3b0cea37e029 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c @@ -231,6 +231,7 @@ function_stack_trace_call(unsigned long ip, unsigned lo= ng parent_ip, long disabled; int cpu; unsigned int trace_ctx; + int skip =3D STACK_SKIP; =20 if (unlikely(!tr->function_enabled)) return; @@ -247,7 +248,11 @@ function_stack_trace_call(unsigned long ip, unsigned l= ong parent_ip, if (likely(disabled =3D=3D 1)) { trace_ctx =3D tracing_gen_ctx_flags(flags); trace_function(tr, ip, parent_ip, trace_ctx); - __trace_stack(tr, trace_ctx, STACK_SKIP); +#ifdef CONFIG_UNWINDER_FRAME_POINTER + if (ftrace_pids_enabled(op)) + skip++; +#endif + __trace_stack(tr, trace_ctx, skip); } =20 atomic_dec(&data->disabled); --=20 2.43.0 From nobody Thu Feb 12 21:49:29 2026 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 673E8197530 for ; Thu, 6 Jun 2024 12:11:02 +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=1717675862; cv=none; b=dEauC0bOOanIzOPvQwdAS2IwosU+i7UhobfNCdmh9Nh9fbJTJmNZEWd9YJRKP303+gXcw6S4oq5q773h95ol4YoSikFdBOAHy7gKqlBtlKQcqHTA0As+yH4piRHNdFWNcKo+W/fNJJ1FtjSgr7pDZR0Bva3jGzmpPg1x10Q5oME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675862; c=relaxed/simple; bh=g5J78wUfojd2WmwHbBCDPFONoHxtPGid/f23v9af9tU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=IyrWECULQKgEydictZUIOz3GKMyGdo9PwPYjRIVT/LvNKU/noyb9Svc4gO4TglCN80y4ajKpyPF7Ecwdrx1QL1TIxrrqC02KkRaEjvsijwS2OKBe64c6INHU326TINNadrhH4PjXmaO5rLg6GAVoDGtH46ApA08756gDVw5js9Y= 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 53B4CC4AF5F; Thu, 6 Jun 2024 12:11:02 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxS-00000000nPp-3rmn; Thu, 06 Jun 2024 08:11:06 -0400 Message-ID: <20240606121106.784134644@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:19 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Abaci Robot , Jiapeng Chong Subject: [for-next][PATCH 15/15] fgraph: Remove some unused functions References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jiapeng Chong These functions are defined in the fgraph.c file, but not called elsewhere, so delete these unused functions. kernel/trace/fgraph.c:273:1: warning: unused function 'set_bitmap_bits'. kernel/trace/fgraph.c:259:19: warning: unused function 'get_fgraph_type'. Link: https://lore.kernel.org/linux-trace-kernel/20240606021053.27783-1-jia= peng.chong@linux.alibaba.com Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=3D9289 Signed-off-by: Jiapeng Chong Signed-off-by: Steven Rostedt (Google) --- kernel/trace/fgraph.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index c0e428c87ea5..a13551a023aa 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -255,12 +255,6 @@ static inline int get_frame_offset(struct task_struct = *t, int offset) return __get_offset(t->ret_stack[offset]); } =20 -/* Get FGRAPH_TYPE from the word from the @offset at ret_stack */ -static inline int get_fgraph_type(struct task_struct *t, int offset) -{ - return __get_type(t->ret_stack[offset]); -} - /* For BITMAP type: get the bitmask from the @offset at ret_stack */ static inline unsigned long get_bitmap_bits(struct task_struct *t, int offset) @@ -268,13 +262,6 @@ get_bitmap_bits(struct task_struct *t, int offset) return (t->ret_stack[offset] >> FGRAPH_INDEX_SHIFT) & FGRAPH_INDEX_MASK; } =20 -/* For BITMAP type: set the bits in the bitmap bitmask at @offset on ret_s= tack */ -static inline void -set_bitmap_bits(struct task_struct *t, int offset, unsigned long bitmap) -{ - t->ret_stack[offset] |=3D (bitmap << FGRAPH_INDEX_SHIFT); -} - /* Write the bitmap to the ret_stack at @offset (does index, offset and bi= tmask) */ static inline void set_bitmap(struct task_struct *t, int offset, unsigned long bitmap) --=20 2.43.0