[DTrace-devel] [PATCH] Forbid setting lockmem value with a pragma
Kris Van Hees
kris.van.hees at oracle.com
Fri Jan 26 05:46:20 UTC 2024
On Thu, Dec 14, 2023 at 05:13:38PM -0500, eugene.loh at oracle.com wrote:
>
> With commit
> 5a12c51c983f "options: ensure lockmem is set before retrieving probe info",
> lockmem is set early. Therefore, forbid setting its value in a pragma and
> modify the associated test.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
> libdtrace/dt_options.c | 3 +++
> test/unittest/misc/err.lockmem-pragma.r | 2 ++
> test/unittest/misc/err.lockmem-pragma.sh | 19 +++++++++++++++++
> test/unittest/misc/tst.lockmem-pragma.r | 23 --------------------
> test/unittest/misc/tst.lockmem-pragma.sh | 27 ------------------------
> test/unittest/misc/tst.lockmem-pragma.x | 16 --------------
> 6 files changed, 24 insertions(+), 66 deletions(-)
> create mode 100644 test/unittest/misc/err.lockmem-pragma.r
> create mode 100755 test/unittest/misc/err.lockmem-pragma.sh
> delete mode 100644 test/unittest/misc/tst.lockmem-pragma.r
> delete mode 100755 test/unittest/misc/tst.lockmem-pragma.sh
> delete mode 100755 test/unittest/misc/tst.lockmem-pragma.x
>
> diff --git a/libdtrace/dt_options.c b/libdtrace/dt_options.c
> index 33995a6f..00926882 100644
> --- a/libdtrace/dt_options.c
> +++ b/libdtrace/dt_options.c
> @@ -762,6 +762,9 @@ dt_opt_size(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
> static int
> dt_opt_lockmem(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
> {
> + if (dtp->dt_pcb != NULL)
> + return dt_set_errno(dtp, EDT_BADOPTCTX);
> +
> if (arg == NULL)
> return dt_set_errno(dtp, EDT_BADOPTVAL);
>
> diff --git a/test/unittest/misc/err.lockmem-pragma.r b/test/unittest/misc/err.lockmem-pragma.r
> new file mode 100644
> index 00000000..595ae65e
> --- /dev/null
> +++ b/test/unittest/misc/err.lockmem-pragma.r
> @@ -0,0 +1,2 @@
> +-- @@stderr --
> +dtrace: failed to compile script /dev/stdin: line 1: failed to set option 'lockmem' to '1': Option cannot be used from within a D program
> diff --git a/test/unittest/misc/err.lockmem-pragma.sh b/test/unittest/misc/err.lockmem-pragma.sh
> new file mode 100755
> index 00000000..0b7bba26
> --- /dev/null
> +++ b/test/unittest/misc/err.lockmem-pragma.sh
> @@ -0,0 +1,19 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
> +# Licensed under the Universal Permissive License v 1.0 as shown at
> +# http://oss.oracle.com/licenses/upl.
> +#
> +# @@nosort
> +
> +dtrace=$1
> +
> +$dtrace -qs /dev/stdin << EOF
> +#pragma D option lockmem=1
> +
> +BEGIN
> +{
> + exit(0);
> +}
> +EOF
> diff --git a/test/unittest/misc/tst.lockmem-pragma.r b/test/unittest/misc/tst.lockmem-pragma.r
> deleted file mode 100644
> index 29917922..00000000
> --- a/test/unittest/misc/tst.lockmem-pragma.r
> +++ /dev/null
> @@ -1,23 +0,0 @@
> -1
> -1
> -
> - 1234
> -0
> -
> - 1234
> -0
> -
> - 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'.
> -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'.
> diff --git a/test/unittest/misc/tst.lockmem-pragma.sh b/test/unittest/misc/tst.lockmem-pragma.sh
> deleted file mode 100755
> index 74d0ed15..00000000
> --- a/test/unittest/misc/tst.lockmem-pragma.sh
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -#!/bin/bash
> -#
> -# Oracle Linux DTrace.
> -# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
> -# Licensed under the Universal Permissive License v 1.0 as shown at
> -# http://oss.oracle.com/licenses/upl.
> -#
> -# @@nosort
> -
> -dtrace=$1
> -
> -ulimit -l 1
> -
> -for val in 16 1K 268435456K 262144M 256G unlimited; do
> - $dtrace -qs /dev/stdin << EOF
> - #pragma D option lockmem=$val
> -
> - BEGIN
> - {
> - @ = avg(1234);
> - exit(0);
> - }
> -EOF
> - echo $?
> -done
> -
> -exit 0
> diff --git a/test/unittest/misc/tst.lockmem-pragma.x b/test/unittest/misc/tst.lockmem-pragma.x
> deleted file mode 100755
> index a779416b..00000000
> --- a/test/unittest/misc/tst.lockmem-pragma.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
>
>
More information about the DTrace-devel
mailing list