Bug 2564512

Summary: rocclr 7.1.1 (F44): host memory and HSA signals leak in long-running HIP processes — please backport rocm-systems 839fb957 (PR #1354), bf75609a (PR #4653) and the submission-batch change of 6ec7540e (PR #4671)
Product: [Fedora] Fedora Reporter: Yeongjun Yoon <evenfarther>
Component: rocclrAssignee: Jeremy Newton <alexjnewt>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 44CC: alexjnewt, rocm-packagers-sig
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
URL: https://github.com/ROCm/legacy-rocm-build/issues/6573
Whiteboard:
Fixed In Version: rocclr-7.1.1-5.fc44 Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2026-11-26 01:35:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
PATCH 1/3: backport of rocm-systems 839fb957 (PR #1354) to clr-7.1.1 - signal pool growth in HwQueueTracker::ActiveSignal()
none
PATCH 2/3: backport of rocm-systems bf75609a (PR #4653) to clr-7.1.1 - create the replacement signal with the proper type (applies on top of 1/3)
none
PATCH 3/3: backport of the HostQueue::FlushSubmissionBatch() change of rocm-systems 6ec7540e (PR #4671) to clr-7.1.1 - fixes the synchronous hipMemcpy leak of ROCm/legacy-rocm-build#6573 none

Description Yeongjun Yoon 2026-11-01 04:52:39 UTC
The HIP runtime in Fedora 44 (rocm-hip-7.1.1-3.fc44, libamdhip64.so.7.1.52802) leaks host memory in long-running processes. We found two separate defects, both already fixed upstream in the 7.2 series. We found no environment-variable workaround; DEBUG_CLR_SYSMEM_POOL=0/1 has no effect.

(a) Signal-pool growth in HwQueueTracker::ActiveSignal(). The runtime keeps creating HSA signals and does not release them while the process runs. In the long-running non-graph HIP workloads we tested, host memory grew for the whole run. The growth is in two places: the ROCr signal pool, which grows in doubling /dev/zero (deleted) MAP_SHARED blocks at about 128 B per signal, and the heap, at roughly 250–330 B per signal.

Measured on an AMD Radeon AI PRO R9700 (gfx1201) running a LAMMPS KOKKOS/HIP molecular-dynamics input. The unpatched rows use either the system library or an unpatched rebuild from the Fedora sources; the patched rows use a rebuild with the first two upstream commits:

| runtime | pool growth (MiB/s) | net new signals per MD step | heap in-use growth, from the count shim (MiB/s) |
|---|---:|---:|---:|
| system libamdhip64 7.1.1-3 | 0.640 | — | — |
| unpatched rebuild, no instrumentation | 0.571 | — | — |
| unpatched rebuild, signal-count shim | 0.593 | 18.57 (0 destroyed while running) | 1.216 |
| rebuild with 839fb957 + bf75609a, signal-count shim | 0.000 | 0.000 | 0.001 |
| rebuild with 839fb957 + bf75609a, no instrumentation, 600 s | 0.000 | — | 0 MiB growth |
| rebuild with 839fb957 + bf75609a, 62 min (3753 s steady state) | 0.0 MiB growth of RSS, RssShmem, heap and signal pool | — | — |

The count shim changed the leak rate by less than 4% relative to the uninstrumented run. In these short measurement windows (minutes, not hours) the resident growth (VmRSS) was the signal pool alone, 0.57–0.64 MiB/s (≈ 2.0–2.3 GiB/h); RssAnon did not rise within these windows (presumably because the leaked heap objects first filled already-resident free heap). The leaked heap objects (≈ 1.2 MiB/s in-use, from the shim) would add to that once the free heap is used up, so the long-run total may approach 1.8 MiB/s (≈ 6.4 GiB/h). We did not run an unpatched process to exhaustion.

The same growth appears without any third-party library: a LAMMPS KOKKOS input with a zero-force pair_style soft/kk and neighbor rebuilds every step grew at 2.18 MiB/s. It also appears in a Python/ASE workload (0.64 MiB/s). An allocation-tracking shim attributed 95–98% of the signals alive during the run to the ActiveSignal insert path. That shim slows the process, so we use it only for attribution, not for rates. We identified the location from the MiniDebugInfo symbols in the Fedora binary.

(b) The direct-dispatch submission batch is never drained for synchronous copies. This is the leak reported in ROCm/legacy-rocm-build#6573 (a loop of synchronous host-to-device hipMemcpy of 2 KiB from pageable memory). It is not fixed by the two commits above. With the public reproducer from that issue, 2,000,000 calls per run, one fresh process per runtime:

| runtime | VmData / VmRSS growth (B per call) | [heap] growth (B per call) | ROCr signal pool, at 25% of the run → end |
|---|---:|---:|---|
| system libamdhip64 7.1.1-3 | 931.6 / 975.5 | 950.8 | 136 → 260 MiB |
| unpatched rebuild | 931.6 / 975.5 | — | — |
| rebuild with 839fb957 + bf75609a | 929.2 / 967.5 | 941.5 | 136 → 264 MiB |
| rebuild with 839fb957 + bf75609a + the submission-batch change of 6ec7540e | 0.0 / 0.0 | 0.0 | 12 → 12 MiB (flat) |

Slopes are least-squares fits over the second half of each run (the reproducer's own method for VmData/VmRSS; /proc/<pid>/smaps sampled every second for the heap column). The pool grows in doubling blocks, so we give its size at 25% of the run and at the end instead of a slope. The system and the 839fb957 + bf75609a rows were run in the same session as the last row. For comparison, the runtime from a recent TheRock build (HIP 7.13 or later) also showed 0.0 B per call on this machine.

Root cause (already fixed upstream):

(a) rocm-7.1.0 added || !signal_list_[temp_id]->flags_.done_ to the "+2" look-ahead in HwQueueTracker::ActiveSignal(). In the rocm-7.1.1 tarball this is rocclr/device/rocm/rocvirtual.cpp:440-443, introduced by "clr: Optimize doorbell ring", PR #1030. In 7.1.x, done_ becomes true only when the host waits on a signal that is still busy (CpuWaitForSignal) or when the signal's timestamp is processed. A signal that the GPU finished before any host wait therefore never becomes reusable. Once such a signal sits at the +2 position, every later ActiveSignal() call inserts a new signal in front of it, and the list never shrinks until the queue is destroyed.

- rocm-systems 839fb957 ("clr: Do not increase signal pool", PR #1354, merged 2025-10-24, in rocm-7.2.0) removes the clause.
- rocm-systems bf75609a ("Create the new signal of proper type during the signal swap", PR #4653, merged to develop 2026-04-02; the same change reached the 7.2 release branch as part of 6ec7540e, below, and is in rocm-7.2.2) fixes a second, related problem in the same function: a replacement signal was created with the wrong interrupt type. In our workload this second problem did not contribute to the measured growth (analysis). We include it because it is the follow-up fix in the same function and both are in rocm-7.2.2.

(b) Command::enqueue() calls FlushSubmissionBatch(this) once the direct-dispatch batch exceeds DEBUG_CLR_MAX_BATCH_SIZE (1000). In 7.1.1 that only calls notifyCmdQueue() on the current command, and in HIP notifyCmdQueue() returns without doing anything when the command already has a HW event. A synchronous copy always has one, and HostQueue::finishCommand() waits only on that HW signal. In a loop of synchronous copies nothing drains the batch, so every WriteMemoryCommand stays alive together with its ProfilingSignal. Because those older commands still hold their signals, ActiveSignal() allocates a new ProfilingSignal and a new HSA signal for each reused ring slot. By our reading of the source, each call leaves one command (about 690 B), one ProfilingSignal (about 175 B) and one HSA signal behind; together about 865 B, which roughly accounts for the measured ~950 B of heap per call (allocator overhead not counted), while the HSA signals account for the signal-pool growth.

- rocm-systems 6ec7540e (PR #4671, merged into release/rocm-rel-7.2) changes HostQueue::FlushSubmissionBatch() to enqueue a dedicated internal marker once the batch is over the limit; the marker's completion handler updates and releases the whole batch regardless of the HW-event state of the last command. The commit is in the rocm-7.2.2 and rocm-7.2.4 tags and not in rocm-7.2.0 or rocm-7.2.1.
- AMD reproduced the synchronous-hipMemcpy leak with ROCm 7.1.1 in ROCm/legacy-rocm-build#6573 and, after a bisection, attributed the fix to PR #1354 (naming PR #2471 as a follow-up performance improvement). In our tests, 7.1.1 with #1354 (and #4653) still leaks at the same rate with that reproducer; adding the submission-batch change from #4671 removes the leak. We cannot reconstruct the bisection, so we only report what we measured. That issue was closed as fixed in later releases and "unlikely to be backported to 7.1.1". Related (closed) reports: ROCm/legacy-rocm-build#5915, #5921 and #5948 (GROMACS).
- Rawhide is at rocclr 10.1.0, which is based on a ROCm release that already contains 839fb957 and bf75609a. We did not check whether it contains the change from 6ec7540e, and we did not test the rawhide build itself.
- The newest F44 build we found, rocclr-7.1.1-4.fc44 (testing), applies four patches in %prep: the three from -3 plus 0001-clr-remove-__noinline__-keyword.patch. None of them is any of the three fixes.

Version-Release number of selected component:
rocm-hip-7.1.1-3.fc44 (from rocclr-7.1.1-3.fc44.src.rpm); also checked: rocclr-7.1.1-4.fc44 (testing). rocm-runtime-7.1.1-6.fc44, kernel 7.2.11-200.fc44.x86_64, GPU gfx1201.

Reproducible: Always

Steps to Reproduce:
1. Build the minimal reproducer attached to ROCm/legacy-rocm-build#6573 (a loop of synchronous host-to-device hipMemcpy of 2 KiB) with the system hipcc, e.g. hipcc -O2 -std=c++17 --offload-arch=gfx1201 hipleak-minimal.hip -lamdhip64 -o hipleak-minimal. On Fedora 44 the explicit -lamdhip64 is needed; without it the link fails with undefined hipMalloc/hipMemcpy.
2. Run it with its defaults (./hipleak-minimal 2000000 25000). It prints its own VmData/VmRSS slope per call. To see the signal pool as well, sample the process; RssShmem and the summed Rss of the /dev/zero (deleted) mappings track the ROCr signal pool, for example:
   ./hipleak-minimal 2000000 25000 > out.csv & PID=$!
   while kill -0 $PID 2>/dev/null; do
     grep -E '^(VmRSS|RssAnon|RssShmem):' /proc/$PID/status
     awk '/\/dev\/zero \(deleted\)/{z=1;next} /^[0-9a-f]+-[0-9a-f]+ /{z=0} z&&/^Rss:/{s+=$2} END{print "dev_zero_Rss_kB", s+0}' /proc/$PID/smaps
     sleep 10
   done
3. Repeat with LD_LIBRARY_PATH pointing to a libamdhip64.so.7 rebuilt from the same Fedora sources with the three attached patches. With only patches 1–2 the reproducer still leaks; with all three it does not.
Actual Results:
With the system library the reproducer grows by 931.6 B per call (VmData) and 975.5 B per call (VmRSS), the same value AMD reported for 7.1.1, and the ROCr signal pool keeps growing. With our LAMMPS workload, see table (a) above.

Expected Results:
Memory stays flat after warm-up, as it does with the three patches applied (table (b), last row) and with the TheRock runtime.

Additional Information:
- We rebuilt only libamdhip64.so.7 from the Fedora rocclr-7.1.1 sources. The tarball matched the SHA512 in the Fedora sources file. The build used the same three patches as -3 and the cmake options from the Koji build log. One build had no further changes, one added patches 1–2, and one added patches 1–3.
  - All three patches apply to the clr-7.1.1 tarball layout with -p1 --fuzz=0, in order. Patches 1–2 change only rocclr/device/rocm/rocvirtual.cpp; patch 3 changes only rocclr/platform/commandqueue.hpp, commandqueue.cpp and command.cpp. Patch 3 did not change the exported symbol set of the library.
  - Patch 3 is not a literal cherry-pick of 6ec7540e. Its parent on the release branch had intermediate code that 7.1.1 does not have, so we ported the final HostQueue::FlushSubmissionBatch() behaviour as it appears in rocm-7.2.4. 6ec7540e also carries a rocvirtual.cpp hunk equivalent to bf75609a, which patch 2 already covers.
  - With patches 1–2, MD throughput was unchanged: median patched/unpatched ratio 1.004 and 0.997 over three fresh-process pairs each, for two input configurations. In single-run microbenchmarks (p50, patched minus unpatched), empty-queue synchronization and 4-byte copies changed by −0.14 to +0.12 µs; some 32 KiB copies changed by up to +3.2 µs, which we did not repeat.
  - With patches 1–3 vs 1–2 (same LAMMPS input, fresh-process pairs): a first short check with three pairs in alternating order gave a median ratio of 1.003 (pair ratios 1.029, 0.977 and 1.003). The process that ran second was always faster, so that check did not meet our pre-set criterion that every pair stays at or above 0.98. We then re-measured with a longer warm-up and four pairs in balanced order (AB, BA, BA, AB). The first such run was inconclusive because one trial failed our stability check. In the repeat all four pairs were valid: the balanced (geometric-mean) ratio was 0.995 (pair ratios 0.984, 0.995, 0.997 and 1.003), within our pre-set non-loss bound of 0.99. Memory growth was zero with both libraries in every run. On this input the balanced estimate is about 0.5% slower with patch 3, within our pre-set 1% non-loss bound; we do not claim that patch 3 is performance-neutral.
  - Results were not bit-identical between runs even with the same library, because the application sums forces with atomics. They were within our tolerances.
- Scope of our testing: non-graph HIP use only (LAMMPS KOKKOS/HIP, a Python workload and the #6573 reproducer). Upstream also has a follow-up to the signal-pool change, "Fixed performance regression due to the increase of the signal pool" (PR #2470 on develop, PR #2471 on release/rocm-rel-7.2; AMD names #2471 in #6573 as a follow-up performance improvement to #1354). We did not backport or test it; with patches 1–2 alone we saw no throughput loss on our inputs (see above). Upstream later also changed the same code paths for hipGraph plus profiling (e.g. PRs #2084 and #2108). Please judge whether F44 should take only these minimal changes or also the follow-ups; a rebase to a newer release would also resolve it.
- Attachments: the three backported patches (rebased to the 7.1.1 tarball paths) and links to the upstream commits.
- Prepared with the help of AI coding tools.

Comment 1 Yeongjun Yoon 2026-11-01 04:55:08 UTC
Created attachment 2162684 [details]
PATCH 1/3: backport of rocm-systems 839fb957 (PR #1354) to clr-7.1.1 - signal pool growth in HwQueueTracker::ActiveSignal()

Comment 2 Yeongjun Yoon 2026-11-01 04:55:47 UTC
Created attachment 2162685 [details]
PATCH 2/3: backport of rocm-systems bf75609a (PR #4653) to clr-7.1.1 - create the replacement signal with the proper type (applies on top of 1/3)

Comment 3 Yeongjun Yoon 2026-11-01 04:56:16 UTC
Created attachment 2162686 [details]
PATCH 3/3: backport of the HostQueue::FlushSubmissionBatch() change of rocm-systems 6ec7540e (PR #4671) to clr-7.1.1 - fixes the synchronous hipMemcpy leak of ROCm/legacy-rocm-build#6573

Comment 4 Fedora Update System 2026-11-17 04:38:32 UTC
FEDORA-2026-41bf0549f4 (rocclr-7.1.1-5.fc44) has been submitted as an update to Fedora 44.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-41bf0549f4

Comment 5 Fedora Update System 2026-11-18 03:26:10 UTC
FEDORA-2026-41bf0549f4 has been pushed to the Fedora 44 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2026-41bf0549f4`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2026-41bf0549f4

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 6 Fedora Update System 2026-11-26 01:35:21 UTC
FEDORA-2026-41bf0549f4 (rocclr-7.1.1-5.fc44) has been pushed to the Fedora 44 stable repository.
If problem still persists, please make note of it in this bug report.