-
Notifications
You must be signed in to change notification settings - Fork 55.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code cleanup in linux/sched/ #597
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,10 +142,12 @@ void free_rt_sched_group(struct task_group *tg) | |
destroy_rt_bandwidth(&tg->rt_bandwidth); | ||
|
||
for_each_possible_cpu(i) { | ||
if (tg->rt_rq) | ||
kfree(tg->rt_rq[i]); | ||
if (tg->rt_se) | ||
kfree(tg->rt_se[i]); | ||
/* Don't need to check if tg->rt_rq[i] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was actually checking if tg->rt_rq and tg->rt_se are NULL or not, not the elements in the array. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how I managed to overlook that. I've received feedback from Peter Zijlstra describing this patch as "horrible" and I agree with that assessment. I'm waiting for a response from Peter regarding whether he thinks any part of the patch is salvageable or if the whole thing is better off being thrown out. |
||
* or tg->rt_se[i] are NULL, since kfree(NULL) | ||
* simply performs no operation | ||
*/ | ||
kfree(tg->rt_rq[i]); | ||
kfree(tg->rt_se[i]); | ||
} | ||
|
||
kfree(tg->rt_rq); | ||
|
@@ -1015,10 +1017,7 @@ enqueue_top_rt_rq(struct rt_rq *rt_rq) | |
|
||
BUG_ON(&rq->rt != rt_rq); | ||
|
||
if (rt_rq->rt_queued) | ||
return; | ||
|
||
if (rt_rq_throttled(rt_rq)) | ||
if (rt_rq->rt_queued || rt_rq_throttled(rt_rq)) | ||
return; | ||
|
||
if (rt_rq->rt_nr_running) { | ||
|
@@ -1211,10 +1210,7 @@ void dec_rt_tasks(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq) | |
*/ | ||
static inline bool move_entity(unsigned int flags) | ||
{ | ||
if ((flags & (DEQUEUE_SAVE | DEQUEUE_MOVE)) == DEQUEUE_SAVE) | ||
return false; | ||
|
||
return true; | ||
return !((flags & (DEQUEUE_SAVE | DEQUEUE_MOVE)) == DEQUEUE_SAVE) | ||
} | ||
|
||
static void __delist_rt_entity(struct sched_rt_entity *rt_se, struct rt_prio_array *array) | ||
|
@@ -1393,7 +1389,7 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags) | |
|
||
/* For anything but wake ups, just return the task_cpu */ | ||
if (sd_flag != SD_BALANCE_WAKE && sd_flag != SD_BALANCE_FORK) | ||
goto out; | ||
return cpu; | ||
|
||
rq = cpu_rq(cpu); | ||
|
||
|
@@ -1437,7 +1433,6 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags) | |
} | ||
rcu_read_unlock(); | ||
|
||
out: | ||
return cpu; | ||
} | ||
|
||
|
@@ -2518,12 +2513,10 @@ static int tg_set_rt_bandwidth(struct task_group *tg, | |
/* | ||
* Disallowing the root group RT runtime is BAD, it would disallow the | ||
* kernel creating (and or operating) RT threads. | ||
* | ||
* No period doesn't make any sense. | ||
*/ | ||
if (tg == &root_task_group && rt_runtime == 0) | ||
return -EINVAL; | ||
|
||
/* No period doesn't make any sense. */ | ||
if (rt_period == 0) | ||
if ((tg == &root_task_group && !rt_runtime) || !rt_period) | ||
return -EINVAL; | ||
|
||
mutex_lock(&rt_constraints_mutex); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it clearer having just one return statement instead of several exit points?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a tiny optimization that should reduce the amount of instructions used in that method imo (if the compiler doesn't optimize that already), instead of assigning cpupri variable a value and then return it, it will just return the value instead.