|
Userspace Resource Manager
|
Refer Plugin.cpp in Examples section, for basic code-guidance.
Resource Tuner's Extension Interface exposes macros that can be used to customize callbacks and Configs. To make use of this capability client's need to create a shared library, called libPlugin.so and place it at /etc/urm/custom. This library should contain all the customization logic. This strategy allows the Clients to keep their code wherever they want. The only constraints are in terms of library naming, and library location.
Refer Plugin.cpp for instructions on building the lib. Note, the lib must have appropriate permissions so that Resource Tuner can read it.
Resource Tuner's Extension Interface allows for users to specify Custom Appliers and Teardown Callbacks for each Resource. Resource Tuner will provide default Applier and Teardown callbacks, but hte user can override them as per their needs.
=> Applier Callback: This callback is called when a Request to tune a Resource is about to be applied. The default applier writes the configured value to the associated Resource (sysfs / procfs, cgroup etc.) Node.
=> Teardown Callback: This callback is called when the currently applied Request for a Resource expires and there are no other Pending Requests. The default teardown callback resets the Resource Node value to its original value.
Using the Extensions Interface, Users can easily extend the Resource Tuner's functionality to tune New Resources and apply their own Custom Logic for Applier and Teardown Callbacks.
The following examples shows a sample custom Applier callback for Resource with the ResCode: 0x00090005.
Post-processing callbacks allow extension plugins to react to signal events after URM has processed them. Register a callback using URM_REGISTER_POST_PROCESS_CB. URM invokes the callback when a signal matching the registered identifier is acquired, passing a PostProcessCBData* as the argument.
PostProcessCBData struct (declared in extensions/Include/Extensions.h):
The mHandleAcq field carries the handle returned by the internal acquireSignal call, allowing the callback to track or release the associated resource tuning request.
Usage Example
Resource Tuner allows users to provide their own Config files for different entities like: Resources, Signals, Properties etc. In order for these custom config files to be read and parsed they can either be placed in /etc/urm/custom/ or if the user wants even more flexibility in terms of location, they can specify the location of the Config file, using the Extensions Interface's URM_REGISTER_CONFIG macro.
For example:
This will tell Resource Tuner that the custom Resources Config file is located at: "/opt/custom/ResourcesConfig.yaml". Similar strategy can be followed for Signals, Properties, Ext Features etc.