From: Yajun Deng <yajun.deng@linux.dev>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
bsegall@google.com, mgorman@suse.de, bristot@redhat.com,
vschneid@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] sched/fair: Return NULL when entity isn't a task in task_of()
Date: Wed, 24 Jan 2024 16:08:05 +0800 [thread overview]
Message-ID: <f40f9aa9-e722-0264-2d4d-bc9062472f12@linux.dev> (raw)
In-Reply-To: <20240122224852.6ab9b498@gandalf.local.home>
On 2024/1/23 11:48, Steven Rostedt wrote:
> On Wed, 6 Dec 2023 14:33:59 +0800
> Yajun Deng <yajun.deng@linux.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@linux.dev>
next prev parent reply other threads:[~2024-01-24 8:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 6:33 [PATCH v2 0/2] sched: Return NULL when entity isn't a task Yajun Deng
2023-12-06 6:33 ` [PATCH v2 1/2] sched/fair: Return NULL when entity isn't a task in task_of() Yajun Deng
2024-01-23 3:48 ` Steven Rostedt
2024-01-24 8:08 ` Yajun Deng [this message]
2023-12-06 6:34 ` [PATCH v2 2/2] sched/rt: Return NULL when rt entity isn't a task in rt_task_of() Yajun Deng
2024-01-23 3:19 ` [PATCH v2 0/2] sched: Return NULL when entity isn't a task Yajun Deng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f40f9aa9-e722-0264-2d4d-bc9062472f12@linux.dev \
--to=yajun.deng@linux.dev \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox