From: Eugene Loh <eugene.loh@oracle.com>
To: Kris Van Hees <kris.van.hees@oracle.com>,
dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [DTrace-devel] [PATCH v3] test: account for member name change in mm_struct
Date: Tue, 10 Feb 2026 13:39:25 -0500 [thread overview]
Message-ID: <cf9a29c8-e86a-5293-dc85-189ee7a0239a@oracle.com> (raw)
In-Reply-To: <DS0PR10MB7522BEBEF1650BD20A9A7214C262A@DS0PR10MB7522.namprd10.prod.outlook.com>
A few minor comments:
On 2/10/26 12:35, Kris Van Hees via DTrace-devel wrote:
> The flexible array at the end of the mm_struct has changed name in newer
> kernels. Rather than depending on a particular name, we can simply get
> the name of the last member (since that is there the flexible array is
> always found) and try to use that.
>
> The testsuite gains a dependency on bpftool for this test.
>
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
> dtrace.spec | 2 +-
> .../arrays/tst.ctf-dynsized-bounds-runtime.d | 25 -----------
> .../arrays/tst.ctf-dynsized-bounds-runtime.sh | 43 +++++++++++++++++++
> 3 files changed, 44 insertions(+), 26 deletions(-)
> delete mode 100644 test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d
> create mode 100755 test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh
>
> diff --git a/dtrace.spec b/dtrace.spec
> index d6af5a80..e0d832ac 100644
> --- a/dtrace.spec
> +++ b/dtrace.spec
> @@ -115,7 +115,7 @@ Requires: %{name}-devel = %{version}-%{release} perl gcc java
> Requires: java-devel perl-IO-Socket-IP perl-Net-Ping xfsprogs
> Requires: exportfs vim-minimal %{name}%{?_isa} = %{version}-%{release}
> Requires: coreutils wireshark %{glibc32}
> -Requires: time bc nfs-utils
> +Requires: time bc nfs-utils bpftool
> Suggests: kernel-uek-tools
> Autoreq: 0
> Group: Development/System
> diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d
> deleted file mode 100644
> index f3801454..00000000
> --- a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -/*
> - * Oracle Linux DTrace.
> - * Copyright (c) 2023, 2024, 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.
> - */
> -
> -/*
> - * ASSERTION: Array accesses work for CTF-declared arrays of dynamic size
> - * (ensuring the bounds checking is also bypassed at runtime).
> - *
> - * SECTION: Pointers and Arrays/Array Declarations and Storage
> - */
> -
> -BEGIN
> -{
> - i = pid - pid; /* Non-constant 0 value. */
> - trace(curthread->mm->cpu_bitmap[i]);
> - exit(0);
> -}
> -
> -ERROR
> -{
> - exit(1);
> -}
> diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh
> new file mode 100755
> index 00000000..60fe6afc
> --- /dev/null
> +++ b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh
> @@ -0,0 +1,43 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2023, 2026, 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.
> +
> +# ASSERTION: Array accesses work for CTF-declared arrays of dynamic size
> +# (ensuring the bounds checking is also bypassed at runtime).
> +#
> +# SECTION: Pointers and Arrays/Array Declarations and Storage
> +
> +dtrace=$1
> +
> +# The mm_struct 'cpu_bitmap' was renamed to 'flexible_array', so we need to
> +# see which member name the current kernel uses. Since it is always the last
> +# member of mm_struct, we just use that member name, and hope for the best.
> +# If mm_struct ever gets changed to not have a flesible array at its end, this
s/flesible/flexible/
> +# test will need a new structure to work with.
> +# are out of luck.
/are out of luck/d
> +
> +# Determine the member name we should use.
> +member=`bpftool btf dump id 1 | \
> + awk '/^\[[0-9]+\] STRUCT \047mm_struct\047/ { in_mm = 1; next; }
> + /^\t/ && in_mm { fld = $1; gsub(/\047/, "", fld); next }
> + /^\[[0-9]+\] [A-Z]+ \047/ && in_mm { print fld; exit; }'`
The search for the end of STRUCT looks for [A-Z]+, but could there be a
'_' in there? E.g., for "FUNC_PROTO"?
> +
> +
> +# Try to access the flexible array.
> +$dtrace $dt_flags -qn "
> +BEGIN
> +{
> + i = pid - pid; /* non-constant 0 value */
> + v = curthread->mm->$member[i];
> + exit(0);
> +}
> +
> +ERROR
> +{
> + exit(1);
> +}"
> +
> +echo $?
prev parent reply other threads:[~2026-02-10 20:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 17:35 [PATCH v3] test: account for member name change in mm_struct Kris Van Hees
2026-02-10 18:39 ` Eugene Loh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cf9a29c8-e86a-5293-dc85-189ee7a0239a@oracle.com \
--to=eugene.loh@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
--cc=kris.van.hees@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox