[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f40f9aa9-e722-0264-2d4d-bc9062472f12@linux.dev>
Date: Wed, 24 Jan 2024 16:08:05 +0800
From: Yajun Deng <yajun.deng@...ux.dev>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
vincent.guittot@...aro.org, dietmar.eggemann@....com, bsegall@...gle.com,
mgorman@...e.de, bristot@...hat.com, vschneid@...hat.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] sched/fair: Return NULL when entity isn't a task
in task_of()
On 2024/1/23 11:48, Steven Rostedt wrote:
> On Wed, 6 Dec 2023 14:33:59 +0800
> Yajun Deng <yajun.deng@...ux.dev> wrote:
>
>> Before calling task_of(), we need to make sure that the entity is a task.
>> 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,
> Does it really check it twice? Have you disassembled it to see if the code
> 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.
Yes, the second check should be optimized.
>
>> return the task struct is meaningless.
>>
>> 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.
> I'm not against the change, as it could be considered a clean up. But it is
> up to the sched maintainers to decide if it's worth the churn.
Return NULL in task_of() makes the code cleaner.
>
> -- Steve
>
>
>> Signed-off-by: Yajun Deng <yajun.deng@...ux.dev>
Powered by blists - more mailing lists