[DTrace-devel] [PATCH 3/4] Allow DIFOs to have a variety of flags

Eugene Loh eugene.loh at oracle.com
Fri Jan 15 08:17:22 PST 2021


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

On 01/14/2021 08:30 AM, Kris Van Hees wrote:
> DIFOs could be flagged as containing destructive operations using the
> specific dtdo_destructive field in dtrace_difo_t.  There is a need for
> other flags to be associated with DIFOs, so the dtdo_destructive field
> is being changed into a dtdo_flags field.  DTDOFLG_* constants in
> difo_defines.h provide the flags that can be set and checked for.
>
> Signed-off-by: Kris Van Hees<kris.van.hees at oracle.com>
> ---
>   include/dtrace/difo.h         | 2 +-
>   include/dtrace/difo_defines.h | 5 +++++
>   libdtrace/dt_as.c             | 4 ++--
>   libdtrace/dt_cc.c             | 7 ++++---
>   4 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/include/dtrace/difo.h b/include/dtrace/difo.h
> index 4190bc93..173d0701 100644
> --- a/include/dtrace/difo.h
> +++ b/include/dtrace/difo.h
> @@ -41,7 +41,7 @@ typedef struct dtrace_difo {
>   	uint_t dtdo_varlen;			/* length of variable table */
>   	uint_t dtdo_reclen;			/* length of trace record */
>   	uint_t dtdo_refcnt;			/* owner reference count */
> -	uint_t dtdo_destructive;		/* invokes destructive subroutines */
> +	uint_t dtdo_flags;			/* flags (destructive, ...) */
>   	struct dof_relodesc *dtdo_breltab;	/* BPF relocations */
>   	struct dof_relodesc *dtdo_kreltab;	/* kernel relocations */
>   	struct dof_relodesc *dtdo_ureltab;	/* user relocations */
> diff --git a/include/dtrace/difo_defines.h b/include/dtrace/difo_defines.h
> index b5a0f7a7..cb057182 100644
> --- a/include/dtrace/difo_defines.h
> +++ b/include/dtrace/difo_defines.h
> @@ -17,4 +17,9 @@
>   
>   struct dtrace_difo;
>   
> +/*
> + * DIFO flags.
> + */
> +#define DIFOFLG_DESTRUCTIVE		1	/* Uses destructive ops */
> +
>   #endif /* _DTRACE_DIFO_DEFINES_H */
> diff --git a/libdtrace/dt_as.c b/libdtrace/dt_as.c
> index 86d83298..528714fd 100644
> --- a/libdtrace/dt_as.c
> +++ b/libdtrace/dt_as.c
> @@ -331,7 +331,7 @@ fail:
>   	/*
>   	 * Make a second pass through the instructions, relocating each branch
>   	 * target (a label ID) to the relative location of the label and noting
> -	 * any instruction-specific DIFO flags such as dtdo_destructive.
> +	 * any instruction-specific flags such as DIFOFLG_DESTRUCTIVE.
>   	 */
>   	for (i = 0; i < dp->dtdo_len; i++) {
>   		struct bpf_insn instr = dp->dtdo_buf[i];
> @@ -352,7 +352,7 @@ fail:
>   		if (op == DIF_OP_CALL) {
>   			if (DIF_INSTR_SUBR(instr) == DIF_SUBR_COPYOUT ||
>   			    DIF_INSTR_SUBR(instr) == DIF_SUBR_COPYOUTSTR)
> -				dp->dtdo_destructive = 1;
> +				dp->dtdo_flags |= DIFOFLG_DESTRUCTIVE;
>   			continue;
>   		}
>   #endif
> diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
> index 0f8f7af9..e8865c45 100644
> --- a/libdtrace/dt_cc.c
> +++ b/libdtrace/dt_cc.c
> @@ -135,13 +135,14 @@ dt_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp,
>   #ifdef FIXME
>   /*
>    * Utility function to determine if a given action description is destructive.
> - * The dtdo_destructive bit is set for us by the DIF assembler (see dt_as.c).
> + * The DIFOFLG_DESTRUCTIVE bit is set for us by the DIF assembler (see dt_as.c).
>    */
>   static int
>   dt_action_destructive(const dtrace_actdesc_t *ap)
>   {
> -	return (DTRACEACT_ISDESTRUCTIVE(ap->dtad_kind) || (ap->dtad_kind ==
> -	    DTRACEACT_DIFEXPR && ap->dtad_difo->dtdo_destructive));
> +	return (DTRACEACT_ISDESTRUCTIVE(ap->dtad_kind) ||
> +		(ap->dtad_kind == DTRACEACT_DIFEXPR &&
> +		 (ap->dtad_difo->dtdo_flags & DIFOFLG_DESTRUCTIVE)));
>   }
>   #endif
>   
> -- 2.28.0 _______________________________________________ DTrace-devel 
> mailing list DTrace-devel at oss.oracle.com 
> https://oss.oracle.com/mailman/listinfo/dtrace-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.oracle.com/pipermail/dtrace-devel/attachments/20210115/6d193dfb/attachment.html 


More information about the DTrace-devel mailing list