On Wed, 6 Dec 2023 14:33:59 +0800
Yajun Deng <yajun.deng@xxxxxxxxx> wrote:
Before calling task_of(), we need to make sure that the entity is a task.Does it really check it twice? Have you disassembled it to see if the code
There is also a warning in task_of() if the entity isn't a task. That
means we need to check the entity twice. If the entity isn't a task,
is any better?
#define entity_is_task(se) (!se->my_q)
static inline struct task_struct *task_of(struct sched_entity *se)
{
SCHED_WARN_ON(!entity_is_task(se));
return container_of(se, struct task_struct, se);
}
The above is a macro and a static inline, which means that the compiler
should optimized out that second check.
return the task struct is meaningless.I'm not against the change, as it could be considered a clean up. But it is
Return NULL when entity isn't a task in task_of(), and call task_of()
instead of entity_is_task() when we need a task_struct.
up to the sched maintainers to decide if it's worth the churn.
-- Steve
Signed-off-by: Yajun Deng <yajun.deng@xxxxxxxxx>