All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: eugene.loh@oracle.com
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH 07/38] Clean up prp/pprp/uprp variable names
Date: Thu, 18 Jul 2024 14:48:53 -0400	[thread overview]
Message-ID: <ZpljlXz/cG60B2WK@oracle.com> (raw)
In-Reply-To: <20240627053455.21567-8-eugene.loh@oracle.com>

On Thu, Jun 27, 2024 at 01:34:24AM -0400, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
> 
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> ---
>  libdtrace/dt_prov_uprobe.c | 83 +++++++++++++++++++++++++-------------
>  1 file changed, 55 insertions(+), 28 deletions(-)
> 
> diff --git a/libdtrace/dt_prov_uprobe.c b/libdtrace/dt_prov_uprobe.c
> index afc1f628..c77063a8 100644
> --- a/libdtrace/dt_prov_uprobe.c
> +++ b/libdtrace/dt_prov_uprobe.c
> @@ -6,6 +6,31 @@
>   *
>   * The uprobe-based provider for DTrace (implementing pid and USDT providers).
>   */
> +/*
> + * This file uses both overlying probes (specified by the user) as well as
> + * underlying probes (the uprobes recognized by the kernel).  To minimize
> + * confusion, this file should use consistent variable names:
> + *
> + *     dt_probe_t	*prp;   //  overlying probe
> + *     dt_probe_t	*uprp;  // underlying probe
> + *
> + *             Either one might be returned by dt_probe_lookup() or
> + *             dt_probe_insert() or added to dt_enablings[] or dt_probes[].
> + *             Further, uprp might be returned by create_underlying().
> + *
> + *     dt_uprobe_t	*upp;   // uprobe associated with an underlying probe
> + *
> + *     list_probe_t	*pop;   //  overlying probe list
> + *     list_probe_t	*pup;   // underlying probe list
> + *
> + * The provider-specific prv_data has these meanings:
> + *
> + *     prp->prv_data            // dt_list_t of associated underlying probes
> + *
> + *     uprp->prv_data           // upp (the associated uprobe)
> + *
> + * Finally, note that upp->probes is a dt_list_t of overlying probes.
> + */

As mentioned in my earlier review, I truly believe that this comment block is
not necessary because the code changes includes in the patch accomplish what
is described here and I think that sets up enough of a precedent/example that
future changes in code should stick to that naming pattern.  No need for an
explicit comment block to highlight that.

>  #include <sys/types.h>
>  #include <assert.h>
>  #include <errno.h>
> @@ -118,7 +143,7 @@ static dt_probe_t *create_underlying(dtrace_hdl_t *dtp,
>  	char			mod[DTRACE_MODNAMELEN];
>  	char			prb[DTRACE_NAMELEN];
>  	dtrace_probedesc_t	pd;
> -	dt_probe_t		*prp;
> +	dt_probe_t		*uprp;
>  	dt_uprobe_t		*upp;
>  	int			is_enabled = 0;
>  
> @@ -160,8 +185,8 @@ static dt_probe_t *create_underlying(dtrace_hdl_t *dtp,
>  	pd.fun = psp->pps_fun;
>  	pd.prb = prb;
>  
> -	prp = dt_probe_lookup(dtp, &pd);
> -	if (prp == NULL) {
> +	uprp = dt_probe_lookup(dtp, &pd);
> +	if (uprp == NULL) {
>  		dt_provider_t	*pvp;
>  
>  		/* Get the provider for underlying probes. */
> @@ -182,12 +207,12 @@ static dt_probe_t *create_underlying(dtrace_hdl_t *dtp,
>  		if (upp->tp == NULL)
>  			goto fail;
>  
> -		prp = dt_probe_insert(dtp, pvp, pd.prv, pd.mod, pd.fun, pd.prb,
> +		uprp = dt_probe_insert(dtp, pvp, pd.prv, pd.mod, pd.fun, pd.prb,
>  				      upp);
> -		if (prp == NULL)
> +		if (uprp == NULL)
>  			goto fail;
>  	} else
> -		upp = prp->prv_data;
> +		upp = uprp->prv_data;
>  
>  	switch (psp->pps_type) {
>  	case DTPPT_RETURN:
> @@ -202,7 +227,7 @@ static dt_probe_t *create_underlying(dtrace_hdl_t *dtp,
>  	     */
>  	}
>  
> -	return prp;
> +	return uprp;
>  
>  fail:
>  	probe_destroy(dtp, upp);
> @@ -259,7 +284,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
>  	}
>  
>  	/*
> -	 * Underlying and overlying probe list entries.
> +	 * Overlying and underlying probe list entries.
>  	 */
>  	pop = dt_zalloc(dtp, sizeof(list_probe_t));
>  	if (pop == NULL)
> @@ -271,7 +296,10 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
>  		return -1;
>  	}
>  
> -	/* Add the pid probe, if we need to. */
> +	/*
> +	 * Add the underlying probe to the list of probes for the overlying probe,
> +	 * adding the overlying probe if we need to.
> +	 */
>  
>  	pup->probe = uprp;
>  	if (prp == NULL)
> @@ -286,11 +314,10 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
>  		return -1;
>  	}
>  
> -	pop->probe = prp;
> -
>  	/*
> -	 * Add the pid probe to the list of probes for the underlying probe.
> +	 * Add the overlying probe to the list of probes for the underlying probe.
>  	 */
> +	pop->probe = prp;
>  	dt_list_append(&upp->probes, pop);
>  
>  	return 0;
> @@ -394,8 +421,8 @@ static void enable_usdt(dtrace_hdl_t *dtp, dt_probe_t *prp)
>  static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
>  {
>  	dt_irlist_t		*dlp = &pcb->pcb_ir;
> -	const dt_probe_t	*prp = pcb->pcb_probe;
> -	const dt_uprobe_t	*upp = prp->prv_data;
> +	const dt_probe_t	*uprp = pcb->pcb_probe;
> +	const dt_uprobe_t	*upp = uprp->prv_data;
>  	const list_probe_t	*pop;
>  	uint_t			lbl_exit = pcb->pcb_exitlbl;
>  
> @@ -441,15 +468,15 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
>  	 */
>  	for (pop = dt_list_next(&upp->probes); pop != NULL;
>  	     pop = dt_list_next(pop)) {
> -		const dt_probe_t	*pprp = pop->probe;
> +		const dt_probe_t	*prp = pop->probe;
>  		uint_t			lbl_next = dt_irlist_label(dlp);
>  		pid_t			pid;
>  		dt_ident_t		*idp;
>  
> -		pid = dt_pid_get_pid(pprp->desc, pcb->pcb_hdl, pcb, NULL);
> +		pid = dt_pid_get_pid(prp->desc, pcb->pcb_hdl, pcb, NULL);
>  		assert(pid != -1);
>  
> -		idp = dt_dlib_add_probe_var(pcb->pcb_hdl, pprp);
> +		idp = dt_dlib_add_probe_var(pcb->pcb_hdl, prp);
>  		assert(idp != NULL);
>  
>  		/*
> @@ -457,8 +484,8 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
>  		 * process, and emit a sequence of clauses for it when it does.
>  		 */
>  		emit(dlp,  BPF_BRANCH_IMM(BPF_JNE, BPF_REG_0, pid, lbl_next));
> -		emite(dlp, BPF_STORE_IMM(BPF_W, BPF_REG_7, DMST_PRID, pprp->desc->id), idp);
> -		dt_cg_tramp_call_clauses(pcb, pprp, DT_ACTIVITY_ACTIVE);
> +		emite(dlp, BPF_STORE_IMM(BPF_W, BPF_REG_7, DMST_PRID, prp->desc->id), idp);
> +		dt_cg_tramp_call_clauses(pcb, prp, DT_ACTIVITY_ACTIVE);
>  		emit(dlp,  BPF_JUMP(lbl_exit));
>  		emitl(dlp, lbl_next,
>  			   BPF_NOP());
> @@ -508,8 +535,8 @@ copyout_val(dt_pcb_t *pcb, uint_t lbl, uint32_t val, int arg)
>  static int trampoline_is_enabled(dt_pcb_t *pcb, uint_t exitlbl)
>  {
>  	dt_irlist_t		*dlp = &pcb->pcb_ir;
> -	const dt_probe_t	*prp = pcb->pcb_probe;
> -	const dt_uprobe_t	*upp = prp->prv_data;
> +	const dt_probe_t	*uprp = pcb->pcb_probe;
> +	const dt_uprobe_t	*upp = uprp->prv_data;
>  	const list_probe_t	*pop;
>  	uint_t			lbl_assign = dt_irlist_label(dlp);
>  	uint_t			lbl_exit = pcb->pcb_exitlbl;
> @@ -561,14 +588,14 @@ static int trampoline_is_enabled(dt_pcb_t *pcb, uint_t exitlbl)
>  	 */
>  	for (pop = dt_list_next(&upp->probes); pop != NULL;
>  	     pop = dt_list_next(pop)) {
> -		const dt_probe_t	*pprp = pop->probe;
> +		const dt_probe_t	*prp = pop->probe;
>  		pid_t			pid;
>  		dt_ident_t		*idp;
>  
> -		pid = dt_pid_get_pid(pprp->desc, pcb->pcb_hdl, pcb, NULL);
> +		pid = dt_pid_get_pid(prp->desc, pcb->pcb_hdl, pcb, NULL);
>  		assert(pid != -1);
>  
> -		idp = dt_dlib_add_probe_var(pcb->pcb_hdl, pprp);
> +		idp = dt_dlib_add_probe_var(pcb->pcb_hdl, prp);
>  		assert(idp != NULL);
>  
>  		/*
> @@ -636,9 +663,9 @@ out:
>  	return name;
>  }
>  
> -static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
> +static int attach(dtrace_hdl_t *dtp, const dt_probe_t *uprp, int bpf_fd)
>  {
> -	dt_uprobe_t	*upp = prp->prv_data;
> +	dt_uprobe_t	*upp = uprp->prv_data;
>  	tp_probe_t	*tpp = upp->tp;
>  	FILE		*f;
>  	char		*fn;
> @@ -733,9 +760,9 @@ out:
>   * probes that didn't get created.  If the removal fails for some reason we are
>   * out of luck - fortunately it is not harmful to the system as a whole.
>   */
> -static void detach(dtrace_hdl_t *dtp, const dt_probe_t *prp)
> +static void detach(dtrace_hdl_t *dtp, const dt_probe_t *uprp)
>  {
> -	dt_uprobe_t	*upp = prp->prv_data;
> +	dt_uprobe_t	*upp = uprp->prv_data;
>  	tp_probe_t	*tpp = upp->tp;
>  
>  	if (!dt_tp_has_info(tpp))
> -- 
> 2.18.4
> 

  reply	other threads:[~2024-07-18 18:49 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-27  5:34 eugene.loh
2024-06-27  5:34 ` [PATCH 01/38] Move comment closer to the code it describes eugene.loh
2024-06-27  5:34 ` [PATCH 02/38] Move dt_spec_buf_data_t and dt_spec_buf_t into dt_consume.c eugene.loh
2024-07-18  6:54   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 03/38] Get rid of apparently orphaned status[2] eugene.loh
2024-07-18  6:59   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 04/38] Get rid of apparently orphaned bufdesc stuff eugene.loh
2024-07-18 18:28   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 05/38] Get rid of unneeded enabling_defines.h eugene.loh
2024-07-18 18:35   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 06/38] Get rid of unused dtrace_repldesc_t eugene.loh
2024-07-18 18:34   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 07/38] Clean up prp/pprp/uprp variable names eugene.loh
2024-07-18 18:48   ` Kris Van Hees [this message]
2024-07-18 20:19     ` Eugene Loh
2024-06-27  5:34 ` [PATCH 08/38] Fix comment in dt_probe.c eugene.loh
2024-07-18 18:49   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 09/38] Fix comments that hardwire DBUF_ offsets eugene.loh
2024-07-18 19:04   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 10/38] Fix comments in dt_cg.c eugene.loh
2024-07-18 19:28   ` Kris Van Hees
2024-07-18 20:29     ` Eugene Loh
2024-06-27  5:34 ` [PATCH 11/38] USDT module names may contain dots; but forbid "." and ".." names eugene.loh
2024-07-18 19:23   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 12/38] USDT module names may contain dots; remove incorrect check eugene.loh
2024-07-18 19:24   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 13/38] Hide dtrace_actdesc_t until it is needed eugene.loh
2024-07-18 20:02   ` Kris Van Hees
2024-07-18 21:06     ` Eugene Loh
2024-07-18 21:28       ` Kris Van Hees
2024-07-18 22:36         ` Eugene Loh
2024-06-27  5:34 ` [PATCH 14/38] Remove orphaned dtrace_hdl_t component dt_maxformat eugene.loh
2024-07-18 20:03   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 15/38] Remove orphaned dtrace_hdl_t component dt_prov_usdt eugene.loh
2024-07-18 20:03   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 16/38] Move dt_probe_clause_t to be available outside of dt_probe.c eugene.loh
2024-07-18 20:19   ` Kris Van Hees
2024-06-27  5:34 ` [PATCH 17/38] Add a provider-specific probe_add_clause handle eugene.loh
2024-07-18 20:49   ` Kris Van Hees
2024-07-19  4:00     ` Eugene Loh
2024-06-27  5:34 ` [PATCH 18/38] Add a provider-specific probe_add_clause for underlying probes eugene.loh
2024-07-18 20:50   ` Kris Van Hees
2024-07-19  4:00     ` Eugene Loh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZpljlXz/cG60B2WK@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    --cc=eugene.loh@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.