syscl / CPUTune

An open source kernel extension enables dynamic CPU performance tuning at runtime for macOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I have a solution to solve this potential issue, CPUTune::readConfigAtRuntime().

iAaronLau opened this issue · comments

I have a solution to solve this potential issue, but as for my ability, I am unable to realize it:

// FIXME: As per Apple Document (https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP0000018-BAJFFJAD Listing 7-5):

    // FIXME: As per Apple Document (https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP0000018-BAJFFJAD Listing 7-5):
    // Events originating from timers are handled by the driver’s Action routine.
    // As with other event handlers, this routine should never block indefinitely.
    // This specifically means that timer handlers, and any function they invoke,
    // must not allocate memory or create objects, as allocation can block for unbounded periods of time.
    // As for now, the reading procedure reads only one byte, which is fairly fast in our case, so we assume
    // this routine will not cause infinite blocking. Let me know if you have some other good ideas.

The solution just need to do a replacement and to modify the function CPUTune::init():

  1. replace all the "/tmp/"with "/tmp/CPUTune/" in the project;

in the init function:

  1. mkdir /tmp/CPUTune
  2. mount a disk made by RAM with just 1MB size; All the config files work in RAM.

In this way, the disk I/O requests could be transformed into RAM requests. Therefore the
infinite blocking risk avoided.

@syscl @asepms92 @Mrc527 @christophe-duc @schdt899