From: Kris Van Hees <kris.van.hees@oracle.com>
To: Kris Van Hees <kris.van.hees@oracle.com>
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH v2] test: account for member name change in mm_struct
Date: Tue, 10 Feb 2026 12:26:34 -0500 [thread overview]
Message-ID: <aYtqSth5OjHleE+f@oracle.com> (raw)
In-Reply-To: <DS0PR10MB752267259322167083A85C80C262A@DS0PR10MB7522.namprd10.prod.outlook.com>
Woops, forgot to add the change to dtrace.spec. v3 coming
On Tue, Feb 10, 2026 at 11:48:51AM -0500, Kris Van Hees 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.
>
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
> .../arrays/tst.ctf-dynsized-bounds-runtime.d | 25 -----------
> .../arrays/tst.ctf-dynsized-bounds-runtime.sh | 43 +++++++++++++++++++
> 2 files changed, 43 insertions(+), 25 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/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
> +# test will need a new structure to work with.
> +# are out of luck.
> +
> +# 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; }'`
> +
> +
> +# 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 $?
> --
> 2.51.0
>
prev parent reply other threads:[~2026-02-10 20:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 16:48 [PATCH v2] test: account for member name change in mm_struct Kris Van Hees
2026-02-10 17:26 ` Kris Van Hees [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=aYtqSth5OjHleE+f@oracle.com \
--to=kris.van.hees@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
/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