Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1242116pxb; Wed, 4 Nov 2020 03:57:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVe3V7E/0LGba5f/tpl1FU/0hjyewSLmRmrnIIECzX1wHV+hscz9OQGffOZ5eutuG1Hc0k X-Received: by 2002:a05:6402:88d:: with SMTP id e13mr11509998edy.366.1604491035684; Wed, 04 Nov 2020 03:57:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604491035; cv=none; d=google.com; s=arc-20160816; b=tZLSNfsTRkm5frrUB4pugpp13PO2cwAxWuDr2i0agx6GsZU5cJ3H4jPJweMWP27fni lU40tdMRcwBS6kgrXhUFbJENOR3jqmr+hYaZpp+BUyJB7ZDV64MYBfB+umFSTKyr+q16 e69/2912QXphtYssAYlHyWWlUynE8K6JhQY6yEc0JgoONFvbrRmnnw9N2JCayIxzQCVP ufxR6JdWP0Ey7Z+sDcsubsLaQfFovjONaogVyPmtErNtNLbp3yP+iJRraZEB5JLmPyrP Z76dH/6PkigenoID2hePcWLn8Mo5JdCOPqcfxJ9HjZNWAyrC7RdydCC3U4v2I9KYItmG ueNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=1TAN6sTVQa9DKuXAHFPjb57qKtHVxyYDHrsrrCR3lDc=; b=bT1iKS0BwmGgYnO07Y1+l5XEQ3GTaN7YljyZQh9OM/dy9/UVhFQ0Xi9rZGxVXhW2f1 jO1UC3DO1uBYvVtTft7KulUgwqXRW7V7pdmI4oyus/SUt0T5TLlCPYMQrUCdZUUbLuUW 1kEzPDtZxm4gxQbkO+L3c+L2+7l1xt2f7bSfiYbc/1gGXxVxGFBjy4X+49F3a0VqrYX4 lqn4Raoe8hZyieL+2zQBhk0t4NVBH+gQGUwrplGCyn1/VkM3j3IcVNRYeBrcJAGYIDPJ 4CK88K43R1Up/M3M70M5CNvezlBZTMHuEFWNcZ7UHU6A3J+WhRwenOZQoE/3daal+Rvx YvoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m5si1215880eje.723.2020.11.04.03.56.53; Wed, 04 Nov 2020 03:57:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728287AbgKDLx1 (ORCPT + 99 others); Wed, 4 Nov 2020 06:53:27 -0500 Received: from mga04.intel.com ([192.55.52.120]:2014 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbgKDLw1 (ORCPT ); Wed, 4 Nov 2020 06:52:27 -0500 IronPort-SDR: eqx+g7s30Wc/9Nau371tKlz/Ud92KiV/aJtZSyG3BkTYwyCzc18ZOFzQ0aZ5Y6+ViLayXKbDTE hsPkNRTFkNvw== X-IronPort-AV: E=McAfee;i="6000,8403,9794"; a="166613756" X-IronPort-AV: E=Sophos;i="5.77,450,1596524400"; d="scan'208";a="166613756" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2020 03:52:27 -0800 IronPort-SDR: 7ncpuVVDPmthK2Ha1LadJKAMOHcImbcuboUuE4AURtqTe9gQE2BM4dhers92R1uWpSlza7/xg0 RuI9MaIW+xtQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,450,1596524400"; d="scan'208";a="363957787" Received: from cli6-desk1.ccr.corp.intel.com (HELO [10.239.161.135]) ([10.239.161.135]) by orsmga007.jf.intel.com with ESMTP; 04 Nov 2020 03:52:23 -0800 Subject: Re: [RFC PATCH v3] sched/fair: select idle cpu from idle cpumask for task wakeup To: Valentin Schneider Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, tim.c.chen@linux.intel.com, linux-kernel@vger.kernel.org, Aubrey Li , Qais Yousef , Jiang Biao References: <20201021150335.1103231-1-aubrey.li@linux.intel.com> From: "Li, Aubrey" Message-ID: <27f88d6a-302e-2c28-c936-22ac233fe175@linux.intel.com> Date: Wed, 4 Nov 2020 19:52:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Valentin, Thanks for your reply. On 2020/11/4 3:27, Valentin Schneider wrote: > > Hi, > > On 21/10/20 16:03, Aubrey Li wrote: >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 6b3b59cc51d6..088d1995594f 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -6023,6 +6023,38 @@ void __update_idle_core(struct rq *rq) >> rcu_read_unlock(); >> } >> >> +static DEFINE_PER_CPU(bool, cpu_idle_state); > > I would've expected this to be far less compact than a cpumask, but that's > not the story readelf is telling me. Objdump tells me this is recouping > some of the padding in .data..percpu, at least with the arm64 defconfig. > > In any case this ought to be better wrt cacheline bouncing, which I suppose > is what we ultimately want here. Yes, every CPU has a byte, so it may not be less than a cpumask. Probably I can put it into struct rq, do you have any better suggestions? > > Also, see rambling about init value below. > >> @@ -10070,6 +10107,12 @@ static void nohz_balancer_kick(struct rq *rq) >> if (unlikely(rq->idle_balance)) >> return; >> >> + /* The CPU is not in idle, update idle cpumask */ >> + if (unlikely(sched_idle_cpu(cpu))) { >> + /* Allow SCHED_IDLE cpu as a wakeup target */ >> + update_idle_cpumask(rq, true); >> + } else >> + update_idle_cpumask(rq, false); > > This means that without CONFIG_NO_HZ_COMMON, a CPU going into idle will > never be accounted as going out of it, right? Eventually the cpumask > should end up full, which conceptually implements the previous behaviour of > select_idle_cpu() but in a fairly roundabout way... Maybe I can move it to scheduler_tick(). > >> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c >> index 9079d865a935..f14a6ef4de57 100644 >> --- a/kernel/sched/topology.c >> +++ b/kernel/sched/topology.c >> @@ -1407,6 +1407,7 @@ sd_init(struct sched_domain_topology_level *tl, >> sd->shared = *per_cpu_ptr(sdd->sds, sd_id); >> atomic_inc(&sd->shared->ref); >> atomic_set(&sd->shared->nr_busy_cpus, sd_weight); >> + cpumask_copy(sds_idle_cpus(sd->shared), sched_domain_span(sd)); > > So at init you would have (single LLC for sake of simplicity): > > \all cpu : cpu_idle_state[cpu] == false > cpumask_full(sds_idle_cpus) == true > > IOW it'll require all CPUs to go idle at some point for these two states to > be properly aligned. Should cpu_idle_state not then be init'd to 1? > > This then happens again for hotplug, except that cpu_idle_state[cpu] may be > either true or false when the sds_idle_cpus mask is reset to 1's. > okay, will refine this in the next version. Thanks, -Aubrey