[DTrace-devel] [PATCH v4 2/7] cg: bump number of TSLOTS to 6

Kris Van Hees kris.van.hees at oracle.com
Thu Jul 10 04:46:15 UTC 2025


Stay tuned for a patch I will post tomorrow (Thursday) with an optimization
for the ternary operator for strings that will reduce the use of tstrings
quite a bit.  With that optimization, the test you added for nested ternaries
still won't use more than 4 slots.

In the future though we should change the tstring handling to dynamically
determine the max number of slots needed for the compiled code, and allocate
based on that rather than having a hard limit.

On Wed, Jul 09, 2025 at 03:46:55PM +0100, Alan Maguire via DTrace-devel wrote:
> Because of the ternary operations using inet_ntoa*() in the
> TCP translators more temporary string slots are needed.
> 
> Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
> ---
>  libdtrace/dt_impl.h | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libdtrace/dt_impl.h b/libdtrace/dt_impl.h
> index 2adc1252..a47b6d40 100644
> --- a/libdtrace/dt_impl.h
> +++ b/libdtrace/dt_impl.h
> @@ -203,14 +203,16 @@ typedef struct dt_kern_path {
>  #define DT_DM_KERN_UNLOADED	0x8	/* module not loaded into the kernel */
>  
>  /*
> - * Why do we need (only) 4 slots?  The maximum amount of string arguments to
> + * Why do we need 6 slots?  The maximum amount of string arguments to
>   * any function is 2, and if the result is a string as well, that means we may
>   * need 3 temporary strings during code generation for that function.
> + * However if operations like inet_ntoa6 are used in ternary operations we need 
> + * 2x the number of slots for left and right.
>   *
>   * Since string functions can be nested, we can (at most) end up with 1 tstring
>   * (from a nested function for which we already generated code) along with a
>   * nested function being processed which needs 3 temporary strings as mentioned
> - * above.  That brings us to a total of 4.
> + * above.
>   *
>   * Each tstring needs to be large enough to hold the largest possible string
>   * and accomodate the largest known need for tstring space in subroutines.
> @@ -222,7 +224,7 @@ typedef struct dt_kern_path {
>   * - cleanpath() holds a prepended '/' char, a string, an appended '/' char,
>   *   and a terminating NUL char, or STRSZ + 3 chars altogether
>   */
> -#define DT_TSTRING_SLOTS	4
> +#define DT_TSTRING_SLOTS	6
>  #define DT_TSTRING_SIZE(dtp)	\
>  		MAX(P2ROUNDUP((dtp)->dt_options[DTRACEOPT_STRSIZE] + 3, 8), \
>  		    72)
> -- 
> 2.39.3
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list