Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1269352lqj; Mon, 3 Jun 2024 16:12:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvirCbnRTXzC1w9UTQ4n1g/1jUbdTgyJzqlxLjtppxEtNI/kE37qpt4I0fYNJ1CY22xIkjl60c9fn4Rg1bA+SEiwrDmxwPNcQeLER9qg== X-Google-Smtp-Source: AGHT+IGvlHkdvDhhRBmGyxNYhWAzL1bTB7kOOdHH6JRbvBbmpf907T/7kd8FJmTx8oiHl4d4NXJQ X-Received: by 2002:a2e:82d6:0:b0:2ea:8ff7:8c52 with SMTP id 38308e7fff4ca-2ea950e5497mr66541821fa.13.1717456367384; Mon, 03 Jun 2024 16:12:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717456367; cv=pass; d=google.com; s=arc-20160816; b=jvN+qcPy5iJhYu0THwPjBpRzxs8cj0K+Q0Kkt4PhRq3fB/V83z6fEbJyLkWQHRgPUG MS+3M5TtTHfUqOUixdGbxXznzGCcTR/rM2XAwhQ5xUoKldUY+z51KxdMN7RxGlsMCHnt XNX3Uo1/OG8lvhnzCvxyIUcLIadQ+vQrbp8Cx0tKua0ydK6F/sIqoa+R/jqsFmaBXp/A P2xFttBi82TYD9CtWDzTP2jk0/X32pPBEpzzzl3rSUpia2uKzsT8DzgKBf09nvG3YmQo 4+hIf2jQm/lJuSKyipuMl5DTgdaK4ZHW6P+1vA5JC4ZmgkolBehCh5QYqdVYdm9HxgFB jRGA== 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:dkim-signature; bh=mDuh6BdMSY0tkmj0UJ4sWaHINa1esjOkI8ucXG2+GwA=; fh=NSnYj6tpGinFvTJElM5X+45jOrnS9GbogdcRlOg2Gnw=; b=VVHaUlnk7gXSVL1KnOrDJfKQTEhQUFswhTNBQO0cW8f2vm5qnErdQAvZcjeTspsQk/ AvGoO653EqheuBfpSiVrviw4+6PGPMF+fWdjymndXLfU0opf93z+/RnfHPK2fSv362La mRIp4mSzRtGPWxCNu+7ysW+4h9YWr1wCJBo7Bp8yQd3fv1X4M6qaDudQ9eytHiXn1ilE l290PBDFIP8HYGRJs85v1bSLkTS/OkpWF47nVCsdA83mw8scdIT5TZghvE97R4MkxROa LHImDNfH3U/OK6gt1aCwxFuhVN5DaiCEy1/DUpyGAJF5zEq8inN94BCefRji56+4d0cq aksQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ca6KCx7a; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199811-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31ba669fsi4470871a12.143.2024.06.03.16.12.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 16:12:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ca6KCx7a; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199811-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 E5A391F24E4D for ; Mon, 3 Jun 2024 23:12:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92E5B13CFAD; Mon, 3 Jun 2024 23:12:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ca6KCx7a" 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 B416982D9C; Mon, 3 Jun 2024 23:12:37 +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=1717456357; cv=none; b=aSzCBKbLISftVEzSFAOI1qEfb5oechzVEU+TwIIbaA2VF59YkaYD9FxP3JAM95looKhJJe/Icop4XRWsW6GbRb6JUbrxEmmhc3BOXVoXHc9IiEscIxcbf6AJ5Dn8KM3bRWjcMolRfCv55LFnaKrEb+GcHX8eRxG+eC4oOeD1sp8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717456357; c=relaxed/simple; bh=jlMa/1KQP8AgPUAWk/zBkqIn2aacp2s+DjgzIqxPWDQ=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=XK5R+MCyeKBhePV18DG+ncJlb6a1nb8o16IrUvmsG/xRa5sq4SyGE3QYC3Wg8a3KQimcAeorhVnZIEu2YwlLiFEE8ZD40Voqwi9tqXx+WzR3Wp3Njzg1RWhxt+2Odhszz/ibrW28jvc8JG7/aV5wLnqtLPiBu5N8nXxzqAAu1Dw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ca6KCx7a; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3704FC2BD10; Mon, 3 Jun 2024 23:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717456357; bh=jlMa/1KQP8AgPUAWk/zBkqIn2aacp2s+DjgzIqxPWDQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ca6KCx7aqJRwWApIMM8vrwvbTX4Ut/P0HwSeC/htl1BQTTajA27H4YD7Z+Xaoet7A sO5FwBevKqVeMkVJG6gSMVKADMrcXl5hBmZ+mW75wj3y1UB83Ft15FRaTDhBo/MYBG Zs/0CKWlEhzYsta8V/LGbJWpeV1IFM69VGHixhji+61vB5H2TfqJxtWiMJOGq0nDnR gbvDZV+Ze4dC4w8SbhjmhSYIdyMjtMLXwsH/F5m6EB61cWL06S2w/5Dic5ohwnWBY6 5aJ6jJFO1GfkS4lYrITdQaV4xdo36T/QqgfhMcHjGfwZGKikYlg7eO/2WSTJ2YnmvQ ZM/TEkwCNZgTw== Date: Tue, 4 Jun 2024 08:12:29 +0900 From: Masami Hiramatsu (Google) To: Steven Rostedt 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: <20240604081229.8d80bee75a29663f3b61322d@kernel.org> In-Reply-To: <20240603105250.52ea24f2@gandalf.local.home> References: <20240602033744.563858532@goodmis.org> <20240602033832.870736657@goodmis.org> <20240603113723.b192c8c346e0ed55cb94b61a@kernel.org> <20240603105250.52ea24f2@gandalf.local.home> X-Mailer: Sylpheed 3.7.0 (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 10:52:50 -0400 Steven Rostedt wrote: > 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. Ah, I missed that point. OK, I got it. > > > > > > + > > > + /* 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); So this `ops` is managed ops of this subops. > > > > 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. Ah, OK. This `ops` is a subops. Thank you, > > -- Steve > -- Masami Hiramatsu (Google)