Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-84365

CPUAffinity in /etc/systemd/system.conf doesn't update properly when applied by a tuned profile

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • rhel-8.10
    • tuned
    • No
    • Low
    • rhel-net-perf
    • ssg_core_services
    • None
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • x86_64
    • None

      What were you trying to do that didn't work?

       
      When applying this configuration with a tuned profile this setting is not restored or cleared on profile change and reboot.
      [systemd]
      cpu_affinity=${not_isolated_cores_expanded}

      From the source code for tuned/plugins/plugin_systemd.py

      """
      Plug-in for tuning systemd options.

      The [option]`cpu_affinity` option allows setting CPUAffinity in
      `/etc/systemd/system.conf`. This configures the CPU affinity for the
      service manager as well as the default CPU affinity for all forked
      off processes. The option takes a comma-separated list of CPUs with
      optional CPU ranges specified by the minus sign (`-`).

      .Set the CPUAffinity for `systemd` to `0 1 2 3`
      ====


      [systemd]
      cpu_affinity=0-3


      ====

      NOTE: These tunings are unloaded only on profile change followed by a reboot.
      """

      The problem seems likely to be in this function, which apparently checks for a file under /var/lib/tuned/ and either restores the old value or removes the CPUAffinity key completely.
      def _remove_systemd_tuning(self):
      conf = self._read_systemd_system_conf()
      if (conf is not None):
      fname = self._get_storage_filename()
      cpu_affinity_saved = self._cmd.read_file(fname, err_ret = None, no_error = True)
      self._cmd.unlink(fname)
      if cpu_affinity_saved is None:
      conf = self._del_key(conf, consts.SYSTEMD_CPUAFFINITY_VAR)
      else:
      conf = self._add_keyval(conf, consts.SYSTEMD_CPUAFFINITY_VAR, cpu_affinity_saved)
      self._write_systemd_system_conf(conf)

      We noted that after changing the tuned profile and rebooting the system, the CPU affinity was not cleared, instead it reverts to the previous configuration.

      What is the impact of this issue to you?

      Customer impacted and expecting CPU affinity configuration to be cleared after changing tuned profile to a default profile and rebooting.

      Please provide the package NVR for which the bug is seen:

      How reproducible is this bug?:

      Every time

      Steps to reproduce

      1.) Enable the tuned cpu-partitioning profile with the all the defaults
      2.) CPUAffinity in /etc/systemd/system.conf is set to the first core in each numa; i.e. Let's say 0 and 16 for this example.
      3.) No /var/lib/tuned/systemd backup file is created
      4.) Alter /etc/tuned/cpu-partitioning-variables.conf; to maybe isolated_cores=1-4,17-20
      5.) Reboot
      6.) On startup, tuned will see that CPUAffinity is not correctly set and will write 0,16 to /var/lib/tuned/systemd then fix /etc/systemd/system.conf with CPUAffinity=1-4,17-20
      7.) Disable the cpu-partition profile
      8.) Tuned will incorrectly restore CPUAffinity=0,16 to /etc/systemd/system.conf

      Expected results

      Set a value for 'cpu_affinity=' with a tuned profile. Then change the profile to a default profile and reboot. This should clear the CPU affinity configuration but it does not. /etc/systemd/system.conf must be manually configured and the system rebooted once more.

       

      Actual results

       

      Chaning the tuned profile and rebooting keeps previous CPU affinity applied in /etc/systemd/system.conf

              jskarvad Jaroslav Škarvada
              rhn-support-gmcnealy Grant McNealy
              Grant McNealy
              Jaroslav Škarvada Jaroslav Škarvada
              Robin Hack Robin Hack
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated: