Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp293082ybh; Wed, 22 Jul 2020 00:20:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAPR/NCFgumnHg8cms+dNxvyJwG3cwf8FMYRf/tdpEPJ/YvUBH1//qKGci6RxTWX4VK65I X-Received: by 2002:a17:906:7c07:: with SMTP id t7mr30092427ejo.487.1595402453192; Wed, 22 Jul 2020 00:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595402453; cv=none; d=google.com; s=arc-20160816; b=m9o8GQOjmLPp8J1aWJbb4eAAEMpU5l4kXY8CjQsaqj1swHImOj+mWHf/5foljbTfMU KqgLD/sn/9uuXLlImq3bmBDd/Lt4z7HtiYcHUBEVFEwpbB3hmCzqzqGUiqyRXQhGbV33 moZkgv3E4RblssSdRI4lsikzf8uTtO1n3ZH43klPxTK+rVRZc7vkaqFdHHemOnXxil6R Mnb5XuMXWzqZJDhW6HyQGq0+tBCoIXktqX3EZ1Cn7eqwRnr1QAYJwi1M4S+8XMF6EOJY JnzTEeXEv2ANJB/xUCvWQFetU4tYy3mXSjFrykdL9Gt2Ab0+ge88Yqr1joI2CkhToebb oi3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=56sGWhnGKynThdl1LbDQD4iUDHvflh6rlDG2GfB6tgE=; b=QseHFlNN5QHMcaC4onuCkcWBXyWR3mKgI2hicl6gKi22/6vHsgfeih09arjpqHXYVm Z/+WoixKDrAU13LD/U+xZggLPAZwwMIm3b4L/+WpXyQZ+755PDgFMQjG/F2ZziFgxdoW JaU6pZokV5v8JdHvWZ6v8dh3kbmoAg9qGxH45lPVzzQgIu9lVZlqeSg+uV/irP/bGYS+ 0HgAN1wfikzxqt6EMXvB3vQ9kqe6gs472oxYDiUZezSgRI158SPBK9Bfj1g/4XeYV/2N 7IXBIUR/0Pj/jF0pPRNr95IuUl5n3CgXtooYXoXoJQ/s2du9IYVL5AtPaH2uzDqzviDd LoIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tencent.com header.s=s202002 header.b=GPpx9vug; 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=pass (p=NONE sp=NONE dis=NONE) header.from=tencent.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p11si14433193edq.445.2020.07.22.00.20.30; Wed, 22 Jul 2020 00:20:53 -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; dkim=pass header.i=@tencent.com header.s=s202002 header.b=GPpx9vug; 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=pass (p=NONE sp=NONE dis=NONE) header.from=tencent.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731994AbgGVHUS (ORCPT + 99 others); Wed, 22 Jul 2020 03:20:18 -0400 Received: from mail4.tencent.com ([183.57.53.109]:34838 "EHLO mail4.tencent.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728338AbgGVHUR (ORCPT ); Wed, 22 Jul 2020 03:20:17 -0400 Received: from EX-SZ020.tencent.com (unknown [10.28.6.40]) by mail4.tencent.com (Postfix) with ESMTP id B5702724D6; Wed, 22 Jul 2020 15:20:13 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tencent.com; s=s202002; t=1595402413; bh=AsYlnjFF2hYKj+7FKYMNeD7e5NE3fdzhp7oH/PzpvYU=; h=From:To:CC:Subject:Date:References:In-Reply-To; b=GPpx9vughH3O4VqknGZLt6yFJ5PC1HUDD6Mwg4VvOD6LT5kSo0kKzO4qGRWdrrfZ4 8R5Gqkx35QNqeht4VBkGakJ+DYb7FUhxCkT91+Ae5raq1dsqX/44bWVwUHK0YNYwv6 1CUkb6/sudfv0EsVeLOIzV35OmQtChgA5H/LapWU= Received: from EX-SZ004.tencent.com (10.28.6.25) by EX-SZ020.tencent.com (10.28.6.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Wed, 22 Jul 2020 15:20:13 +0800 Received: from EX-SZ012.tencent.com (10.28.6.36) by EX-SZ004.tencent.com (10.28.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Wed, 22 Jul 2020 15:20:13 +0800 Received: from EX-SZ012.tencent.com ([fe80::f57b:8971:e6d4:fe6b]) by EX-SZ012.tencent.com ([fe80::f57b:8971:e6d4:fe6b%3]) with mapi id 15.01.1847.007; Wed, 22 Jul 2020 15:20:13 +0800 From: =?iso-2022-jp?B?YmVuYmppYW5nKBskQj5VSTcbKEIp?= To: Vineeth Remanan Pillai , Peter Zijlstra CC: Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , "Tim Chen" , "mingo@kernel.org" , "tglx@linutronix.de" , "pjt@google.com" , "torvalds@linux-foundation.org" , "linux-kernel@vger.kernel.org" , "subhra.mazumdar@oracle.com" , "fweisbec@gmail.com" , "keescook@chromium.org" , "kerrnel@google.com" , Phil Auld , Aaron Lu , Aubrey Li , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , Joel Fernandes , "Joel Fernandes (Google)" , "vineethrp@gmail.com" , "Chen Yu" , Christian Brauner Subject: Re: [RFC PATCH 07/16] sched/fair: Fix forced idle sibling starvation corner case(Internet mail) Thread-Topic: [RFC PATCH 07/16] sched/fair: Fix forced idle sibling starvation corner case(Internet mail) Thread-Index: AQHWTyYlpLP1bK1w0UWTtI+YyeyPMKkSzKoA Date: Wed, 22 Jul 2020 07:20:13 +0000 Message-ID: <8C431BBC-154C-4AAC-8876-FFFF173AE2B9@tencent.com> References: In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [9.19.161.93] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Jul 1, 2020, at 5:32 AM, Vineeth Remanan Pillai wrote: >=20 > From: vpillai >=20 > If there is only one long running local task and the sibling is > forced idle, it might not get a chance to run until a schedule > event happens on any cpu in the core. >=20 > So we check for this condition during a tick to see if a sibling > is starved and then give it a chance to schedule. Hi, There may be other similar starvation cases this patch can not cover.=20 Such as, If there is one long running RT task and sibling is forced idle, t= hen all tasks with different cookies on all siblings could be starving fore= ver. Current load-balances seems not able to pull the starved tasks away.=20 Would load-balance be more aware of core-scheduling to make things better? = :) Thx. Regards, Jiang=20 >=20 > Signed-off-by: Vineeth Remanan Pillai > Signed-off-by: Julien Desfossez > --- > kernel/sched/fair.c | 39 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 39 insertions(+) >=20 > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index ae17507533a0..49fb93296e35 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -10613,6 +10613,40 @@ static void rq_offline_fair(struct rq *rq) >=20 > #endif /* CONFIG_SMP */ >=20 > +#ifdef CONFIG_SCHED_CORE > +static inline bool > +__entity_slice_used(struct sched_entity *se) > +{ > + return (se->sum_exec_runtime - se->prev_sum_exec_runtime) > > + sched_slice(cfs_rq_of(se), se); > +} > + > +/* > + * If runqueue has only one task which used up its slice and if the sibl= ing > + * is forced idle, then trigger schedule to give forced idle task a chan= ce. > + */ > +static void resched_forceidle_sibling(struct rq *rq, struct sched_entity= *se) > +{ > + int cpu =3D cpu_of(rq), sibling_cpu; > + > + if (rq->cfs.nr_running > 1 || !__entity_slice_used(se)) > + return; > + > + for_each_cpu(sibling_cpu, cpu_smt_mask(cpu)) { > + struct rq *sibling_rq; > + if (sibling_cpu =3D=3D cpu) > + continue; > + if (cpu_is_offline(sibling_cpu)) > + continue; > + > + sibling_rq =3D cpu_rq(sibling_cpu); > + if (sibling_rq->core_forceidle) { > + resched_curr(sibling_rq); > + } > + } > +} > +#endif > + > /* > * scheduler tick hitting a task of our scheduling class. > * > @@ -10636,6 +10670,11 @@ static void task_tick_fair(struct rq *rq, struct= task_struct *curr, int queued) >=20 > update_misfit_status(curr, rq); > update_overutilized_status(task_rq(curr)); > + > +#ifdef CONFIG_SCHED_CORE > + if (sched_core_enabled(rq)) > + resched_forceidle_sibling(rq, &curr->se); > +#endif > } >=20 > /* > --=20 > 2.17.1 >=20 >=20