Skip to contentSkip to conversation

fftw: Fix planner hang on musl with CLOCK_SGI_CYCLE

PATCH In review Khem Raj 2 participants 7 messages Oct 25 – Oct 28

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/6 fftw: Fix planner hang on musl with CLOCK_SGI_CYCLE

musl defines CLOCK_SGI_CYCLE, so on aarch64 cycle.h uses clock_gettime(CLOCK_SGI_CYCLE) as its tick counter. Linux returns EINVAL for that clock, every measurement reads as zero, and FFTW_MEASURE planning loops forever, which times out the bench ptest. Skip the SGI clock on Linux.

AI-Generated: Uses Claude Code

---
 ...-Do-not-use-CLOCK_SGI_CYCLE-on-Linux.patch | 43 +++++++++++++++++++
 meta-oe/recipes-support/fftw/fftw_3.3.11.bb   |  1 +
 2 files changed, 44 insertions(+)
 create mode 100644 meta-oe/recipes-support/fftw/fftw/0001-cycle.h-Do-not-use-CLOCK_SGI_CYCLE-on-Linux.patch
meta-oe/recipes-support/fftw/fftw/0001-cycle.h-Do-not-use-CLOCK_SGI_CYCLE-on-Linux.patch new file +43 -0
new file mode 100644
index 0000000000..ce23ac4377
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sun, 25 Oct 2026 18:30:00 +0100
+Subject: [PATCH] cycle.h: Do not use CLOCK_SGI_CYCLE on Linux
+
+musl's <time.h> defines CLOCK_SGI_CYCLE, so on targets without an
+inline-asm cycle counter ahead of it in cycle.h (e.g. aarch64), FFTW
+picks clock_gettime(CLOCK_SGI_CYCLE) as its tick counter. Linux dropped
+the driver behind that clock id and returns EINVAL, leaving the timespec
+uninitialized. Every measurement then reads as (nearly) zero, so
+X(measure_execution_time) keeps doubling the iteration count and any
+FFTW_MEASURE plan never finishes; the bench --verify ptest hangs.
+
+Skip the SGI clock on Linux, which makes musl fall back to the same
+estimate-only planner glibc uses on these architectures. This also
+avoids the duplicate ticks definition with --enable-armv8-cntvct-el0.
+
+Upstream-Status: Submitted [https://github.com/FFTW/fftw3/pull/430]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ kernel/cycle.h | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/kernel/cycle.h b/kernel/cycle.h
+index 83438bb..960eb90 100644
+--- a/kernel/cycle.h
++++ b/kernel/cycle.h
+@@ -437,8 +437,13 @@ INLINE_ELAPSED(__inline)
+ #define HAVE_TICK_COUNTER
+ #endif
+ /*----------------------------------------------------------------*/
+-/* SGI/Irix */
+-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE) && !defined(HAVE_TICK_COUNTER) && !defined(__ANDROID__)
++/* SGI/Irix
++
++   Linux removed the CLOCK_SGI_CYCLE driver and clock_gettime() fails with
++   EINVAL for it, but musl still defines the constant.  Using it leaves the
++   timespec unset, so every measurement reads as zero and the planner keeps
++   doubling the iteration count forever. */
++#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE) && !defined(HAVE_TICK_COUNTER) && !defined(__ANDROID__) && !defined(__linux__)
+ typedef struct timespec ticks;
+
+ static inline ticks getticks(void)
meta-oe/recipes-support/fftw/fftw_3.3.11.bb +1 -0
index e33d12af10..699ff56979 100644
@@ -7,6 +7,7 @@ SRC_URI = " \
     http://www.fftw.org/fftw-${PV}.tar.gz \
     file://0001-NEON-autodetection-segfaults-assume-neon-present.patch \
     file://install-bench.patch \
+    file://0001-cycle.h-Do-not-use-CLOCK_SGI_CYCLE-on-Linux.patch \
     file://run-ptest \
 "
 SRC_URI[sha256sum] = "5630c24cdeb33b131612f7eb4b1a9934234754f9f388ff8617458d0be6f239a1"
author
#1 lore raw

PATCH 2/6 fuse3: Load the loop driver for the blkdev ptests

mount/blkdev-fsname-hello{,-ll} attach a loop device, but loop is built as a module and was not in the ptest image, so losetup failed. Recommend kernel-module-loop and modprobe it in run-ptest, since it is not loaded on demand when /dev/loop-control has not been created.

AI-Generated: Uses Claude Code

---
 meta-oe/recipes-support/fuse/fuse3/run-ptest | 4 ++++
 meta-oe/recipes-support/fuse/fuse3_3.18.3.bb | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
meta-oe/recipes-support/fuse/fuse3/run-ptest +4 -0
index b8295bbce9..0835402f0a 100644
@@ -7,6 +7,10 @@
 # so print it as is and add the ptest result line after it.
 cd "$(dirname "$0")"
 
+# The mount/blkdev-fsname-* tests attach a loop device, and the loop driver
+# is not loaded on demand when /dev/loop-control has not been created yet.
+modprobe -q loop
+
 # Some test filesystems mirror the real tree but cannot follow symlinks, so
 # keep the run directory off paths like /var/tmp, which is a symlink to
 # volatile/tmp. run-tests.py creates the directory and removes it when done.
meta-oe/recipes-support/fuse/fuse3_3.18.3.bb +1 -1
index 1e4b86a47a..172dd9e69d 100644
@@ -51,7 +51,7 @@ RDEPENDS:${PN}-ptest += " \
     file \
     util-linux-losetup \
 "
-RRECOMMENDS:${PN}-ptest += " kernel-module-cuse"
+RRECOMMENDS:${PN}-ptest += " kernel-module-cuse kernel-module-loop"
 
 do_install_ptest() {
     install -d ${D}${PTEST_PATH}/test
author
#2 lore raw

PATCH 3/6 tbb: Skip test_scheduler_mix in ptest

In reply to Khem Raj

The test hangs intermittently on all architectures and is an open upstream issue, https://github.com/uxlfoundation/oneTBB/issues/1281.
On qemuarm64 musl it hit the ptest-runner timeout.

AI-Generated: Uses Claude Code

---
 meta-oe/recipes-support/tbb/files/run-ptest | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta-oe/recipes-support/tbb/files/run-ptest +3 -1
index 0d11413201..ef14dab437 100755
@@ -2,7 +2,9 @@
 
 # ctest result lines look like: "  1/142 Test   #1: test_tick_count .....   Passed    0.01 sec"
 # anything other than Passed/Skipped/Disabled (Failed, Timeout, Exception, Not Run) is a FAIL
-ctest | awk '/Test +#[0-9]+:/ {
+# test_scheduler_mix hangs intermittently on every architecture
+# https://github.com/uxlfoundation/oneTBB/issues/1281
+ctest -E '^test_scheduler_mix$' | awk '/Test +#[0-9]+:/ {
     if ($0 ~ /Passed/) res = "PASS"
     else if ($0 ~ /Skipped|Disabled/) res = "SKIP"
     else res = "FAIL"
author
#3 lore raw

PATCH 4/6 libgpiod: Show the output of failing tests in ptest log

In reply to Khem Raj

run-ptest wrote each test's output into a file in the image, so an intermittent gpiod-glib-test failure in testimage left nothing to debug. Print the output when a test fails.

---
 meta-oe/recipes-support/libgpiod/libgpiod-2.x/run-ptest | 2 ++
 1 file changed, 2 insertions(+)
meta-oe/recipes-support/libgpiod/libgpiod-2.x/run-ptest +2 -0
index eae172116f..8403102d4d 100644
@@ -20,6 +20,8 @@ run_one_test() {
 
 	./$testbin > ./$testbin.out 2>&1
 	if [ $? -ne 0 ]; then
+		# keep the details of intermittent failures in the ptest log
+		cat ./$testbin.out
 		echo "FAIL: $testbin"
 	else
 		echo "PASS: $testbin"
Reviewed-by on v1 4/6
#4 lore raw

Re: [oe] [meta-oe][PATCH 4/6] libgpiod: Show the output of failing tests in ptest log

Quoted 6 lines · Khem Raj via lists.openembedded.org

run-ptest wrote each test's output into a file in the image, so an intermittent gpiod-glib-test failure in testimage left nothing to debug. Print the output when a test fails.

---

author
#5 lore raw

PATCH 5/6 python3-fsspec: Skip network test in ptest

In reply to Khem Raj

test_async_cat_file_ranges fetches a file from a public S3 bucket, which fails without DNS and internet access on the target, as in sysvinit qemu images where resolv.conf is empty.

AI-Generated: Uses Claude Code

---
 .../recipes-devtools/python/python3-fsspec/run-ptest        | 6 ++++++
 .../recipes-devtools/python/python3-fsspec_2026.9.0.bb      | 2 ++
 2 files changed, 8 insertions(+)
 create mode 100755 meta-python/recipes-devtools/python/python3-fsspec/run-ptest
meta-python/recipes-devtools/python/python3-fsspec/run-ptest new file +6 -0
new file mode 100755
index 0000000000..544881a837
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# test_async_cat_file_ranges fetches a file from a public S3 bucket, so it
+# needs working DNS and internet access from the target.
+pytest --automake \
+    --deselect implementations/tests/test_reference.py::test_async_cat_file_ranges
meta-python/recipes-devtools/python/python3-fsspec_2026.9.0.bb +2 -0
index cacafc88d6..6b2b4c33b1 100644
@@ -6,6 +6,8 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=b38a11bf4dcdfc66307f8515ce1fbaa6"
 SRC_URI = "git://github.com/fsspec/filesystem_spec;protocol=https;branch=master;tag=${PV}"
 SRCREV = "0f76baaae4a227b085b18e8469e6cc1792a95ade"
 
+SRC_URI += "file://run-ptest"
+
 inherit python_hatchling ptest-python-pytest
 
 DEPENDS = "python3-hatch-vcs-native python3-hatchling-native"
author
#6 lore raw

PATCH 6/6 python3-pyzmq: Skip timing sensitive test_retry_poll in ptest

In reply to Khem Raj

The test expects a message sent from another thread 0.2s later to arrive within a 0.5s poll window, which a loaded test host misses. Upstream marks it flaky(reruns=3), but pytest-rerunfailures is not available. Adjust the musl sed to the new end of the -k expression.

AI-Generated: Uses Claude Code

---
 meta-python/recipes-devtools/python/python3-pyzmq/run-ptest | 6 +++++-
 meta-python/recipes-devtools/python/python3-pyzmq_27.2.0.bb | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)
meta-python/recipes-devtools/python/python3-pyzmq/run-ptest +5 -1
index e7e14951c2..bfe76654e4 100644
@@ -7,5 +7,9 @@
 # of exiting 0. Reproduces reliably on target but never locally (isolated,
 # whole-file, or whole-suite runs all pass), consistent with an
 # environment-specific fork-safety issue rather than a logic bug.
+#
+# test_retry_poll expects a message sent 0.2s later by another thread to
+# arrive within a 0.5s poll window; on a loaded host it misses that window.
+# Upstream marks it flaky(reruns=3), which needs pytest-rerunfailures.
 pytest --automake \
--k 'not test_callable_check and not test_on_recv_basic and not test_on_recv_wake and not test_on_recv_async and not test_on_recv_async_error and not test_curve and not test_process_teardown'
+-k 'not test_callable_check and not test_on_recv_basic and not test_on_recv_wake and not test_on_recv_async and not test_on_recv_async_error and not test_curve and not test_process_teardown and not test_retry_poll'
meta-python/recipes-devtools/python/python3-pyzmq_27.2.0.bb +1 -1
index bbce601f3f..4cbf46cf0a 100644
@@ -63,7 +63,7 @@ do_install_ptest() {
 }
 
 do_install_ptest:append:libc-musl() {
-        sed -i -e "s/ and not test_process_teardown'/ and not test_process_teardown and not test_close_all_fds'/" \
+        sed -i -e "s/ and not test_retry_poll'/ and not test_retry_poll and not test_close_all_fds'/" \
             ${D}${PTEST_PATH}/run-ptest
         grep -q "not test_close_all_fds'" ${D}${PTEST_PATH}/run-ptest || bbfatal "failed to skip test_close_all_fds in run-ptest"
 }