RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1225124 - Add a variables plugin to tuned
Summary: Add a variables plugin to tuned
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: tuned
Version: 7.2
Hardware: All
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Jaroslav Škarvada
QA Contact: Tereza Cerna
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-26 15:58 UTC by Jeremy Eder
Modified: 2015-11-19 12:21 UTC (History)
7 users (show)

Fixed In Version: tuned-2.5.1-1.el7
Doc Type: Enhancement
Doc Text:
Feature: Add support for variables to Tuned. Reason: Variables may ease creation/maintenance of Tuned profiles - there is no need to repeat the same values multiple time on multiple places and the profile can be parametrized - there are use cases when user supplied parameters are needed. Result: Support for variables was added into Tuned, for details see comments in bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1225124 especially comments number 2, 3, and 9.
Clone Of:
Environment:
Last Closed: 2015-11-19 12:21:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2375 0 normal SHIPPED_LIVE tuned bug fix and enhancement update 2015-11-19 10:51:42 UTC

Comment 2 Jaroslav Škarvada 2015-06-01 17:24:37 UTC
Support is added by:
tuned-2.4.1-1.20150601git.el7

Snapshot repo:
https://fedorapeople.org/~jskarvad/tuned/devel/repo/

Variables can be defined in [variables] section in profile configuration. Variables are specified the following way:

[variables]
VARIABLE1 = VALUE1
VARIABLE2 = VALUE2

Variables are expanded on definition and assignment. Previously defined variable is redefined by its new definition.

Variables can be referenced in plugins configuration by using '$' prefix, e.g.:

[variables]
delay = 20
   
[audio]
timeout = $delay
   
There can be also included external file with definition of variables by using 'include' directive:
    
[variables]
include = filename

The 'filename' is processed by ConfigObj parser. Comments are supported by '#' character. Multiple sections are not supported and files with multiple sections are flattened to single section configuration file.

The variables are also supported by the script plugin. It exports variables into environment before the script is executed. The variable names are prefixed by the 'TUNED_' string. Example:
   
[variables]
VARIABLE1 = VALUE1

will be exported into environment as:

TUNED_VARIABLE1 = VALUE1

If there is already TUNED_ prefix in the variable name, no other prefix is added, i.e.:

[variables]
TUNED_VARIABLE1 = VALUE1

will be exported as:

TUNED_VARIABLE1 = VALUE1

and not TUNED_TUNED_VARIABLE1.

Comment 3 Jaroslav Škarvada 2015-06-02 16:00:55 UTC
tuned-2.4.1-1.20150602git.el7 changes relevant to this feature:

No more support for $VARIABLE syntax, now only the ${VARIABLE} syntax is supported. It is to resolve ambiguity and prepare room for the more complex syntax which will be introduced by built-in functions, e.g now the following works:

[variables]
delay = 20
   
[audio]
timeout = ${delay}

The timeout will be set to 20.

Also support for '$' was added, use $${VARIABLE} to disable expansion. The first '$' will be removet, e.g.:

[variables]
delay = 20
   
[audio]
timeout = $${delay}

The timeout will be set to '${delay}' literally which is not integer and error will be emitted.

Also undefined variables are not expanded to NULL (as in bash) but are taken literally, e.g.:

[audio]
timeout = ${delay}

The timout will be set to '${delay}' and the result will be the same as in the prevous example.

Comment 4 Jaroslav Škarvada 2015-06-02 16:03:55 UTC
(In reply to Jaroslav Škarvada from comment #3)

> Also support for '$' was added

Should be:

Also support for escaping was added

Comment 7 Jeremy Eder 2015-06-05 00:58:28 UTC
Works now.  One thing I noted was that after applying the profile, grub.cfg reflected the new cmdline immediately, but /etc/tuned/bootcmdline took a few seconds to update.  Not a bug, just surprised me.

# rpm -q tuned
tuned-2.4.1-1.20150604git.el7.noarch
# grep cmdline tuned.conf 
cmdline=isolcpus=${isolated_cores} nohz_full=${isolated_cores} mce=ignore_ce intel_pstate=disable nosoftlockup
# cat variables.conf 
[variables]
# Examples:
# isolated_cores=2,4-7
isolated_cores=2-23
# tail -1 /etc/tuned/bootcmdline
TUNED_BOOT_CMDLINE="isolcpus=2-23 nohz_full=2-23 mce=ignore_ce intel_pstate=disable nosoftlockup"
# grep ^"set tuned" /boot/grub2/grub.cfg 
set tuned_params="isolcpus=2-23 nohz_full=2-23 mce=ignore_ce intel_pstate=disable nosoftlockup"

Comment 9 Jaroslav Škarvada 2015-06-05 13:31:33 UTC
I had to change the syntax a bit to be consistent with the newly implemented feature, so since tuned build 20150605 quoting is done by backslash '\' not by doubling dollar '$', e.g.:

[variables]
a = 1
audio = a

[audio]
timeout = \${audio}

timeout will be set to '${audio}'.

but:

[variables]
audio = 1

[audio]
timeout = $${audio}

timeout will be set to '$1' which is not expanded further (there is only one level expansion)

Comment 14 errata-xmlrpc 2015-11-19 12:21:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2375.html


Note You need to log in before you can comment on or make changes to this bug.