Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3071868ybi; Tue, 2 Jul 2019 01:36:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqx91rL6i7ew1uMwViD8GEmoauoKzk3vsYuf57tK6na30JC0zOriokHOukNCekWHYQgWA8dx X-Received: by 2002:a63:b46:: with SMTP id a6mr3114681pgl.235.1562056582840; Tue, 02 Jul 2019 01:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562056582; cv=none; d=google.com; s=arc-20160816; b=jRF6N4cev33Y/OFOH8obueK9UtySjUhvnjNWLNFpHUqUDLKsd+LbyXgFa/ezC2nB4X j+xhQA9Om9NwaLlT6miKcGnGKj5/eX1QydQb723s/NjEoX1GptwhHUDtpbtcswiTyMen biEefM45zYDmxoVDT263XLuekya98vae5R6l838UVBvIWWb9BikLkreTkN3Mc0ygDvzR gGRBLxm6TcpG5hV1yv4u1qL7iceeoVuhvSPWcW07IL9oqn5qTEHkA9UCpgoimevEAyfD HpIan4ipSsgeP6BQQ+LvR4rTYfjathfpNdduGEYcl5Re3tghMrgWKnZOw5/m69fGTbaI 7u7A== 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; bh=fzuDJRp1GS1NXqeYiBlRbpLNKor0YyYTWdJKqC2k2W8=; b=pTRIGkY8YfnjwuByQMtrwORnkVXuOZF2dg67qPcohvP1IvAczlmRdqHEoUeq77kAW3 9RgKct/94s7EfdQXtcb6JsAL+eRZTIa0xixCRkZzjl0xx91vd+RM59QR/07HBrKNkymU iOM1iJb8CO9Fs49SaJrB0EICknN2+SnTi10gv1DJhegq67VcAvJaj+NpCFfhfSFBOCiD 0olohuLbAJCvmGNeYxwlSKpi95W+VluNSI1Vboi63/WLMpKTyI6ulfXgdGMUhMqptXAL Wf9B32bN6D3xdcKxddaUOz3bUcy93apJ6P+SGv/p0w3MT/RVxEMROoaSkrpjznFSSKAf VhSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=PXpjKC1L; 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 s29si13565577pfd.147.2019.07.02.01.36.08; Tue, 02 Jul 2019 01:36:22 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=PXpjKC1L; 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 S1726594AbfGBIfn (ORCPT + 99 others); Tue, 2 Jul 2019 04:35:43 -0400 Received: from merlin.infradead.org ([205.233.59.134]:44532 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbfGBIfn (ORCPT ); Tue, 2 Jul 2019 04:35:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fzuDJRp1GS1NXqeYiBlRbpLNKor0YyYTWdJKqC2k2W8=; b=PXpjKC1L/ZQH0U3MH0ew5Q0iK os1DO7nXa0YF3DvR3UAKHdnl5aSdcQuyZXCfpwrLiluTdN8qF8R8OYhWM4OF7PHHM6X7K90YzsLOQ YXKR2fbV0djPsUSJcC4KrRu8ZQ1Yyvg0anITTN4hJbUs6Hx80Pefga6eWGjv+BhBhcykOKFaYJWO6 rwAPWEprtgnH7zHRSyJ9YdVWyHLhepjeBsd0Jc2voDAyv5iWnYRj2N23jcuIwLypT/ibnvz7Qdqp6 XaqEW5IK/ZYFc37G3Zrzd7VNsGSAC1tLvI2Kwqu6/eMVbh4qYrTf7ojQCdmXINo4fMxZjkVU2kPN3 axIs56tHg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hiEG0-0005ZG-5y; Tue, 02 Jul 2019 08:35:20 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8063F20ADAD55; Tue, 2 Jul 2019 10:35:17 +0200 (CEST) Date: Tue, 2 Jul 2019 10:35:17 +0200 From: Peter Zijlstra To: Subhra Mazumdar Cc: Viresh Kumar , Ingo Molnar , linux-kernel@vger.kernel.org, Vincent Guittot , tkjos@google.com, Daniel Lezcano , quentin.perret@linaro.org, chris.redpath@arm.com, steven.sistare@oracle.com, songliubraving@fb.com Subject: Re: [PATCH V3 2/2] sched/fair: Fallback to sched-idle CPU if idle CPU isn't found Message-ID: <20190702083517.GY3419@hirez.programming.kicks-ass.net> References: <32bd769c-b692-8896-5cc9-d19ab0a23abb@oracle.com> <20190701080349.homlsgia4fuaitek@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 01, 2019 at 03:08:41PM -0700, Subhra Mazumdar wrote: > On 7/1/19 1:03 AM, Viresh Kumar wrote: > > On 28-06-19, 18:16, Subhra Mazumdar wrote: > > > On 6/25/19 10:06 PM, Viresh Kumar wrote: > > > > @@ -5376,6 +5376,15 @@ static struct { > > > > #endif /* CONFIG_NO_HZ_COMMON */ > > > > +/* CPU only has SCHED_IDLE tasks enqueued */ > > > > +static int sched_idle_cpu(int cpu) > > > > +{ > > > > + struct rq *rq = cpu_rq(cpu); > > > > + > > > > + return unlikely(rq->nr_running == rq->cfs.idle_h_nr_running && > > > > + rq->nr_running); > > > > +} > > > > + > > > Shouldn't this check if rq->curr is also sched idle? > > Why wouldn't the current set of checks be enough to guarantee that ? > I thought nr_running does not include the on-cpu thread. It very much does. > > > And why not drop the rq->nr_running non zero check? > > Because CPU isn't sched-idle if nr_running and idle_h_nr_running are both 0, > > i.e. it is an IDLE cpu in that case. And so I thought it is important to have > > this check as well. > > > idle_cpu() not only checks nr_running is 0 but also rq->curr == rq->idle idle_cpu() will try very hard to declare a CPU !idle. But I don't see how that it relevant. sched_idle_cpu() will only return true if there are only SCHED_IDLE tasks on the CPU. Viresh's test is simple and straight forward.