From d33b2be2ca445badb3c3004b618c8e7c79677f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 27 Oct 2020 21:26:39 +0100 Subject: Implement LinuxProcess_effectiveIOPriority as function Make it more readable and fix unenclosed macro arguments --- linux/LinuxProcess.c | 7 ++++++- linux/LinuxProcess.h | 10 ---------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'linux') diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index fad80555..d607a71b 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -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; diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index 80a4220b..02e4af7e 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -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); -- cgit v1.2.3