Re: [PATCH v2] sched: separate operations only for SMP from account_entity_en(de)queue

From: Byungchul Park
Date: Tue Jul 07 2015 - 02:31:23 EST


On Tue, Jul 07, 2015 at 10:07:03AM +0900, byungchul.park@xxxxxxx wrote:
> From: Byungchul Park <byungchul.park@xxxxxxx>
>
> manipulating rq->cfs_tasks and numa-accounting are not meaningless on !SMP.
> separate the operations from account_entity_en(de)queue.
>
> Signed-off-by: Byungchul Park <byungchul.park@xxxxxxx>
> ---
> kernel/sched/fair.c | 40 +++++++++++++++++++++++++++-------------
> 1 file changed, 27 insertions(+), 13 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 09456fc..a22f255 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2314,20 +2314,36 @@ static inline void account_numa_dequeue(struct rq *rq, struct task_struct *p)
> }
> #endif /* CONFIG_NUMA_BALANCING */
>
> +#ifdef CONFIG_SMP
> +static void account_task_enqueue(struct rq *rq, struct sched_entity *se)
> +{
> + account_numa_enqueue(rq, task_of(se));

i put this code within #ifdef CONFIG_SMP as original code. see below.

> + list_add(&se->group_node, &rq->cfs_tasks);

se->group_node can be used for other purposes, so i didn't touch the structure.
but manipulating rq->cfs_tasks list is only for CONFIG_SMP.
so i just touched the code manipulating the list.

> +}
> +
> +static void account_task_dequeue(struct rq *rq, struct sched_entity *se)
> +{
> + account_numa_dequeue(rq, task_of(se));
> + list_del_init(&se->group_node);
> +}
> +#else
> +static inline void account_task_enqueue(struct rq *rq, struct sched_entity *se)
> +{
> +}
> +
> +static inline void account_task_dequeue(struct rq *rq, struct sched_entity *se)
> +{
> +}
> +#endif /* CONFIG_SMP */
> +
> static void
> account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se)
> {
> update_load_add(&cfs_rq->load, se->load.weight);
> if (!parent_entity(se))
> update_load_add(&rq_of(cfs_rq)->load, se->load.weight);
> -#ifdef CONFIG_SMP
> - if (entity_is_task(se)) {
> - struct rq *rq = rq_of(cfs_rq);
> -
> - account_numa_enqueue(rq, task_of(se));
> - list_add(&se->group_node, &rq->cfs_tasks);
> - }
> -#endif

this is the original code i mentioned.

> + if (entity_is_task(se))
> + account_task_enqueue(rq_of(cfs_rq), se);
> cfs_rq->nr_running++;
> }
>
> @@ -2337,15 +2353,13 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)
> update_load_sub(&cfs_rq->load, se->load.weight);
> if (!parent_entity(se))
> update_load_sub(&rq_of(cfs_rq)->load, se->load.weight);
> - if (entity_is_task(se)) {
> - account_numa_dequeue(rq_of(cfs_rq), task_of(se));
> - list_del_init(&se->group_node);
> - }
> + if (entity_is_task(se))
> + account_task_dequeue(rq_of(cfs_rq), se);
> cfs_rq->nr_running--;
> }
>
> #ifdef CONFIG_FAIR_GROUP_SCHED
> -# ifdef CONFIG_SMP
> +#ifdef CONFIG_SMP
> static inline long calc_tg_weight(struct task_group *tg, struct cfs_rq *cfs_rq)
> {
> long tg_weight;
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/