Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp551953lqt; Thu, 6 Jun 2024 10:56:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVStzMIQ6aDC0Pvt9R05Vqd4l0kYdBDiKJJET/A8+lE8rDjk4UpQsh1+KUSVZz/8VutUjkbxL6uNGtKYcaRlk/9ZtZBaslItL5va1aB8g== X-Google-Smtp-Source: AGHT+IHeaHP4XPreorLUzQj0Hb0/5RXgM1d9sjmeM4E3o3zIiEVENI1JzSO2/Vt1RfiaHdeTHOfj X-Received: by 2002:a05:6214:4b0d:b0:6af:3d64:3421 with SMTP id 6a1803df08f44-6b059b6ef5amr3632506d6.7.1717696594705; Thu, 06 Jun 2024 10:56:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717696594; cv=pass; d=google.com; s=arc-20160816; b=PvSDOb+apeXxHiqs7dJJssQTch1OC6AnVY0JXMr+SxJqyd7iRGkzBfzrKhdxQ3s55p E+SukpJoeYrVAM+Ybwp9HkZQ2KF26NOv5sjp5tc0xvUx1t7VA7c3w1md936kwYxuiter wS9aeXFPWfAt+9CmixV8ITF5KAu4oRkWCdrwwAWC5Klm8EpqWb6nRcvdE3/8sEVcVP7c DduEcth19LN7Szuper8w6rSqTebuT9AvKplWlaAaWTqAQA/JLlHS66IJ1CDXOZ8VwXVl wIJikysuArcIfMXkaVzdnm9G8GFiy8TBvERiaQ7DgoVkexJNhrjr1ju3X7y2u/3v36Bc gRvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=flC/dPtngBHBTbtSDjsa3tKYjUn0+ScJRE8vOwTHqG4=; fh=D7vGFCemkZDU34ZWTdMMgxTv/fBH8o6Jqms0Kr1Z2d4=; b=fWqfaMCSloJkVSql8sP873OyJ9Z/nwfiwQ2Qy17sG9gW4Ioyk3jWpV59SunMqfX4T6 neCW4wDbdo1FRuEN1Jr9vNnmnGii5FDIMgpPiyov2a6SdxGR8IjODXOmYA9FIWRDA31f X+IHY0oSPC/uz/2Ks/3d5zVzALOWBnXjs+J86sEHT0Wn4RcyMhEuIajJbRuuRrEPTlDw epP19+SkyVVq4KbU81XQRzaGMTY6sop96RLkTetnlc/FnDidTd5WR+bqfn3ti9fFqEX/ CbHm/i2ty5wMiOHTgl8uf8mwVuui5zf24yM6p+AtlnLWCCwTJetWqtPCktLo55XRRSvz SOCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-204844-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204844-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b04f632013si11333826d6.46.2024.06.06.10.56.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 10:56:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204844-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-204844-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204844-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6DDE21C2742A for ; Thu, 6 Jun 2024 17:56:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03951199246; Thu, 6 Jun 2024 17:56:29 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 085A7197A8F; Thu, 6 Jun 2024 17:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717696588; cv=none; b=L5o1uPiTrSgVmfhx11aKSzjkOYqnFQ19NlPmzv8sh+IjppborJhu+DkiK6g5M5eMJFwGA7CCddIsAFuJ0GEnEyTfG1yprM5X5OCX+QXtSZMW6LEhADjPPG6WAND/oeNVooYo81ojByuOCmuoTnydN8/qwD/M3oyRgCn8VyBtja8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717696588; c=relaxed/simple; bh=f95TZ836Ou9FDPwMEm5IByJ1EjN0UoHTi7twP5cFKMc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fyTPwHfUVjLV0uuXs80v/0TTAj9lKV2ZETBmKI8pNxlpj1Xzqk/8QmXZtT13N0xjTQu7fkaNc9oq3zYSurQf/dV0H0B5oAnj/wbe0nUSxelIKmJSGZx393XyPPrjxqNY5oarF4uXBx12rkbWcjFUQgQXuBllbAxTeEEqb8M1ukc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0329A2F4; Thu, 6 Jun 2024 10:56:51 -0700 (PDT) Received: from J2N7QTR9R3.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9F4483F64C; Thu, 6 Jun 2024 10:56:25 -0700 (PDT) Date: Thu, 6 Jun 2024 18:56:23 +0100 From: Mark Rutland To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Masami Hiramatsu , Mathieu Desnoyers , Andrew Morton Subject: Re: [PATCH v2 5/5] ftrace: Add comments to ftrace_hash_move() and friends Message-ID: References: <20240605180334.090848865@goodmis.org> <20240605180409.179520305@goodmis.org> 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-Disposition: inline In-Reply-To: <20240605180409.179520305@goodmis.org> On Wed, Jun 05, 2024 at 02:03:39PM -0400, Steven Rostedt wrote: > 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) Acked-by: Mark Rutland Mark. > --- > 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 83f23f8fc26d..ae1603e771c5 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) > @@ -1429,6 +1430,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) > { > @@ -1443,6 +1445,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) > -- > 2.43.0 > >