AdelKS / LinuxGamingGuide

Linux Gaming Guide - An incomplete compilation of things I came across that may improve your gaming experience on Linux
394 stars 16 forks source link

tasks_redirect.sh: Redirect process to a new process #3

Closed xk0niR closed 3 years ago

xk0niR commented 3 years ago

Hey,

this isn´t a real issue but a question but my understanding to this is very limited: In your script you are performing

/bin/echo pgrep lutris > /dev/cpuset/theGood/tasks

which means the process is already running.

How would you do this for a new process? (pseudo code: /opt/game > /dev/cpuset/theGood/tasks which obv. will not work since you just redirect stdout this way.)

Thanks a lot!

AdelKS commented 3 years ago

Hello!

I was currently having a discussion with someone with the same needs, one solution I came up with is to create the cpu sets then move the current bash shell PID to theGood, then lunch your game from it as you used to:

$ sudo su -c "./tasks_redirect.sh"
$ sudo su -c "/bin/echo $$ > /dev/cpuset/theGood/tasks"
$ # Launch the game as you used to, now this shell is bound to theGood, and any process it spawns will be in it
$ sudo su -c "./reverse_tasks_redirect.sh"

You may want to remove the lutris question from the script if you don't need it.

xk0niR commented 3 years ago

Thanks a lot! This also should work with Steam games (custom launch options).

Is there an easy way to check if it´s working (e.g. cat /dev/cpuset/theGood/tasks and check if the game´s PID is listed)?

Edit: Sometimes I get

/bin/echo: write error: Invalid argument

while executing tasks_redirect. Any idea?

AdelKS commented 3 years ago

You are welcome!

If theGood has PIDs in it, it's already a good sign. And yes you can check if the game's PIDs are there.

For the errors, it's normal, because some of the PIDs are not movable so you get an error. It's safe to ignore.

Also, I did a benchmark (have a look at the updated notes): if you only game and have no "heavy" workload in parallel, it seems to not be useful. Except, I think, if the game doesn't need more cores than the isolated CCX/CCD