From: Byungchul Park <byungchul.park@lge.com>
To: <peterz@infradead.org>, <mingo@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <juri.lelli@gmail.com>,
<rostedt@goodmis.org>, <kernel-team@lge.com>
Subject: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()
Date: Fri, 2 Jun 2017 16:31:03 +0900 [thread overview]
Message-ID: <1496388663-29067-2-git-send-email-byungchul.park@lge.com> (raw)
In-Reply-To: <1496388663-29067-1-git-send-email-byungchul.park@lge.com>
When the heap tree is empty, cp->elements[0].cpu has meaningless value.
We need to consider the case.
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
kernel/sched/cpudeadline.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index d4a6963..9b314a9 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -110,7 +110,8 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
static inline int cpudl_maximum_cpu(struct cpudl *cp)
{
- return cp->elements[0].cpu;
+ int cpu = cp->elements[0].cpu;
+ return cp->elements[cpu].idx == IDX_INVALID ? -1 : cpu;
}
static inline u64 cpudl_maximum_dl(struct cpudl *cp)
--
1.9.1
next prev parent reply other threads:[~2017-06-02 7:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 7:31 [PATCH 1/2] sched/deadline: Add cpudl_maximum_dl() Byungchul Park
2017-06-02 7:31 ` Byungchul Park [this message]
2017-06-06 15:12 ` [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu() Juri Lelli
2017-06-06 23:42 ` Byungchul Park
2017-06-07 0:14 ` Byungchul Park
2017-06-08 14:02 ` Juri Lelli
2017-06-09 2:43 ` Byungchul Park
2017-06-09 11:42 ` Juri Lelli
2017-06-12 1:43 ` Byungchul Park
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=1496388663-29067-2-git-send-email-byungchul.park@lge.com \
--to=byungchul.park@lge.com \
--cc=juri.lelli@gmail.com \
--cc=kernel-team@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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