From 73c515f0bb9e41921202099c0d141f0844ce6730 Mon Sep 17 00:00:00 2001 From: Lemmy Huang Date: Thu, 13 Mar 2025 23:19:26 +0800 Subject: [PATCH] profiles: add spark-omni Signed-off-by: Lemmy Huang --- profiles-add-spark-omni.patch | 244 ++++++++++++++++++++++++++++++++++ tuned.spec | 7 +- 2 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 profiles-add-spark-omni.patch diff --git a/profiles-add-spark-omni.patch b/profiles-add-spark-omni.patch new file mode 100644 index 0000000..f91ec76 --- /dev/null +++ b/profiles-add-spark-omni.patch @@ -0,0 +1,244 @@ +From 931885bed760a232a22b52564d9266a752e26619 Mon Sep 17 00:00:00 2001 +From: Lemmy Huang +Date: Fri, 14 Mar 2025 10:42:05 +0800 +Subject: [PATCH] profiles: add spark-omni + +Signed-off-by: Lemmy Huang +--- + Makefile | 3 +- + tuned-proc.sh | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 204 insertions(+), 1 deletion(-) + create mode 100755 tuned-proc.sh + +diff --git a/Makefile b/Makefile +index 88bf693..eda3659 100644 +--- a/Makefile ++++ b/Makefile +@@ -69,7 +69,7 @@ release-cp: release-dir + cp -a tuned.py tuned.spec tuned.service tuned.tmpfiles Makefile tuned-adm.py \ + tuned-adm.bash dbus.conf recommend.conf tuned-main.conf 00_tuned \ + 92-tuned.install bootcmdline modules.conf com.redhat.tuned.policy \ +- tuned-gui.py tuned-gui.glade tuned-ppd.py \ ++ tuned-gui.py tuned-gui.glade tuned-ppd.py tuned-proc.sh \ + tuned-gui.desktop functions $(VERSIONED_NAME) + cp -a doc experiments libexec man profiles systemtap tuned contrib icons \ + tests $(VERSIONED_NAME) +@@ -149,6 +149,7 @@ install: install-dirs + $(call install_python_script,tuned.py,$(DESTDIR)/usr/sbin/tuned) + $(call install_python_script,tuned-adm.py,$(DESTDIR)/usr/sbin/tuned-adm) + $(call install_python_script,tuned-gui.py,$(DESTDIR)/usr/sbin/tuned-gui) ++ $(call install_python_script,tuned-proc.sh,$(DESTDIR)/usr/sbin/tuned-proc) + + $(foreach file, diskdevstat netdevstat scomes, \ + install -Dpm 0755 systemtap/$(file) $(DESTDIR)/usr/sbin/$(notdir $(file));) +diff --git a/tuned-proc.sh b/tuned-proc.sh +new file mode 100755 +index 0000000..1d54c6b +--- /dev/null ++++ b/tuned-proc.sh +@@ -0,0 +1,202 @@ ++#!/bin/bash ++ ++_debug=false ++_action="" ++_profile_name="" ++_pid=0 ++ ++ ++########## Add a conf template ########## ++_profile_conf="" ++_profile_conf_list=" ++ Available profiles: ++ \n- example ++ \n- spark-omni ++" ++ ++_example_conf=( ++ 'uname_regex' 'aarch64' 'aarch64' ++) ++_spark_omni_conf=( ++ 'uname_regex' 'aarch64' 'aarch64' ++ '/proc/%d/bound' '0' '1' ++ '/sys/kernel/perception_schedule' '0' '1' ++ '/sys/kernel/debug/sched_features' 'NO_BOUND_NUMA' 'BOUND_NUMA' ++ '/sys/kernel/mm/transparent_hugepage/enabled' 'always' 'never' ++ '/sys/kernel/mm/transparent_hugepage/defrag' 'madvise' 'never' ++) ++ ++function prase_profile_name() { ++ local profile_name=$1 ++ case "$profile_name" in ++ example) ++ _profile_conf=("${_example_conf[@]}") ++ ;; ++ spark-omni) ++ _profile_conf=("${_spark_omni_conf[@]}") ++ ;; ++ *) ++ echo "Error: Unknown profile '$profile_name'." ++ return ++ ;; ++ esac ++ ++ debug "_profile_conf : ${_profile_conf[@]}" ++} ++########## Add a conf template ########## ++ ++ ++debug() { ++ if [ "$_debug" = true ]; then ++ echo "[DEBUG] $@" ++ fi ++} ++ ++function show_usage() ++{ ++ echo "usage: tuned-proc [-h] [--debug] {list,off,profile} ..." ++ echo "" ++ echo "positional arguments:" ++ echo " list list available profiles" ++ echo " off switch off all tunings" ++ echo " profile switch to a given profile" ++ echo "" ++ echo "optional arguments:" ++ echo " -h, --help show this help messages and exit" ++ echo " -d, --debug show debug messages" ++ echo "" ++ echo "example:" ++ echo " tuned-proc profile spark-omni --pid 111" ++ echo " tuned-proc off spark-omni" ++ echo "" ++} ++ ++args_check_pid() { ++ if [[ "$1" =~ ^[0-9]+$ ]]; then ++ return 0 ++ else ++ return 1 ++ fi ++} ++ ++function prase_args() ++{ ++ while [[ $# -gt 0 ]]; do ++ case "$1" in ++ -h|--help) ++ show_usage ++ exit 0 ++ ;; ++ -d|--debug) ++ _debug=true ++ shift ++ ;; ++ list|off|profile) ++ _action=$1 ++ shift ++ if [ "$_action" = "profile" ] || [ "$_action" = "off" ]; then ++ _profile_name=$1 ++ if [ -z "$_profile_name" ]; then ++ echo "Error: No profile specified." ++ show_usage ++ exit 1 ++ fi ++ shift ++ if [ "$1" = "--pid" ]; then ++ shift ++ _pid=$1 ++ if ! args_check_pid "$_pid"; then ++ echo "Error: pid must be a positive integer." ++ show_usage ++ exit 1 ++ fi ++ shift ++ fi ++ prase_profile_name $_profile_name ++ fi ++ ;; ++ *) ++ echo "Unknown option: $1" ++ show_usage ++ exit 1 ++ ;; ++ esac ++ done ++ ++ debug "_debug : $_debug" ++ debug "_action : $_action" ++ debug "_profile_name : $_profile_name" ++ debug "_pid : $_pid" ++} ++ ++function _set_conf() ++{ ++ file=$1 ++ value=$2 ++ if [ -e $file ]; then ++ echo $value > $file ++ debug "_set_conf $file : $value" ++ else ++ debug "_set_conf $file not exist!" ++ fi ++} ++ ++function _active_conf() ++{ ++ step=$1 ++ for ((i=0; i<${#_profile_conf[@]}; i+=3)); do ++ conf=${_profile_conf[i]} ++ value=${_profile_conf[i+$step]} ++ ++ if [ $conf == "uname_regex" ]; then ++ if [ $value != `uname -m` ]; then ++ debug "skip for `uname -m`" ++ break ++ fi ++ continue ++ fi ++ ++ echo $conf | grep -q "/proc/" ++ if [ $? == 0 ]; then ++ if [ "$_pid" -gt 0 ]; then ++ file=$(printf $conf $_pid) ++ _set_conf $file $value ++ fi ++ else ++ _set_conf $conf $value ++ fi ++ done ++} ++ ++function profile_off() ++{ ++ _active_conf 1 ++} ++ ++function profile_on() ++{ ++ _active_conf 2 ++} ++ ++function profile_list() ++{ ++ echo -e $_profile_conf_list ++} ++ ++function profile_active() ++{ ++ case "$_action" in ++ list) ++ profile_list ++ ;; ++ off) ++ profile_off ++ ;; ++ profile) ++ profile_on ++ ;; ++ esac ++} ++ ++prase_args $@ ++profile_active +-- +2.33.0 + diff --git a/tuned.spec b/tuned.spec index 9775fc3..c381ba2 100644 --- a/tuned.spec +++ b/tuned.spec @@ -1,7 +1,7 @@ Summary: A system tuning service for Linux Name: tuned Version: 2.24.1 -Release: 1 +Release: 2 License: GPLv2+ Source0: https://github.com/redhat-performance/%{name}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz URL: http://www.tuned-project.org/ @@ -38,6 +38,7 @@ Patch4: tuned-add-app-sensor-profile.patch Patch5: profiles-drop-sched_-tuning-where-appropriate.patch Patch6: bugfix-check_positive-has-some-contradictions.patch Patch7: bugfix-expand-variables-in-Plugin.patch +Patch8: profiles-add-spark-omni.patch Provides: tuned-gtk = %{version}-%{release} Provides: tuned-utils = %{version}-%{release} @@ -242,6 +243,7 @@ fi %{_sbindir}/netdevstat %{_sbindir}/diskdevstat %{_sbindir}/scomes +%{_sbindir}/%{name}-proc %exclude %{_prefix}/lib/%{name}/profiles/realtime %exclude %{_prefix}/lib/%{name}/profiles/realtime-virtual-guest @@ -297,6 +299,9 @@ fi %{_mandir}/man7/tuned-profiles-spectrumscale-ece.7* %changelog +* Thu Mar 13 2025 LemmyHuang - 2.24.1-2 +- profiles: add spark-omni + * Mon Dec 2 2024 Liu Chao - 2.24.1-1 - Upgrade to 2.24.1: - fixed privileged execution of arbitrary scripts by active local user. (CVE-2024-52336) -- Gitee