From patchwork Wed Jun 26 05:06:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167769 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp458486ilk; Tue, 25 Jun 2019 22:06:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqypmN5EUb2XyG98Z28eUZuwkUbVzMAWlgwNYu9b43BAWlQlMAkzdjJnBcb1mm6SOQ0WnGKg X-Received: by 2002:a65:6259:: with SMTP id q25mr884369pgv.404.1561525613519; Tue, 25 Jun 2019 22:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561525613; cv=none; d=google.com; s=arc-20160816; b=DO6/rhHYiykgeP6IfUUp/j2U+6ia1BA9V1aK3fRlJDULbh86HqpOZgsE9NGhwh3I0t TjdSJkLL8fIak/OhLuvpFZh63oQyPL6IUEoNyD/tRw1GY8pjrwnOUOtZNwiIjK9H2xSX Y6pSvf7gcoVpah4jnSNA4Ip/X4uLLuEAmp4xljRdGXEJf4Xu/V+Jtl/cD16EHTuwjNdR QAG/CHMULBzh37xgZJuDmFY2/fkB8EN09gKkg2YbK9GD9bd+Jkr6jpCbT9aJbVPRiSw3 vnkQcLDXLf/GenZ434mIo/HnE2afKkoTqSyofUCEafDckS5AZUbYMZ430VYcSrHH06Xr 4+Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fr132i4NOwwkZ0nQOvkdNyG2SrvzvLzQB1yU26SI4s0=; b=bywhcsQ7xOil3Cl16BIqaTQ7oMobVlAOrbK8Qs70/ziKzs7URT11ZGsTWj+GiH7goa +CZ5d6ggvjxOkq3678bSdiBzy73e/cOVHrrQ+t1rCbX5CANj/2zzQWpgQxWVfpaxozQw F1Ykze6lUMlYrSmwMa8JjHDixxIzZEJCtTsbbP4PfrvVhashfoMYdCIUYRM1JLpUQ0dZ N6v+/vsotqD1DXha5k6D/T5rJCjR48MTzDodF7P+joIcHVru8VRN33wFvzn0oHgc1H0S byYdRvatwZQIN46GqNuyKUxir/9Yoi0MK4IQNIhpPss1I0b4OiJfp7OjXIa9aXiAIBiV YulQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hZFkA//D"; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si14285009pgt.217.2019.06.25.22.06.53; Tue, 25 Jun 2019 22:06:53 -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=@linaro.org header.s=google header.b="hZFkA//D"; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726508AbfFZFGu (ORCPT + 30 others); Wed, 26 Jun 2019 01:06:50 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45466 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbfFZFGs (ORCPT ); Wed, 26 Jun 2019 01:06:48 -0400 Received: by mail-pl1-f193.google.com with SMTP id bi6so709630plb.12 for ; Tue, 25 Jun 2019 22:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fr132i4NOwwkZ0nQOvkdNyG2SrvzvLzQB1yU26SI4s0=; b=hZFkA//DidyxzfiIni3hgxCy98Rh1YTXfmE4Lzbw0Uo7JnNfCPTM7t70dWOkAic4GR FjpMfBzkvBtc+B7cCHSJl1wXbkddZRmT8EGh+Lc+W6AuYLHafOhkNDco/i3bXEwQwH04 ZXExF4I+ZFAZKKeeKnQcj/AhOk3/wd/63E56dO9F6qf7g9Zomnyt49H2+tjQJAQs9oar bImpoWNW4R9nAF5blWn0nO+Kv2B2XjrkzWhbBjcL5RLAcSnfb8N72puiMs5bvatVokMV 7MS3he27x8OWbNip+cd1UbabCs3PWvpGPqQ9VEzn/UbyHis58/GZJkww//6qxLktmRve aAKA== 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:mime-version:content-transfer-encoding; bh=Fr132i4NOwwkZ0nQOvkdNyG2SrvzvLzQB1yU26SI4s0=; b=Md7UnOc5lowdLBxmyzYtcGjVoEFfEa73jy8Z5kN9UaI06cRNOTzw173XKWOcCdIUSK 78weyHpzwSrT7Q0VlSj6Jk09WQH/FZtIXXzQiPo0devbDCpkd9CNMZUVZiuAhRqFY87Q kT7R8kVHcIDnjZrZyyGEJskOqs1O22Vpaj/IFCI/Qec2LAYZllcJ4SRa/S36hCpauSa9 Ya1I4mQjo5oDcVIpi/vjPk+ilriYxUihX6IWNJtGmmOnybuCdJdW4DwCsO0sIcf0JAjo E+bzP9tL5x137eAeu+Gbju+/Uc8TjN8B1evgFAV05+HPR0vXVR1g9TeZNzsPOMbPFHG0 DQLA== X-Gm-Message-State: APjAAAWD8mfpfKBLDCP8oNd1zkzNIFwdocpTsZFY8vUNj1tsjkGKcEJa rCiSVVKJXZlCFutNNcxvKEr0otNdI+w= X-Received: by 2002:a17:902:b187:: with SMTP id s7mr2928225plr.309.1561525607817; Tue, 25 Jun 2019 22:06:47 -0700 (PDT) Received: from localhost ([122.172.211.128]) by smtp.gmail.com with ESMTPSA id z2sm15276614pgg.58.2019.06.25.22.06.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 22:06:47 -0700 (PDT) From: Viresh Kumar To: Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linux-kernel@vger.kernel.org, Vincent Guittot , tkjos@google.com, Daniel Lezcano , quentin.perret@linaro.org, chris.redpath@arm.com, steven.sistare@oracle.com, subhra.mazumdar@oracle.com, songliubraving@fb.com Subject: [PATCH V3 1/2] sched: Start tracking SCHED_IDLE tasks count in cfs_rq Date: Wed, 26 Jun 2019 10:36:29 +0530 Message-Id: <0d3cdc427fc68808ad5bccc40e86ed0bf9da8bb4.1561523542.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Track how many tasks are present with SCHED_IDLE policy in each cfs_rq. This will be used by later commits. Signed-off-by: Viresh Kumar --- kernel/sched/fair.c | 14 ++++++++++++-- kernel/sched/sched.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 036be95a87e9..1277adc3e7ed 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4500,7 +4500,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq) struct rq *rq = rq_of(cfs_rq); struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg); struct sched_entity *se; - long task_delta, dequeue = 1; + long task_delta, idle_task_delta, dequeue = 1; bool empty; se = cfs_rq->tg->se[cpu_of(rq_of(cfs_rq))]; @@ -4511,6 +4511,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq) rcu_read_unlock(); task_delta = cfs_rq->h_nr_running; + idle_task_delta = cfs_rq->idle_h_nr_running; for_each_sched_entity(se) { struct cfs_rq *qcfs_rq = cfs_rq_of(se); /* throttled entity or throttle-on-deactivate */ @@ -4520,6 +4521,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq) if (dequeue) dequeue_entity(qcfs_rq, se, DEQUEUE_SLEEP); qcfs_rq->h_nr_running -= task_delta; + qcfs_rq->idle_h_nr_running -= idle_task_delta; if (qcfs_rq->load.weight) dequeue = 0; @@ -4559,7 +4561,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg); struct sched_entity *se; int enqueue = 1; - long task_delta; + long task_delta, idle_task_delta; se = cfs_rq->tg->se[cpu_of(rq)]; @@ -4579,6 +4581,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) return; task_delta = cfs_rq->h_nr_running; + idle_task_delta = cfs_rq->idle_h_nr_running; for_each_sched_entity(se) { if (se->on_rq) enqueue = 0; @@ -4587,6 +4590,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) if (enqueue) enqueue_entity(cfs_rq, se, ENQUEUE_WAKEUP); cfs_rq->h_nr_running += task_delta; + cfs_rq->idle_h_nr_running += idle_task_delta; if (cfs_rq_throttled(cfs_rq)) break; @@ -5200,6 +5204,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) { struct cfs_rq *cfs_rq; struct sched_entity *se = &p->se; + int idle_h_nr_running = task_has_idle_policy(p); /* * The code below (indirectly) updates schedutil which looks at @@ -5232,6 +5237,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) if (cfs_rq_throttled(cfs_rq)) break; cfs_rq->h_nr_running++; + cfs_rq->idle_h_nr_running += idle_h_nr_running; flags = ENQUEUE_WAKEUP; } @@ -5239,6 +5245,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); cfs_rq->h_nr_running++; + cfs_rq->idle_h_nr_running += idle_h_nr_running; if (cfs_rq_throttled(cfs_rq)) break; @@ -5300,6 +5307,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) struct cfs_rq *cfs_rq; struct sched_entity *se = &p->se; int task_sleep = flags & DEQUEUE_SLEEP; + int idle_h_nr_running = task_has_idle_policy(p); for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); @@ -5314,6 +5322,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) if (cfs_rq_throttled(cfs_rq)) break; cfs_rq->h_nr_running--; + cfs_rq->idle_h_nr_running -= idle_h_nr_running; /* Don't dequeue parent if it has other entities besides us */ if (cfs_rq->load.weight) { @@ -5333,6 +5342,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); cfs_rq->h_nr_running--; + cfs_rq->idle_h_nr_running -= idle_h_nr_running; if (cfs_rq_throttled(cfs_rq)) break; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 802b1f3405f2..1f95411f5e61 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -484,6 +484,8 @@ struct cfs_rq { unsigned long runnable_weight; unsigned int nr_running; unsigned int h_nr_running; + /* h_nr_running for SCHED_IDLE tasks */ + unsigned int idle_h_nr_running; u64 exec_clock; u64 min_vruntime;