Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp237363imm; Thu, 31 May 2018 23:13:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKINBN8VLxwFYF/muBH/Oslu/ZEcylpzkmyDZ1O496RF04lGw3tH78paWd5rjwYR/IV5APEF X-Received: by 2002:a62:808f:: with SMTP id j137-v6mr1381308pfd.91.1527833619238; Thu, 31 May 2018 23:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527833619; cv=none; d=google.com; s=arc-20160816; b=bmKXPfcboRsMt/DhK6POvELhQGKRXYWiCuNCy7jQ1asMQ6g0GUI4pigD6PgT/LLQgm EprOFshtuH0KQ1A/1lAQQFmDTM7HB1PPrd95Z9VabaRvH31R1nyabgz0SMfVVPPbeSqM SrEtJMMLKv5i5XUAtL0HiBaQsWEyVY+qFc8SR4yuelt761FEjXCk+HuN+4hs8pulD7JX u2zBDRQia0op1GQf6r/RZL/x6fsr8Yj9aAo3e+354/fgfK940jYTdX7fXjoB5NgVkIuE BG3HgucyrYtnoBcb5diHtuepHOjohYID+tfjpR6QTs9EaMqRLc/sklwSf4mTmRYw+uwN X0HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=dOafxVnfGWMbhxnwKyu1C72FkLO4wjZVksocXntZ5co=; b=J0bAKFnh266TVtXvaAZ5O4euTLFC5+pQYNr3DGnRQrrBeZiSp6pxRGRdlWe+wHYASh EGsqwITn8DCP/R5+p4+uUxmIBVbTfgW1B1Kv4stQRLNdreUTsr5J+kSyWrmk1qhCcaJa kav0sOkelfLgHt1hLymzGW28J3MqVmVKHw3BjoM34h0nEPZzL1QIg7vjmUIPMBtucXXp gv7nCRgwTKcAZE/ycj977awImtorMgi88U+9l+loLuB2vXl6Ol8GKBKtqC3l0UUgyuv4 Z7fVtuQXAFsqtbWY7BsXM8caTnHnVjn/9xx6YOg4bs04WGLqyktsj6KLURkGoLJm8LGZ nTUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=mReV3TT4; 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 bf3-v6si39025861plb.105.2018.05.31.23.13.23; Thu, 31 May 2018 23:13: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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=mReV3TT4; 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 S1751008AbeFAGM6 (ORCPT + 99 others); Fri, 1 Jun 2018 02:12:58 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:42980 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750760AbeFAGM4 (ORCPT ); Fri, 1 Jun 2018 02:12:56 -0400 Received: by mail-pl0-f66.google.com with SMTP id u6-v6so14699014pls.9 for ; Thu, 31 May 2018 23:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dOafxVnfGWMbhxnwKyu1C72FkLO4wjZVksocXntZ5co=; b=mReV3TT4VJIrHRGKD6NUu7hMsV5KStZeJHorkrPcXe2/Fu6ECUoJMfnEBkuEcBAPBt Q6BpEDi/JbW3jtZimn8KsPJIcNHM6K69D0qKcjI0LCKZMxJzwvZq3UYDPUAsYN0DNeUe ucg1zyu6yhe97LW7Du50sC2A6iYMF/ucs0kvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dOafxVnfGWMbhxnwKyu1C72FkLO4wjZVksocXntZ5co=; b=BoBWMEYUf4J3aV+CEWuNHSGqcdIONIw1mtaFNR1IIJiRN4mlxZYVJLE3pMEvXkmKmw UVUxJPrqpAFk9JOHndtXhGyjyKQzE1+lmLSzN1wc3JSk2XvlcGv0yUEYgJcY4mHg+Rpq 5ozhgi0LjJDw7aIDQzx/ymAmadrHQTnPQHKKn2+5ehwOzPVtny9A7GKr6kan61Cd21ud xM7+6Ty3nfxPpitsSODsQnmADj+Pzqw+vyt631LZLRxMCbpJ7blFpygJ0we3lQLlvNnZ N00P5zOv17xpRFLuW6LBP+wZGf3eCKq9Mt+cMmF1R/IkgQlLIULoYuqE060rWgMCLsuB BC3g== X-Gm-Message-State: ALKqPwdpOZKzOnkdf3iTvG5OnqJ3aZGtE0OdKJNA//EyXi9EyKNdHdnk Q09ZsEhar4HQNeyASuTRZg98Jw== X-Received: by 2002:a17:902:8a81:: with SMTP id p1-v6mr10114424plo.33.1527833576342; Thu, 31 May 2018 23:12:56 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id c12-v6sm1034286pfi.177.2018.05.31.23.12.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 May 2018 23:12:55 -0700 (PDT) Date: Thu, 31 May 2018 23:12:55 -0700 From: Joel Fernandes To: byungchul park 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 Subject: Re: [RESEND, v3, 2/2] sched/deadline: Initialize cp->elements[].cpu to an invalid value Message-ID: <20180601061255.GA189147@joelaf.mtv.corp.google.com> References: <1515392081-32320-2-git-send-email-byungchul.park@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1515392081-32320-2-git-send-email-byungchul.park@lge.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)? thanks, - Joel