Implement LinuxProcess_effectiveIOPriority as function

Make it more readable and fix unenclosed macro arguments
This commit is contained in:
Christian Göttsche 2020-10-27 21:26:39 +01:00 committed by cgzones
parent 6b3dbd5c67
commit d33b2be2ca
2 changed files with 6 additions and 11 deletions

View File

@ -167,7 +167,12 @@ effort class. The priority within the best effort class will be
dynamically derived from the cpu nice level of the process:
io_priority = (cpu_nice + 20) / 5. -- From ionice(1) man page
*/
#define LinuxProcess_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->super.nice + 20) / 5) : p_->ioPriority)
static int LinuxProcess_effectiveIOPriority(const LinuxProcess* this) {
if (IOPriority_class(this->ioPriority) == IOPRIO_CLASS_NONE)
return IOPriority_tuple(IOPRIO_CLASS_BE, (this->super.nice + 20) / 5);
return this->ioPriority;
}
IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this) {
IOPriority ioprio = 0;

View File

@ -171,16 +171,6 @@ Process* LinuxProcess_new(const Settings* settings);
void Process_delete(Object* cast);
/*
[1] Note that before kernel 2.6.26 a process that has not asked for
an io priority formally uses "none" as scheduling class, but the
io scheduler will treat such processes as if it were in the best
effort class. The priority within the best effort class will be
dynamically derived from the cpu nice level of the process:
extern io_priority;
*/
#define LinuxProcess_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->super.nice + 20) / 5) : p_->ioPriority)
IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this);
bool LinuxProcess_setIOPriority(Process* this, Arg ioprio);