Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp117031ybx; Wed, 30 Oct 2019 12:13:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfa4WVEZsFWJj9nszq0MaE6zEarM48NjDfnthYtvDcCg5fKnAHGpvGTyIFz5KiHYuDFH14 X-Received: by 2002:a17:906:7f82:: with SMTP id f2mr1125300ejr.313.1572462814007; Wed, 30 Oct 2019 12:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572462814; cv=none; d=google.com; s=arc-20160816; b=nrnugupwOzrNlpM6CFlTHWXkoRXVSBaLD0CKroFxMADC4MMEdR/SvhRaVmCdDGOXXY LZMYWsv8rBnqvKNIK+6EYna97QD2RkHyRVNi5JmLDMgWgAw9kSJoJC25dGPD78XKr7Wf 0mZC7Z3FFDghLTpn4WksAa3bD4b8a1+rj6FBkKapdJXaWCKW0BDIoRqay1jgYlHMwK5g n5ifXJZvDR+SAWd8rdHu5AK/LZxQS5Dw8tY8jPO6c8q7aeE85NhXgKLg+DMm7BaCmBTS 1V/GoqEvwjIKzIXEYlnE6j9rvr8EgolK003qakDkBUK13076h1eUiMS3Vuaeusxd36zs nXMA== 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=sCPo7Sa7HT48HXeeD9u54Jo9TW2SXqApycTbqabqamA=; b=b7ah/v/tml7kZfge2NIcJ+mfNOW06PdMuu3Ay+d7PVCtlJ1npVQ8TgHV/1ABvSo46e p+LfCRWdO7wa4sdxmpSUqtdhdsWH2k0xgTeEgWD1iAkj6uDpkqLYEsZDehiZ8XdKNabz KqT7Pb3GTjkzAyCCR8eZPWqgOiUpxG34g4xD8XhL3FiJC2YpIs94GEyDylNljv+BhVq7 JhB+cY6L1qLf2kA9AEhQZZaZSrn0jrV+ZW6r12o0E5K5l0+iaLYHqFJOe1zR+j3iF/i2 lGnjcGPDmTNawpLlqv3q2Qd0pM70sacU+YQkXd6/0pO7wYW3VHc59xMtM1icekf7AHOo h8eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digitalocean.com header.s=google header.b=hQBmMXBt; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rv12si105936ejb.372.2019.10.30.12.13.10; Wed, 30 Oct 2019 12:13:33 -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=pass header.i=@digitalocean.com header.s=google header.b=hQBmMXBt; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728220AbfJ3Seh (ORCPT + 99 others); Wed, 30 Oct 2019 14:34:37 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:43437 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728200AbfJ3See (ORCPT ); Wed, 30 Oct 2019 14:34:34 -0400 Received: by mail-yw1-f67.google.com with SMTP id g77so1180022ywb.10 for ; Wed, 30 Oct 2019 11:34:33 -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=sCPo7Sa7HT48HXeeD9u54Jo9TW2SXqApycTbqabqamA=; b=hQBmMXBtE030jLPi+b9OoEqhm+GlYLhHzFG71MvXJfq6tN7DnEaZObUxiXcvp8yJM8 rA2lINv0taa91AQ1KQxEutyYsC/pcupxwkuTpRNSS3DwTJW0m2VqpZ7GzK79exctCUdr YPub1UR6ihiKWvaGOQhGsV04S0Jwhg5oGj1rQ= 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=sCPo7Sa7HT48HXeeD9u54Jo9TW2SXqApycTbqabqamA=; b=dvQ6I+0C+7al8XWFAbBv0O4M90W+0kDXl+fil5EaAn1oN2+bweUAFRP6RNbmbRoPn+ D1bPZg8vKxNje/+UOxdWCh7e7iJe6hQk1qkaeVozLPhjPRw8QK1da7ThOADO+ytYa1yY y6kIRVij2QtMhvVDRStKTVE+RI3yJL8Gp/k/teqdih/VUTGPHlDiODHBUSMG/ehmQbNz 9Kgt2Qhrjneq35+WatZPIFIwKc5D9B1n/m7YmdGyr1TVj8+JAZCRvSSgxGuhRzrcTE/P SLx0CRUDR6hY7VOZ7a0ViW9vVuVXsoxHiF32eSKHaZ0UWPtvLo9M7hocrCP17lNrDkhv t7Mg== X-Gm-Message-State: APjAAAV8bomJ59vJmu8k/rK+3MqUP5k3r+hGBTudyTmi83357DcRRFij oYslvxCaqHnNdHxlHfzi7Uy/IQ== X-Received: by 2002:a81:6cd6:: with SMTP id h205mr841373ywc.119.1572460472652; Wed, 30 Oct 2019 11:34:32 -0700 (PDT) Received: from vpillai-dev.sfo2.internal.digitalocean.com ([138.68.32.68]) by smtp.gmail.com with ESMTPSA id m205sm558325ywd.82.2019.10.30.11.34.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Oct 2019 11:34:32 -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: Aaron Lu , linux-kernel@vger.kernel.org, Dario Faggioli , fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Aaron Lu , Aubrey Li , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , Vineeth Remanan Pillai Subject: [RFC PATCH v4 19/19] sched/fair : Wake up forced idle siblings if needed Date: Wed, 30 Oct 2019 18:33:32 +0000 Message-Id: <4aaad8379b0b54eca2df9a91cbc0eda47a7a8faf.1572437285.git.vpillai@digitalocean.com> 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: Aaron Lu If the sibling of a forced idle cpu has only one task and if it has used up its timeslice, then we should try to wake up the forced idle cpu to give the starving task on it a chance. Signed-off-by: Vineeth Remanan Pillai Signed-off-by: Julien Desfossez --- kernel/sched/fair.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e8dd78a8c54d..9d4cc97d4dd8 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4165,6 +4165,13 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) update_min_vruntime(cfs_rq); } +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); +} + /* * Preempt the current task with a newly woken task if needed: */ @@ -10052,6 +10059,34 @@ static void rq_offline_fair(struct rq *rq) #endif /* CONFIG_SMP */ +#ifdef CONFIG_SCHED_CORE +/* + * 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. * @@ -10075,6 +10110,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