Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp624631pxy; Wed, 28 Apr 2021 10:42:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFewl2DbX2uAXORQa7SQ20CDzYnW6w/BryeGUhB7toC53/vunBYsJpPb+vXrmzj4/Df86Z X-Received: by 2002:a05:6402:5203:: with SMTP id s3mr12849879edd.360.1619631735280; Wed, 28 Apr 2021 10:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619631735; cv=none; d=google.com; s=arc-20160816; b=fBBiA2EIBptAblCJw+ENBBjN5oEOCwI4qa0ocmg+sJ+HJ7rCNdTumx8A5RAksM5Twa m5wJFV9DZkmxipW9zRwp9ejNk91pehlc+17TPcEujdQI4LOVAn5uNmBM97Db5s+qWVnj YgbkbjX7PUx5U0kJMzz/QPLQ6JXfCjVmWW7PWs5C3jK67ijQ/UfqQEGCqP0hgt3lbyyL K6NbKykf7lSdc68UqViRfKrincUAOOkupJLbiddkJ9cEIAD86OztGqOOBz2pIPbRxFGl 3abP1JmDi41EQQr2k4AOBkhfQ/WIcnfytKACeGrTxMkIocwsyI5HdMK2VVYZXnhLQpvR ly0w== 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; bh=W6MANtJKVSSCQCS+h5+VztrEcrjpftlN8KBx1n1Xm0k=; b=HRQjQOJf3DXaqD7oyG29jRSi5TFhBIc4b9bDqUCE1VE2ZoAsUN/xeZ7C5tUWmepA34 WI4zXDMN2OHqJyKXbObDBcKbu2CNsaQzvwVpbZzD2F7eMNm3L/VZS0Z3cGaw+glHlUgd 2L6ziV9cr0uMWb+RtBghdcXHGvzztOLNDPu3asBYt1NYruryAjk1sZJ0ShSb2qxOvcfo MkwWX1KNsX0zRnHf0c9UH0wFtUhccZ8CPKNAVVVIlzBC/azH4BXf0uK5hFSKov0cdqBc 08q2rbd/mgzwikDP3OE0jXAnImexMJF8ZKQ8YbuqKyQgV0GNjN1mdLLXp5HWEKCNOu7T axiQ== 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=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b34si384290edf.381.2021.04.28.10.41.51; Wed, 28 Apr 2021 10:42:15 -0700 (PDT) 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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241139AbhD1QsU (ORCPT + 99 others); Wed, 28 Apr 2021 12:48:20 -0400 Received: from foss.arm.com ([217.140.110.172]:47970 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241219AbhD1QsS (ORCPT ); Wed, 28 Apr 2021 12:48:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0E2BDED1; Wed, 28 Apr 2021 09:47:33 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CA11F3F694; Wed, 28 Apr 2021 09:47:27 -0700 (PDT) Subject: Re: [RFC PATCH v6 3/4] scheduler: scan idle cpu in cluster for tasks within one LLC To: Vincent Guittot , "Song Bao Hua (Barry Song)" Cc: "tim.c.chen@linux.intel.com" , "catalin.marinas@arm.com" , "will@kernel.org" , "rjw@rjwysocki.net" , "bp@alien8.de" , "tglx@linutronix.de" , "mingo@redhat.com" , "lenb@kernel.org" , "peterz@infradead.org" , "rostedt@goodmis.org" , "bsegall@google.com" , "mgorman@suse.de" , "msys.mizuma@gmail.com" , "valentin.schneider@arm.com" , "gregkh@linuxfoundation.org" , Jonathan Cameron , "juri.lelli@redhat.com" , "mark.rutland@arm.com" , "sudeep.holla@arm.com" , "aubrey.li@linux.intel.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "x86@kernel.org" , "xuwei (O)" , "Zengtao (B)" , "guodong.xu@linaro.org" , yangyicong , "Liguozhu (Kenneth)" , "linuxarm@openeuler.org" , "hpa@zytor.com" References: <20210420001844.9116-1-song.bao.hua@hisilicon.com> <20210420001844.9116-4-song.bao.hua@hisilicon.com> <80f489f9-8c88-95d8-8241-f0cfd2c2ac66@arm.com> From: Dietmar Eggemann Message-ID: <8b5277d9-e367-566d-6bd1-44ac78d21d3f@arm.com> Date: Wed, 28 Apr 2021 18:47:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 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 On 28/04/2021 15:04, Vincent Guittot wrote: > On Wed, 28 Apr 2021 at 11:51, Song Bao Hua (Barry Song) > wrote: >> >>> -----Original Message----- >>> From: Dietmar Eggemann [mailto:dietmar.eggemann@arm.com] [...] >>> On 20/04/2021 02:18, Barry Song wrote: [...] >> I am really confused. The whole code has only checked if wake_flags >> has WF_TTWU, it has never checked if sd_domain has SD_BALANCE_WAKE flag. > > look at : > #define WF_TTWU 0x08 /* Wakeup; maps to SD_BALANCE_WAKE */ > > so when wake_wide return false, we use the wake_affine mecanism but > if it's false then we fllback to default mode which looks for: > if (tmp->flags & sd_flag) > > This means looking for SD_BALANCE_WAKE which is never set > > so sd will stay NULL and you will end up calling select_idle_sibling anyway > >> >> static int >> select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) >> { >> ... >> >> if (wake_flags & WF_TTWU) { >> record_wakee(p); >> >> if (sched_energy_enabled()) { >> new_cpu = find_energy_efficient_cpu(p, prev_cpu); >> if (new_cpu >= 0) >> return new_cpu; >> new_cpu = prev_cpu; >> } >> >> want_affine = !wake_wide(p) && cpumask_test_cpu(cpu, p->cpus_ptr); >> } >> } >> >> And try_to_wake_up() has always set WF_TTWU: >> static int >> try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) >> { >> cpu = select_task_rq(p, p->wake_cpu, wake_flags | WF_TTWU); >> ... >> } >> >> So the change in wake_wide will actually affect the value of want_affine. >> And I did also see code entered slow path during my benchmark. Yes, this is happening but IMHO not for wakeups. Check wake_flags for the tasks which go through `slow path` on your machine. They should have WF_EXEC or WF_FORK, not WF_TTWU (& WF_SYNC). >> One issue I mentioned during linaro open discussion is that >> since I have moved to use cluster size to decide the value >> of wake_wide, relatively less tasks will make wake_wide() >> decide to go to slow path, thus, tasks begin to spread to >> other NUMA, but actually llc_size might be able to contain >> those tasks. So a possible model might be: >> static int wake_wide(struct task_struct *p) >> { >> tasksize < cluster : scan cluster >> tasksize > llc : slow path >> tasksize > cluster && tasksize < llc: scan llc >> } >> >> thoughts? Like Vincent explained, the return value of wake_wide() doesn't matter. For wakeups you always end up in sis(). [...]