Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp277389imm; Fri, 1 Jun 2018 00:11:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL4eTyFLT0FAg6pKruGaNVeizLXyedIFNZ9Y5biza4GvLoKdNkNe1lMZfFT8LMRZAKbCljG X-Received: by 2002:a17:902:b604:: with SMTP id b4-v6mr10002355pls.18.1527837099973; Fri, 01 Jun 2018 00:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527837099; cv=none; d=google.com; s=arc-20160816; b=z55N81VjBDy3BFl8CWnQXGiX2IJJ38CfPZozsc8LF8zej/h9HEVwV3oW2NYchRkZdg p1p2rILqfnbwPx4Jp1fprniWGfb8gCSp1QAIj41zGXrUkfex+1I3I9paT2a2hb79J7lJ lTZPCIPRQ79FELCogfMrY2XHTSC4/HkinbpBtawnzcfMxYfd1dgQY2LsvvTKSgugpipn 3p78NMtoE9LFB7h+LrzsSD5BvqGFkei4k9TXt0hTHOSSVvVtlQemlA+62BpmSCNCIgaP YTRGhiorznoH127ZO4OwmMb1CP9ck0B8gKP/1XUrQJw4WgPJq/47jeS9molebUOtWV7E w8dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=nntOiL3QySn8EU1z0Yjo68BX0T9huAD5+2ZICQTIn7g=; b=JKYGhZ+IlLep08pE7kpjpD6uHkbCBhNlXursqujfNP2xoKLDvyYc2hZNr1BJ5wTid4 cNrIUIaCslogRxHDkyQczQdOXyWoyBli+xHTznNpP7IDI1uDzc8Uk9BbD5CmopkdhwcH j6S9hsHlWP0fAfe97fD0oEvEgcoTAw+4nYyyKfripw5VqJ9x2Lg8mjyvHvYYiD357yTy HjARB3n77BwzEb8bp5LJNDbE4embZaewObFFUMuFJON37FCjEA/ASMUWaemqz6+v/pG5 w2tOU1yBJlrIEHv1Tr5ZyJKKzt+bUxqCAg8zwLNRRYqDllk5kz4cozs7ADRfN8xz2A1Q b+8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16-v6si11743832pgd.380.2018.06.01.00.11.24; Fri, 01 Jun 2018 00:11:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750983AbeFAHLA (ORCPT + 99 others); Fri, 1 Jun 2018 03:11:00 -0400 Received: from lgeamrelo13.lge.com ([156.147.23.53]:39290 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750729AbeFAHLA (ORCPT ); Fri, 1 Jun 2018 03:11:00 -0400 Received: from unknown (HELO lgeamrelo04.lge.com) (156.147.1.127) by 156.147.23.53 with ESMTP; 1 Jun 2018 16:10:57 +0900 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO ?10.177.220.135?) (10.177.220.135) by 156.147.1.127 with ESMTP; 1 Jun 2018 16:10:56 +0900 X-Original-SENDERIP: 10.177.220.135 X-Original-MAILFROM: byungchul.park@lge.com Subject: Re: [RESEND, v3, 2/2] sched/deadline: Initialize cp->elements[].cpu to an invalid value To: Joel Fernandes Cc: peterz@infradead.org, mingo@kernel.org, rostedt@goodmis.org, tglx@linutronix.de, raistlin@linux.it, linux-kernel@vger.kernel.org, juri.lelli@gmail.com, bristot@redhat.com, kernel-team@lge.com References: <1515392081-32320-2-git-send-email-byungchul.park@lge.com> <20180601061255.GA189147@joelaf.mtv.corp.google.com> <20180601061841.GA191514@joelaf.mtv.corp.google.com> From: Byungchul Park Message-ID: Date: Fri, 1 Jun 2018 16:10:56 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180601061841.GA191514@joelaf.mtv.corp.google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-06-01 15:18, Joel Fernandes wrote: > On Thu, May 31, 2018 at 11:12:55PM -0700, Joel Fernandes wrote: >> On Mon, Jan 08, 2018 at 03:14:41PM +0900, byungchul park wrote: >>> Currently, migrating tasks to cpu0 unconditionally happens when the >>> heap is empty, since cp->elements[].cpu was initialized to 0(=cpu0). >>> We have to distinguish between the empty case and cpu0 to avoid the >>> unnecessary migrations. Therefore, it has to return an invalid value >>> e.i. -1 in that case. >>> >>> Signed-off-by: Byungchul Park >>> Acked-by: Steven Rostedt (VMware) >>> Acked-by: Daniel Bristot de Oliveira >>> --- >>> kernel/sched/cpudeadline.c | 10 +++++++++- >>> 1 file changed, 9 insertions(+), 1 deletion(-) >>> >>> diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c >>> index 9f02035..bcf903f 100644 >>> --- a/kernel/sched/cpudeadline.c >>> +++ b/kernel/sched/cpudeadline.c >>> @@ -138,6 +138,12 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, >>> int best_cpu = cpudl_maximum_cpu(cp); >>> WARN_ON(best_cpu != -1 && !cpu_present(best_cpu)); >>> >>> + /* >>> + * The heap tree is empty for now, just return. >>> + */ >>> + if (best_cpu == -1) >>> + return 0; >>> + >>> if (cpumask_test_cpu(best_cpu, &p->cpus_allowed) && >>> dl_time_before(dl_se->deadline, cpudl_maximum_dl(cp))) { >>> if (later_mask) >>> @@ -265,8 +271,10 @@ int cpudl_init(struct cpudl *cp) >>> return -ENOMEM; >>> } >>> >>> - for_each_possible_cpu(i) >>> + for_each_possible_cpu(i) { >>> + cp->elements[i].cpu = -1; >>> cp->elements[i].idx = IDX_INVALID; >> >> Shouldn't you also set cp->elements[cpu].cpu to -1 in cpudl_clear (when you >> set cp->elements[cpu].cpu to IDX_INVALID there)? > > I messed up my words, I meant : "when setting cp->elements[cpu].idx to > IDX_INVALID there". Which means I need to call it a day :-) Ah.. I agree with you. It might be a problem when removing the last element.. Then I think the following change should also be applied additionally. Right? --- diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 8d9562d..44d4c88 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -172,12 +172,14 @@ void cpudl_clear(struct cpudl *cp, int cpu) } else { new_cpu = cp->elements[cp->size - 1].cpu; cp->elements[old_idx].dl = cp->elements[cp->size - 1].dl; - cp->elements[old_idx].cpu = new_cpu; + cp->elements[old_idx].cpu = (new_cpu == cpu) ? -1 : new_cpu; cp->size--; - cp->elements[new_cpu].idx = old_idx; cp->elements[cpu].idx = IDX_INVALID; - cpudl_heapify(cp, old_idx); + if (new_cpu != cpu) { + cp->elements[new_cpu].idx = old_idx; + cpudl_heapify(cp, old_idx); + } cpumask_set_cpu(cpu, cp->free_cpus); } raw_spin_unlock_irqrestore(&cp->lock, flags); -- Thanks, Byungchul