Re: [PATCH v4 2/2] selftests/x86/amx: Test dynamic fpstate cleanup across exec()
From: Guixiong Wei
Date: Sun Nov 08 2026 - 08:20:26 EST
> From: "Chang S. Bae"<chang.seok.bae@xxxxxxxxx>
> Date: Sat, Nov 7, 2026, 00:41
> Subject: Re: [PATCH v4 2/2] selftests/x86/amx: Test dynamic fpstate cleanup across exec()
> To: "Guixiong Wei"<weiguixiong@xxxxxxxxxxxxx>, <x86@xxxxxxxxxx>
> Cc: "Thomas Gleixner"<tglx@xxxxxxxxxx>, "Ingo Molnar"<mingo@xxxxxxxxxx>, "Borislav Petkov"<bp@xxxxxxxxx>, "Dave Hansen"<dave.hansen@xxxxxxxxxxxxxxx>, "H . Peter Anvin"<hpa@xxxxxxxxx>, "Chang S . Bae"<chang.seok.bae@xxxxxxxxx>, "Shuah Khan"<shuah@xxxxxxxxxx>, <linux-kernel@xxxxxxxxxxxxxxx>, <linux-kselftest@xxxxxxxxxxxxxxx>
> On 11/2/26 02:30, Guixiong Wei wrote:
> > ---
> > tools/testing/selftests/x86/amx.c | 251 +++++++++++++++++++++++++++++-
> > 1 file changed, 249 insertions(+), 2 deletions(-)
> >
>
> The code looks an overkill to me. I also considered using kmemleak, but
> this vmallocinfo looks to be efficient.
>
> The other way would be adding a script on top of a small change to amx.c
> file. See the attachment.
>
> Can you please try running this on your side and see if it works?
>
> PS: I sent this yesterday but it didn't go through. I switched *.sh to
> *.txt in the attachment.
>
> Thanks,
> Chang
>
Hi Chang,
Thanks for the suggestion and the test patch. The AMX -> exec reproducer
does exercise the leaking path and was useful for validating the fix.
I tested it on an Intel Xeon 6519P-C system with AMX support.
On the unfixed kernel, three runs of 10 execs each consistently
increased the __xfd_enable_feature allocations by 10 entries / 163840
bytes per run.
With the updated fix applied to v7.3-rc5:
- three runs of 10 execs: no increase
- one run of 1000 execs: no increase
- 24 concurrent workers, 500 execs each: no increase
- the existing AMX selftest still passed
I noticed a few issues in the test harness itself:
1. test_exec() waits for the child but does not check WIFEXITED() or
WEXITSTATUS(), so a failed exec can still be reported as success.
2. $NUM_ITERATION in the single-quoted awk program is interpreted as
an awk field reference, not the shell variable. It needs to be
passed with -v, for example:
awk -v iterations="$NUM_ITERATION" '... iterations ...'
3. amx_exec.sh prints "[FAIL]" for a detected leak but still exits
with status 0.
4. Failures while collecting /proc/vmallocinfo or running amx_64 can
be converted into "[OK] no memory leak".
So the reproducer idea looks good to me, while the harness needs the above fixes.
Thanks,
Guixiong