Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp76378ybt; Tue, 30 Jun 2020 15:10:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdfMmlzvNA0BCAJsrK7NH/NOix9GNRyyv/eVMkbjNb0k67yzUTrsw+O1yHlBkmAbh6sey2 X-Received: by 2002:a17:906:3958:: with SMTP id g24mr19320347eje.26.1593554582859; Tue, 30 Jun 2020 15:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593554582; cv=none; d=google.com; s=arc-20160816; b=xDiQSzt/h280JF+L5TGuIV/YhVwvtIwk/U7u1MjnRimNCQa4bHifHptCGbNAjXC8XS haEa1Q8nTGunk8BXkjphdULHAEOoFDNZ3eDW9mTlCA43sw5D1SaH7m1zx6qNdTM9QrFl LBpOhv8m1yQ1r0pfSo6DwU0wKS9Tkwjja79M12BMHV07CgSvTZhLdc6qFNZdFsTw7AUH usfy7C2OdnLfUHGyWTW+ehNluwCSnbnVhhU8zmdBF2HEosSXyvX5OjIgWgmihrIVlLts /rePOEEvTfP5gauQ+2EF6el5vYFYIMVpU5l4uPSBBgEB2rxUyQCn2hksoNsqSQGmtJWN hy6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=p3fES35YITsidZ4eGLne/2ofjR3Ab7HGCf2PrO4zrIE=; b=dd1V4yoKOQEe4nQ+dVraPfmnwNF8G/Y4Rmu1w2Z7Kdaud9VDU8gKjdHzvqQ/m1jhvS Fm1N71QPGnP5fuuizgh9oS5PHw12HHy7SQS1gsRZbrZfO7S5RP02plwmxL49lnhhwfdD WlBShiDQXRZeHJEF5FM19tf7tFthWde77Mi5PFRUqIEN0GjGk9MDAjwFiLlH7N9wW9Wy g2xuwqJx3BcRAI/U80EngySN9CJdkeUVBPZtMe3e/vWEWim7p8LyF6ne6jhOKJVfCjfr 6Y3C6RRQumPP2P2svczdymEQw4unoFVEmlt3PWXCs9Bk5EE/f7QUHl8cm6Vgf7jtrx7R MchQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digitalocean.com header.s=google header.b=gugh5DJ6; 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=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si2465909edr.239.2020.06.30.15.02.39; Tue, 30 Jun 2020 15:03:02 -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=@digitalocean.com header.s=google header.b=gugh5DJ6; 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=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728143AbgF3VdX (ORCPT + 99 others); Tue, 30 Jun 2020 17:33:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728033AbgF3VdV (ORCPT ); Tue, 30 Jun 2020 17:33:21 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15E92C03E97A for ; Tue, 30 Jun 2020 14:33:21 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id j4so9017711plk.3 for ; Tue, 30 Jun 2020 14:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digitalocean.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=p3fES35YITsidZ4eGLne/2ofjR3Ab7HGCf2PrO4zrIE=; b=gugh5DJ6sIVVBrAwPiy1GUqAB9GtT/TRlyBP1Igs9PIF65ybl/IAgLezi+690CMUg7 nboZgWjgClg73e3TqH0YqOeqKB8F32t3oj6tlGF6JRID4e+ouRS5QkZC2wSpatqVT86Y uKxoXFOLbgvMq6nxW9C8N6ZaUvZKI7TvHUBpc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=p3fES35YITsidZ4eGLne/2ofjR3Ab7HGCf2PrO4zrIE=; b=CDBUzfVCVr4WAsn/FTy1kUmLLy11QWnyckzW0aEH7ecuj7mmql9CMoIgk0yylrOQaA XVAaOqkN9qTFrLu6h9VMPswTH9GMA6XHo3fOgLzLei9zrzzdCIgBJkrRsvmnzdQ1eMlK 9ZFDQE2Yl/ffHJFXESV6jKYQux0K4kNB/gJ8KKM+M4YxVMiR6dGRahYma2C1/B7NJhtl R3FTY9Ur0tO1Tn0Y9nykXpIG7DgKInjOaqPBMsLfxPR2tR9P8lQ+uaF16IU9bplPijmM jNwsoIrfZgWqgyD5IB343wKoZWtXWRgtatyfO+n1AvBCZbT2mY7LK9E3PKUKG22v1rWn E8jQ== X-Gm-Message-State: AOAM532VEUBDAuaA0kc7sj7W2HLkj/wJREba9yL88EETP8RnZgQhq94o Oi8qbbugl4H3PwVNjJVnwFzARw== X-Received: by 2002:a17:90a:17ab:: with SMTP id q40mr22174737pja.152.1593552800477; Tue, 30 Jun 2020 14:33:20 -0700 (PDT) Received: from vpillai-dev.sfo2.internal.digitalocean.com ([138.68.32.68]) by smtp.gmail.com with ESMTPSA id e16sm3594311pff.180.2020.06.30.14.33.19 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jun 2020 14:33:20 -0700 (PDT) From: Vineeth Remanan Pillai To: Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , Tim Chen , mingo@kernel.org, tglx@linutronix.de, pjt@google.com, torvalds@linux-foundation.org Cc: vpillai , 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@joelfernandes.org, vineethrp@gmail.com, Chen Yu , Christian Brauner Subject: [RFC PATCH 07/16] sched/fair: Fix forced idle sibling starvation corner case Date: Tue, 30 Jun 2020 21:32:28 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: vpillai 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. So we check for this condition during a tick to see if a sibling is starved and then give it a chance to schedule. Signed-off-by: Vineeth Remanan Pillai Signed-off-by: Julien Desfossez --- kernel/sched/fair.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) 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) #endif /* CONFIG_SMP */ +#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 sibling + * is forced idle, then trigger schedule to give forced idle task a chance. + */ +static void resched_forceidle_sibling(struct rq *rq, struct sched_entity *se) +{ + int cpu = 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 == cpu) + continue; + if (cpu_is_offline(sibling_cpu)) + continue; + + sibling_rq = 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) 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 } /* -- 2.17.1