[DTrace-devel] [PATCH] test: ensure processes are ready for tracing in tst.manypids.tst

Nick Alcock nick.alcock at oracle.com
Fri Mar 8 15:33:12 UTC 2024


On 8 Mar 2024, Kris Van Hees via DTrace-devel outgrape:

> This tests depends on preloading a lot of libraries which can cause the

s/tests/test/

> task startup to be slower than expected.  As a result, dtrace may fail
> to enable probes.  This is typically the case if the preload libraries
> and executable are not in cache yet.
>
> We explicitly invoke /usr/bin/sleep right before starting the tasks to
> be traced to prime the cache.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>

Reviewed-by: Nick Alcock <nick.alcock at oracle.com>

> ---
>  test/unittest/pid/tst.manypids.sh | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/test/unittest/pid/tst.manypids.sh b/test/unittest/pid/tst.manypids.sh
> index 1a98d621..5ae3a4c5 100755
> --- a/test/unittest/pid/tst.manypids.sh
> +++ b/test/unittest/pid/tst.manypids.sh
> @@ -20,6 +20,10 @@ for lib in `ls -1 /lib64/lib*.so.1 | grep -v libthread_db.so.1`; do
>  done
>  
>  export LD_PRELOAD=$preload
> +# Force libraries and executable to get pulled into the cache so that starting
> +# the disowned processes in the loop below will go fast enough that by the time
> +# dtrace is started, all tasks are ready to be traced.
> +/usr/bin/sleep 1

Good call on the /usr/bin too.

(And because it's not backgrounded, we don't need to worry if *it* has
done its job.)

You might want to do a sleep 0, though -- it's worked for a very long
time, longer than coreutils has existed under that name.)

-- 
NULL && (void)



More information about the DTrace-devel mailing list