From: Cruz Zhao <CruzZhao@linux.alibaba.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
bristot@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH v2] sched/core: Skip sched_core_fork/free() when core sched is disabled
Date: Mon, 25 Apr 2022 04:17:34 +0800 [thread overview]
Message-ID: <1650831454-101777-1-git-send-email-CruzZhao@linux.alibaba.com> (raw)
As __put_task_struct() and copy_process() are hot path functions,
the call of sched_core_fork/free() will bring overhead when core
sched is disabled, and we skip them in these cases.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com>
---
kernel/sched/core_sched.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c
index 38a2cec..72a8ef8 100644
--- a/kernel/sched/core_sched.c
+++ b/kernel/sched/core_sched.c
@@ -108,13 +108,16 @@ static unsigned long sched_core_clone_cookie(struct task_struct *p)
void sched_core_fork(struct task_struct *p)
{
- RB_CLEAR_NODE(&p->core_node);
- p->core_cookie = sched_core_clone_cookie(current);
+ if (!sched_core_disabled()) {
+ RB_CLEAR_NODE(&p->core_node);
+ p->core_cookie = sched_core_clone_cookie(current);
+ }
}
void sched_core_free(struct task_struct *p)
{
- sched_core_put_cookie(p->core_cookie);
+ if (!sched_core_disabled())
+ sched_core_put_cookie(p->core_cookie);
}
static void __sched_core_set(struct task_struct *p, unsigned long cookie)
--
1.8.3.1
next reply other threads:[~2022-04-24 20:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-24 20:17 Cruz Zhao [this message]
2022-04-25 8:14 ` [PATCH v2] sched/core: Skip sched_core_fork/free() when core sched is disabled Peter Zijlstra
2022-04-25 15:04 ` cruzzhao
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=1650831454-101777-1-git-send-email-CruzZhao@linux.alibaba.com \
--to=cruzzhao@linux.alibaba.com \
--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 \
/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