From: Clark Williams <clrkwllms@kernel.org>
To: linux-rt-users@vger.kernel.org
Cc: Derek Barbosa <debarbos@redhat.com>,
Clark Williams <clrkwllms@kernel.org>,
Clark Williams <williams@redhat.com>,
wander@redhat.com, marco.chiappero@suse.com,
chris.friesen@windriver.com, luochunsheng@ustc.edu
Subject: [PATCH 10/12] Makefile: Add support for legacy kernels
Date: Thu, 16 Oct 2025 21:24:42 -0500 [thread overview]
Message-ID: <20251017022444.118802-10-clrkwllms@kernel.org> (raw)
In-Reply-To: <20251017022444.118802-1-clrkwllms@kernel.org>
From: Derek Barbosa <debarbos@redhat.com>
In the sched_debug backend code, we conditionally parse the running
tasks block of the sched_debug file to support the older task format (as
denoted by OLD_TASK_FORMAT).
This task format is only present on legacy 3.X kernels. However, on said
legacy kernels, the current Makefile directives and #if macros in the
stalld.c code do not fully support compilation of stalld.
Add a LEGACY check to the makefile, which parses `uname -r` output for
the major kernel version, and adds a LEGACY compilation flag to the
CFLAGS. Use the compilation flag to default to sched_debug_backend in
the stalld.c file to avoid missing references to the queue_track code.
Also, disable Intel CET -fcf-protection and BPF support, remove
annocheck targets, and default to the c99 compiler (if present).
Signed-off-by: Derek Barbosa <debarbos@redhat.com>
Signed-off-by: Clark Williams <clrkwllms@kernel.org>
Signed-off-by: Clark Williams <williams@redhat.com>
---
Makefile | 40 +++++++++++++++++++++++++++++++++++++++-
src/stalld.c | 6 ++++--
2 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 7234a46976aa..c09d5743b696 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,14 @@ ARCH=$(shell uname -m)
endif
$(info ARCH=$(ARCH))
+LEGACY_VER := 3
+ifeq ($(strip $(KERNEL_VER)),)
+KERNEL_VER=$(shell uname -r | cut -f 1 -d .)
+endif
+$(info Kernel Major Version is $(KERNEL_VER))
+
+IS_LEGACY:= $(shell test $(KERNEL_VER) -le $(LEGACY_VER) && echo "true" || echo "false")
+
USE_BPF := 1
FCF_PROTECTION := -fcf-protection
MTUNE := -mtune=generic
@@ -33,6 +41,10 @@ ifeq ($(ARCH),powerpc)
USE_BPF := 0
MTUNE := -mtune=powerpc
endif
+ifeq ($(IS_LEGACY),true)
+USE_BPF := 0
+FCF_PROTECTION :=
+endif
$(info USE_BPF=$(USE_BPF))
$(info FCF_PROTECTION=$(FCF_PROTECTION))
@@ -57,6 +69,7 @@ DEFS := -DUSE_BPF=$(USE_BPF) -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS -DDEBUG_S
# note that RPMCFLAGS and RPMLDFLAGS are variables that come from the specfile when
# building for Fedora/CentOS/RHEL/et al
+#
ifeq ($(RPMCFLAGS),)
CFLAGS := -DVERSION=\"$(VERSION)\" $(FOPTS) $(MOPTS) $(WOPTS) $(SOPTS) $(DEFS)
@@ -64,6 +77,12 @@ else
CFLAGS := $(RPMCFLAGS) $(DEFS)
endif
+ifeq ($(IS_LEGACY),true)
+$(info Compiling with Legacy Mode enabled)
+$(info Overwriting RPMCFLAGS...)
+CFLAGS := -DVERSION=\"$(VERSION)\" $(FOPTS) $(MOPTS) $(WOPTS) $(DEFS) -std=c99 -DLEGACY
+endif
+
ifeq ($(DEBUG),0)
CFLAGS += -g -O2
else
@@ -200,7 +219,7 @@ install: stalld
rm -f $(DESTDIR)$(BINDIR)/throttlectl
make -C systemd DESTDIR=$(INSPATH) uninstall
-.PHONY: clean tarball systemd push annocheck
+.PHONY: clean tarball systemd push annocheck help
clean:
@test ! -f stalld || rm stalld
@test ! -f stalld-static || rm stalld-static
@@ -221,3 +240,22 @@ tarball: clean
annocheck: stalld
annocheck --ignore-unknown --verbose --profile=el10 --debug-dir=/usr/lib/debug/ ./stalld
+
+help:
+ @echo 'Cleaning targets:'
+ @echo ' clean - Clean the main executable, tests, objects, and tarballs.'
+ @echo ''
+ @echo 'Building targets:'
+ @echo ' stalld - Build the main executable (stalld).'
+ @echo ' static - Build a statically linked executable (stalld-static).'
+ @echo ' tests - Run tests in the "tests" subdirectory.'
+ @echo ' tarball - Create a source tarball: $(NAME)-$(VERSION).tar.$(CEXT)'
+ @echo ''
+ @echo 'Installation targets:'
+ @echo ' install - Install the executable, man page, docs, and licenses.'
+ @echo ' uninstall - Remove all installed files.'
+ @echo ''
+ @echo 'Utility targets:'
+ @echo ' annocheck - Run the annocheck security analysis tool on the stalld executable.'
+ @echo ' help - Display this help message.'
+
diff --git a/src/stalld.c b/src/stalld.c
index 466b6db15668..305618e577fc 100644
--- a/src/stalld.c
+++ b/src/stalld.c
@@ -153,14 +153,16 @@ int config_reservation = 0;
/*
* Select a backend.
- * Note that eBPF not supported on i686 and powerpc
+ * Note that eBPF not supported on i686, powerpc, and on x86 3.X kernels.
*/
-#if !__powerpc__ && !__i386__
+#if !__powerpc__ && !__i386__ && !LEGACY
struct stalld_backend *backend = &queue_track_backend;
#else
struct stalld_backend *backend = &sched_debug_backend;
#endif
+
+
/*
* Set of CPUs in which stalld should run.
*/
--
2.51.0
next prev parent reply other threads:[~2025-10-17 2:25 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 2:24 [PATCH 01/12] sched_debug: Unify parsing methods for task_info Clark Williams
2025-10-17 2:24 ` [PATCH 02/12] sched_debug: Fix runqueue task parsing logic and state filtering Clark Williams
2025-10-21 15:58 ` Wander Lairson Costa
2025-10-17 2:24 ` [PATCH 03/12] sched_debug: Fix double-free crash in fill_waiting_task() Clark Williams
2025-10-21 16:01 ` Wander Lairson Costa
2025-10-17 2:24 ` [PATCH 04/12] stalld.c: remove noisy idle report and added report to should_skip_idle_cpus() Clark Williams
2025-10-21 16:03 ` Wander Lairson Costa
2025-10-17 2:24 ` [PATCH 05/12] stalld.c: initialize cpu_info->idle_time to be -1 Clark Williams
2025-10-21 16:15 ` Wander Lairson Costa
2025-10-17 2:24 ` [PATCH 06/12] stalld.c: get rid of misleading print about DL-Server Clark Williams
2025-10-21 16:16 ` Wander Lairson Costa
2025-10-17 2:24 ` [PATCH 07/12] stalld.c: Add starvation logging in single-threaded log-only mode Clark Williams
2025-10-21 16:27 ` Wander Lairson Costa
2025-10-17 2:24 ` [PATCH 08/12] stalld: Add -N/--no_idle_detect flag to disable idle detection Clark Williams
2025-10-21 16:33 ` Wander Lairson Costa
2025-10-17 2:24 ` [PATCH 09/12] stalld: Add defensive checks in print_boosted_info Clark Williams
2025-10-21 17:36 ` Wander Lairson Costa
2025-10-17 2:24 ` Clark Williams [this message]
2025-10-17 12:50 ` [PATCH 10/12] Makefile: Add support for legacy kernels Derek Barbosa
2025-10-21 17:43 ` Wander Lairson Costa
2025-10-17 2:24 ` [PATCH 11/12] scripts: fix run-local if bashism Clark Williams
2025-10-21 17:45 ` Wander Lairson Costa
2025-10-17 2:24 ` [PATCH 12/12] Fix segfault in adaptive/aggressive modes Clark Williams
2025-10-21 17:45 ` Wander Lairson Costa
2025-10-21 15:54 ` [PATCH 01/12] sched_debug: Unify parsing methods for task_info Wander Lairson Costa
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=20251017022444.118802-10-clrkwllms@kernel.org \
--to=clrkwllms@kernel.org \
--cc=chris.friesen@windriver.com \
--cc=debarbos@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=luochunsheng@ustc.edu \
--cc=marco.chiappero@suse.com \
--cc=wander@redhat.com \
--cc=williams@redhat.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