[DTrace-devel] [PATCH] Set the lockmem limit to "unlimited" by default

Kris Van Hees kris.van.hees at oracle.com
Mon Feb 12 04:39:19 UTC 2024


On Sun, Feb 11, 2024 at 10:22:20PM -0500, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Commit d5a2077d ("Locked-memory limit") described the importance of
> setting the locked-memory limit appropriately for DTrace, but it put
> that burden on users, admittedly providing several mechanisms to do so.
> 
> Commit 7e159efa ("Forbid setting lockmem value with a pragma") eliminated
> one such mechanism.

Since you are providing a very verbose commit message, I think you should
then also mention *why* the pragma mechanism was eliminated.  Otherwise it
seems an almost arbitrary change that (based on the following paragraph)
was actually used by users, and that certainly isn't a true reflection of
the situation.

> That pragma mechanism, however, had proven to be a popular way of
> constructing D scripts that could run both under legacy DTrace, which
> does not recognize the lockmem option, and DTrace on Linux, which
> essentially requires the option.  That is, the mechanism allowed a
> script to set the pragma conditionally based on DTrace version.
> 
> Further, it is difficult to size the amount of locked memory needed,
> and so users end up just routinely setting the limit to "unlimited."
> 
> While there are good reasons not to change resource limits quietly, the
> usability issues around lockmem have become nuisances.
> 
> Therefore, continue to support the lockmem option, but change the default
> behavior to set the lockmem limit to "unlimited."
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  libdtrace/dt_open.c                      |  5 +++--
>  test/unittest/misc/tst.lockmem-cmdline.r |  9 +++------
>  test/unittest/misc/tst.lockmem-cmdline.x | 16 ----------------
>  3 files changed, 6 insertions(+), 24 deletions(-)
>  delete mode 100755 test/unittest/misc/tst.lockmem-cmdline.x
> 
> diff --git a/libdtrace/dt_open.c b/libdtrace/dt_open.c
> index 708f1f50..9970750a 100644
> --- a/libdtrace/dt_open.c
> +++ b/libdtrace/dt_open.c
> @@ -1187,9 +1187,10 @@ dtrace_init(dtrace_hdl_t *dtp)
>  	dt_dlib_init(dtp);
>  
>  	/*
> -	 * Set the locked-memory limit if so directed by the user.
> +	 * Set the locked-memory limit.  Use the user-specified value
> +	 * if set.  Otherwise, set lockmem to "unlimited".
>  	 */
> -        if (lockmem != DTRACEOPT_UNSET) {
> +        if (lockmem != DTRACEOPT_UNSET || (lockmem = RLIM_INFINITY)) {

I would prefer not to introduce a side effect in the conditional expression
when it is easy enough to just make this:

	if (lockmem == DTRACEOPT_UNSET)
		lockmem = RLIM_INFINITY;

and then change the following code to simply always set the resource limit
using lockmem.

>  		struct rlimit	rl;
>  
>  		rl.rlim_cur = rl.rlim_max = lockmem;
> diff --git a/test/unittest/misc/tst.lockmem-cmdline.r b/test/unittest/misc/tst.lockmem-cmdline.r
> index 537d655d..a2d5ad5f 100644
> --- a/test/unittest/misc/tst.lockmem-cmdline.r
> +++ b/test/unittest/misc/tst.lockmem-cmdline.r
> @@ -1,12 +1,9 @@
> -1
>  
>               1234
>  0
>  
>               1234
>  0
> --- @@stderr --
> -dtrace: could not enable tracing: failed to create BPF map 'state':
> -	The kernel locked-memory limit is possibly too low.  Set a
> -	higher limit with the DTrace option '-xlockmem=N'.  Or, use
> -	'ulimit -l N' (Kbytes).  Or, make N the string 'unlimited'.
> +
> +             1234
> +0
> diff --git a/test/unittest/misc/tst.lockmem-cmdline.x b/test/unittest/misc/tst.lockmem-cmdline.x
> deleted file mode 100755
> index a779416b..00000000
> --- a/test/unittest/misc/tst.lockmem-cmdline.x
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -#!/bin/bash
> -
> -read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
> -
> -if [ $MAJOR -lt 5 ]; then
> -        exit 0
> -fi
> -if [ $MAJOR -eq 5 -a $MINOR -lt 15 ]; then
> -        exit 0
> -fi
> -
> -# Somehow, UEKR6 (5.4.17) has problems with the the locked-memory limit,
> -# but UEKR7 (5.15.0) does not
> -
> -echo "no locked-memory limit on newer kernels?"
> -exit 1
> -- 
> 2.18.4
> 
> 
> _______________________________________________
> 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