From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753025AbcGSKpy (ORCPT ); Tue, 19 Jul 2016 06:45:54 -0400 Received: from ms01.sssup.it ([193.205.80.99]:46470 "EHLO sssup.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752529AbcGSKpw (ORCPT ); Tue, 19 Jul 2016 06:45:52 -0400 From: Tommaso Cucinotta To: Luca Abeni , Juri Lelli , Peter Zijlstra , Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-dl@retis.sssup.it, Tommaso Cucinotta , Juri Lelli Subject: [RFC PATCH 1/4] Minimally invasive deadline wrap-around bugfix for SCHED_DEADLINE cpu heap Date: Tue, 19 Jul 2016 11:44:50 +0200 Message-Id: <1468921493-10054-2-git-send-email-tommaso.cucinotta@sssup.it> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468921493-10054-1-git-send-email-tommaso.cucinotta@sssup.it> References: <1468921493-10054-1-git-send-email-tommaso.cucinotta@sssup.it> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current code in cpudeadline.c has a bug in re-heapifying when adding a new element at the end of the heap, because a deadline value of 0 is temporarily set in the new elem, then cpudl_change_key() is called with the actual elem deadline as param. However, the function compares the new deadline to set with the one previously in the elem, which is 0. So, if current absolute deadlines grew so much to have negative values as s64, the comparison in cpudl_change_key() makes the wrong decision. Instead, as from dl_time_before(), the kernel should handle correctly abs deadlines wrap-arounds. This patch fixes the problem with a minimally invasive change that forces cpudl_change_key() to heapify up in this case. Cc: Peter Zijlstra Cc: Juri Lelli Cc: Luca Abeni Reviewed-by: Luca Abeni Signed-off-by: Tommaso Cucinotta --- kernel/sched/cpudeadline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 5be5882..d418449 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -168,7 +168,7 @@ void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid) if (old_idx == IDX_INVALID) { cp->size++; - cp->elements[cp->size - 1].dl = 0; + cp->elements[cp->size - 1].dl = dl; cp->elements[cp->size - 1].cpu = cpu; cp->elements[cpu].idx = cp->size - 1; cpudl_change_key(cp, cp->size - 1, dl); -- 2.7.4