Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1015632lqj; Mon, 3 Jun 2024 07:51:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4UxpjwGZ0egvJh9s8/DkAAHlC4e4oJ9OeQshx229cK5tUTtvpqxyk2p3uMPFfbeQGWeU9ocn+fa6EQTfhix6oO+jqDnvmfvjzCkLKyQ== X-Google-Smtp-Source: AGHT+IGrKEn2JGwRDiAusF/qNrS2CRMdktZevw34bkQUJW7eZG1gGxX9jkZZUrSbZPUrE3+lyag5 X-Received: by 2002:a17:906:1645:b0:a5c:e9e4:99b8 with SMTP id a640c23a62f3a-a682234d032mr610439466b.74.1717426318478; Mon, 03 Jun 2024 07:51:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717426318; cv=pass; d=google.com; s=arc-20160816; b=EglC7rpoVRzAxayOC9mDw+rjMiAufeUaNLQU+oovWOkmYzadRGDlKDvodGPUY9HYQ2 2FhSlfRNUuB9Vf5NvKxGzspenxEOZ5u3ww6a+RSUk4G5zm25tqzHqbSle5QKjXhLzGhd HcQfE1jMUzdtw9N0sAqkCYXVZ/kBaeH8t1AAyR0yDuU/H+XkDtM4WdMw8yzU+1mxEQO+ /dvHagW5i4dpnnm5t7WZNweZabAOhFD3N4LdY87cYA33LM797uHIxghe6fRL1ObzMLD7 JTS0VzW49+pCJorVU/h+xIAxRL4Dju58i0KLskJF79Q/BINTiRgHuVNjaY9zj50eZZNH UpyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=eUG/+cfccM+abZpn4vw3odnV6zJ2t3FGxvr8JzGc0KU=; fh=CONbk9IM1KeoX7M3ojYzAuH3rM9roTZPm7jJ9UBDXA8=; b=ILoU6dhuSh9Kp5XD0gX2dOIHUeM7mKOYSQ3GkgJ8zplVhQKV4v9FVXamqD9HhjwrWF SVwVypCVLRVXcTjAy5dwBhLd97rYG1/Dm0fg2KCZGXT79AgPflhTSoPIgYF38kCSYRPM eDHV5K7IFSLv0SN4ibsOxrXX5dMg7BGmbChS8ZiMOrLczp9TxHrLBfrw432hs3+1b2Tt DAu65/zSDOcFpTnUiI5OSoZiivaC4/lvbaxel4eFt84A2NA9BYnYrNr+UVmMCF1UYbWg ExrYbhLSkjoOdehFCRnOg7aj0adJR/einFkIEehHKBifXU6vVjw14edBN9QwiA2ipTy0 obVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-199317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199317-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a686342afcdsi359904866b.967.2024.06.03.07.51.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 07:51:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-199317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199317-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 31F281F22F95 for ; Mon, 3 Jun 2024 14:51:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B52CA12FF70; Mon, 3 Jun 2024 14:51:48 +0000 (UTC) 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 3696426AD5; Mon, 3 Jun 2024 14:51:47 +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=1717426308; cv=none; b=YEZTsF7fynYMri1aMZHdwx/LhCeGq1zg+FJlx6TEPNQeM5mjKGwtw830xEUtszhtnfsT29bWD9G+oZ/5VewSKOWnNFT0KZ7a9b42AbsYyKSEhSrWqrtJr2wTeqfYobUzwcoUOiEIsAAsFG6qOxJrmZ0azk8IitQGgNS9Rl4N8Po= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717426308; c=relaxed/simple; bh=ca60k8sUpBG2JQiZ8IbblhTHdpHysARDcXRKjwBesDY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BpmcYU3BBHYlwy7vJzza/szz4dcMX/mouapImVsXlg3Enp0PXORTEIuicEd26v7ndT5/7y49u86abSvlFSrwv6JQHF3NKjaSuK44Kpx6Fc7NGa504IRecDzH80fH04+y94egcVxaMXO4mT/f8sC2HgkziiTUlgC6RczdNhEoU0Y= 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 59847C2BD10; Mon, 3 Jun 2024 14:51:42 +0000 (UTC) Date: Mon, 3 Jun 2024 10:52:50 -0400 From: Steven Rostedt To: "Masami Hiramatsu (Google)" Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Mark Rutland , Mathieu Desnoyers , Andrew Morton , Alexei Starovoitov , Florent Revest , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Peter Zijlstra , Thomas Gleixner , Guo Ren Subject: Re: [PATCH v2 11/27] ftrace: Allow subops filtering to be modified Message-ID: <20240603105250.52ea24f2@gandalf.local.home> In-Reply-To: <20240603113723.b192c8c346e0ed55cb94b61a@kernel.org> References: <20240602033744.563858532@goodmis.org> <20240602033832.870736657@goodmis.org> <20240603113723.b192c8c346e0ed55cb94b61a@kernel.org> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 3 Jun 2024 11:37:23 +0900 Masami Hiramatsu (Google) wrote: > On Sat, 01 Jun 2024 23:37:55 -0400 > Steven Rostedt wrote: > > [...] > > > > +static int ftrace_hash_move_and_update_subops(struct ftrace_ops *subops, > > + struct ftrace_hash **orig_subhash, > > + struct ftrace_hash *hash, > > + int enable) > > +{ > > + struct ftrace_ops *ops = subops->managed; > > + struct ftrace_hash **orig_hash; > > + struct ftrace_hash *save_hash; > > + struct ftrace_hash *new_hash; > > + int ret; > > + > > + /* Manager ops can not be subops (yet) */ > > + if (WARN_ON_ONCE(!ops || ops->flags & FTRACE_OPS_FL_SUBOP)) > > + return -EINVAL; > > This does return if ops->flags & FTRACE_OPS_FL_SUBOP, but --> (1) Yes, because what is passed in is "subops" and "ops" is subops->managed. > > > + > > + /* Move the new hash over to the subops hash */ > > + save_hash = *orig_subhash; > > + *orig_subhash = __ftrace_hash_move(hash); > > + if (!*orig_subhash) { > > + *orig_subhash = save_hash; > > + return -ENOMEM; > > + } > > + > > + /* Create a new_hash to hold the ops new functions */ > > + if (enable) { > > + orig_hash = &ops->func_hash->filter_hash; > > + new_hash = append_hashes(ops); > > + } else { > > + orig_hash = &ops->func_hash->notrace_hash; > > + new_hash = intersect_hashes(ops); > > + } > > + > > + /* Move the hash over to the new hash */ > > + ret = ftrace_hash_move_and_update_ops(ops, orig_hash, new_hash, enable); > > This also a bit wired to me. maybe we need simple version like > > `__ftrace_hash_move_and_update_ops()` > > And call it from ftrace_hash_move_and_update_ops() and here? We could do that. I almost did due to other issues but I reworked the code where I didn't need to. > > > + > > + free_ftrace_hash(new_hash); > > + > > + if (ret) { > > + /* Put back the original hash */ > > + free_ftrace_hash_rcu(*orig_subhash); > > + *orig_subhash = save_hash; > > + } else { > > + free_ftrace_hash_rcu(save_hash); > > + } > > + return ret; > > +} > > + > > + > > static u64 ftrace_update_time; > > unsigned long ftrace_update_tot_cnt; > > unsigned long ftrace_number_of_pages; > > @@ -4770,8 +4823,33 @@ static int ftrace_hash_move_and_update_ops(struct ftrace_ops *ops, > > { > > struct ftrace_ops_hash old_hash_ops; > > struct ftrace_hash *old_hash; > > + struct ftrace_ops *op; > > int ret; > > > > + if (ops->flags & FTRACE_OPS_FL_SUBOP) > > + return ftrace_hash_move_and_update_subops(ops, orig_hash, hash, enable); > > (1) This calls ftrace_hash_move_and_update_subops() if ops->flags & FTRACE_OPS_FL_SUBOP ? Yes, because ops turns into subops, and the ops above it is its manager ops. -- Steve