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

TuneD does not rollback settings when using vm.dirty_bytes and vm.dirty_background_bytes

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • rhel-9.4, rhel-9.4.z
    • tuned
    • No
    • Moderate
    • rhel-sst-cs-net-perf-services
    • ssg_core_services
    • 5
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • All
    • None

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

      Switch between profiles where vm.dirty_bytes or vm.dirty_background_bytes are being used. For more detail, please see the reproducer.

      What is the impact of this issue to you?

      Unability to roll-back settings during profile switches.

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

      tuned-2.22.1-1.4.20240530git5385fa99.el9fdp.noarch

      How reproducible is this bug?:

      Always.

      Steps to reproduce

      1. mkdir -p /etc/tuned/p {1,2}
      2. cat > /etc/tuned/p1/tuned.conf <<EOF
        [main]
        summary=Empty profile
        EOF
      3. cat > /etc/tuned/p2/tuned.conf <<EOF
        [main]
        summary=Customize dirty memory
        [sysctl]
        vm.dirty_bytes = 8192
        vm.dirty_background_bytes = 8192
        EOF
      4. tuned-adm profile p1
      5. reboot # reboot to get the default kernel settings and set empty TuneD p1 profile
      6. sysctl -a|grep -E 'vm.dirty_(bytes|ratio)'
        vm.dirty_bytes = 0
        vm.dirty_ratio = 20
      7. tuned-adm active
        Current active profile: p1
      8. tuned-adm profile p2
      9. tuned-adm profile p1
      10. sysctl -a|grep -E 'vm.dirty_(bytes|ratio)'
        vm.dirty_bytes = 8192
        vm.dirty_ratio = 0
      11. # Note the sysctls values did not roll back and see the errors in /var/log/tuned/tuned.log
        grep ERROR /var/log/tuned/tuned.log
        2024-09-13 03:08:37,474 ERROR tuned.utils.commands: Writing to file '/proc/sys/vm/dirty_bytes' error: '[Errno 22] Invalid argument'
        2024-09-13 03:08:37,474 ERROR tuned.utils.commands: Writing to file '/proc/sys/vm/dirty_background_bytes' error: '[Errno 22] Invalid argument'

      Expected results

      vm.dirty_bytes
      vm.dirty_ratio
      vm.dirty_background_bytes
      vm.dirty_background_ratio

      values rolled back and no ERROR messages in TuneD logs

      Actual results

      See the reproducer

      Additional information

      The issue is that during the rollback, TuneD tries to write 0 to vm.dirty_bytes and vm.dirty_background_bytes. This is not allowed. The miminum value is 2*page size bytes. This can likely be solved by adding additional logic to see what the value of vm.dirty_ratio and vm.dirty_background_ratio is and write that instead when vm.dirty_bytes or vm.dirty_background_bytes are 0s. Writing any value to the _ratio knobs zeros the respective _bytes knobs. See the kernel docs for more detail:

      dirty_bytes
      ===========
      
      Contains the amount of dirty memory at which a process generating disk writes
      will itself start writeback.
      
      Note: dirty_bytes is the counterpart of dirty_ratio. Only one of them may be
      specified at a time. When one sysctl is written it is immediately taken into
      account to evaluate the dirty memory limits and the other appears as 0 when
      read.
      
      Note: the minimum value allowed for dirty_bytes is two pages (in bytes); any
      value lower than this limit will be ignored and the old configuration will be
      retained.
      
      
      dirty_ratio
      ===========
      
      Contains, as a percentage of total available memory that contains free pages
      and reclaimable pages, the number of pages at which a process which is
      generating disk writes will itself start writing out dirty data.
      
      The total available memory is not equal to total system memory.
      

              pzacik@redhat.com Pavol Zacik
              jmencak Jiri Mencak
              Jaroslav Skarvada Jaroslav Skarvada
              Robin Hack Robin Hack
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: