Skip to content

Enable custom prefix command from env var - #533

Open
rwstauner wants to merge 1 commit into
mainfrom
rwstauner/custom-prefix
Open

Enable custom prefix command from env var#533
rwstauner wants to merge 1 commit into
mainfrom
rwstauner/custom-prefix

Conversation

@rwstauner

Copy link
Copy Markdown
Contributor

I setup my machine with the kernel options to isolate a cpu and then I have a custom script that writes to the necessary files, and I have NOPASSWD sudo commands setup for the commands in that file.

Then I can set this env var to that script and it runs benchmarks specifically configured for my machine with no sudo prompt.

Example script:

#!/bin/bash

# sudoers
# rwstauner ALL= NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/intel_pstate/no_turbo
# rwstauner ALL= NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/intel_pstate/min_perf_pct
# rwstauner ALL= NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/cpu*/online
# rwstauner ALL= NOPASSWD: /usr/bin/renice

# NOTE: add `isolcpus=10,11 nohz_full=10,11` to the options line in /boot/loader conf

cpu=10
sibling=11

sudo () {
  command sudo --bell "$@"
}

teardown () {
  echo 0 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
  echo 8 | sudo tee /sys/devices/system/cpu/intel_pstate/min_perf_pct
  echo 1 | sudo tee /sys/devices/system/cpu/cpu$sibling/online
}

setup () {
  echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
  echo 100 | sudo tee /sys/devices/system/cpu/intel_pstate/min_perf_pct
  echo 0 | sudo tee /sys/devices/system/cpu/cpu$sibling/online
}

setup > /dev/null
trap 'teardown > /dev/null' EXIT

setarch x86_64 -R taskset -c $cpu sh -c 'sudo renice -n -15 "$$" > /dev/null; exec "$@"' - "$@"

I setup my machine with the kernel options to isolate a cpu
and then I have a custom script that writes to the necessary files,
and I have NOPASSWD sudo commands setup for the commands in that file.

Then I can set this env var to that script and it runs
benchmarks specifically configured for my machine with no sudo prompt.

Example script:

    #!/bin/bash

    # sudoers
    # rwstauner ALL= NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/intel_pstate/no_turbo
    # rwstauner ALL= NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/intel_pstate/min_perf_pct
    # rwstauner ALL= NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/cpu*/online
    # rwstauner ALL= NOPASSWD: /usr/bin/renice

    # NOTE: add `isolcpus=10,11 nohz_full=10,11` to the options line in /boot/loader conf

    cpu=10
    sibling=11

    sudo () {
      command sudo --bell "$@"
    }

    teardown () {
      echo 0 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
      echo 8 | sudo tee /sys/devices/system/cpu/intel_pstate/min_perf_pct
      echo 1 | sudo tee /sys/devices/system/cpu/cpu$sibling/online
    }

    setup () {
      echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
      echo 100 | sudo tee /sys/devices/system/cpu/intel_pstate/min_perf_pct
      echo 0 | sudo tee /sys/devices/system/cpu/cpu$sibling/online
    }

    setup > /dev/null
    trap 'teardown > /dev/null' EXIT

    setarch x86_64 -R taskset -c $cpu sh -c 'sudo renice -n -15 "$$" > /dev/null; exec "$@"' - "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant