From patchwork Mon Nov 5 11:21:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 150167 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2474620ljp; Mon, 5 Nov 2018 03:22:09 -0800 (PST) X-Google-Smtp-Source: AJdET5fGTXpTk+si4EuofiGy16xYarqv6WmZuiHyoMbjPxUKJ8fLkVvKdAhx1rR4T9A8tOXtx8Cx X-Received: by 2002:a63:c45:: with SMTP id 5-v6mr19763887pgm.372.1541416929498; Mon, 05 Nov 2018 03:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541416929; cv=none; d=google.com; s=arc-20160816; b=YGvVGkjJeqQ8mOLI3DCEBy5YGEfiD53EjWhcceeo86D8lFpIxrQ+MkW8rICVzWykkx soEzdkLeMBw6AqVUpmUBswiL5wUA0mLYba5jkGCekLY9ydGCMLPyVvGX5ahFd3dY9fjo udPYZAjF4BphQcAgDFaPkseWzTTI1gQUPWKKqVj3+mK8xjy6BOW+B3a2kuZtqWTtklQq 1+1V6ByYBb21U+lGjVr+OECvcnOP78+3KN8CpeOKmjun2EHGKEUAJ4iWn4ZFusnb6eYP Lai1Qd3GWOllc9FR2cbbjbf77dJ6R4DlE9NVcFEYcxKO4MP0zouhPYZnROllvTQaOgQE o+FA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Sz6GE8no3HqnxxiFUe84AvjpuQ0crmNaPDcLmfEYLYg=; b=DEK5w0KYxSDDFc6kee5QRn7Y+4D8qFX08SnYQRokoURawyTZ5/Xyt5c20gSbwJqsqR 2D9RXc98mCkfhsekFT3liqztcBFWJ6L8GjREsyoj8xcKxLJFhzUU/wIEwozPAq2M/4il XEn8ia+twXjvEujsdu2bVmP2rHuIE6y6G5WwCZ22uZIUQAJUNUx8zan4OITzrRKntER9 Q+DSe/xKvKmAv9jTB/GGwvjVAUE+nHzd65Ho5UEv7xkFhiEiutLq8qZf5G6h8edbBZEo hENGkkgY4CCy/JzXM1GyMBeDX87gPkNA3GGL5RCJWx6xTPC2WhayOY6k8AXphJ8BzUSy tlWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iJZCDA/s"; 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 cd11-v6si7693495plb.59.2018.11.05.03.22.09; Mon, 05 Nov 2018 03:22:09 -0800 (PST) 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="iJZCDA/s"; 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 S1729522AbeKEUlU (ORCPT + 32 others); Mon, 5 Nov 2018 15:41:20 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:34472 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728943AbeKEUlU (ORCPT ); Mon, 5 Nov 2018 15:41:20 -0500 Received: by mail-pf1-f194.google.com with SMTP id y18-v6so1900326pfn.1 for ; Mon, 05 Nov 2018 03:22:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sz6GE8no3HqnxxiFUe84AvjpuQ0crmNaPDcLmfEYLYg=; b=iJZCDA/sjLneeTVpDEMU2IZiLyBgXQJxY0589AftLh4/s/SGEjVLm1XqGirT4JA6rN hhOalc+HdUt5d50Rrorn9JAW8OJouayLClQldDxYVGAQMBsXoL8L2VjspjG7nzvGUUDQ zFR2u6/7wgEShuvukFZaIAWbnTKTt3YsFZpqo= 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:mime-version :content-transfer-encoding; bh=Sz6GE8no3HqnxxiFUe84AvjpuQ0crmNaPDcLmfEYLYg=; b=cOAAMSGWQWzWZgPvbAGGk4+io9/Hf5Nf8oDq0+yTWNSPxG68FePgXfiZ0NY61Dg2SM wN/6dAphob99rF/XQExYHHnQtEP2KFzd9J9C2G+rdY8KHZ1WmYGvXc4DjBq9FbA/WWSe LmUNk0ds8eY7DWE8mdQK0RjYzW7IhhDSHaZU6pOxquF4B7uYauu8XA9t0EjI8ZK9TK8C SMq2ShS81vZdmYRuZojUaZ/Qzg5XE2OHWHiJd38sXDAyF5dNCqOUsfhhB2b9n+S85QfC bMBpeGjWBNwM0x0juibPl/cGJARgnnWwGontYDZ8JCww8SxDyJM+fz4w3pjMSW+7i/Fg rJzg== X-Gm-Message-State: AGRZ1gKo6Ecdfi+HQH7g+Ogh9CMf0PrTef0tLM1drGJR5cJuHs9E5yF/ FdlNivAH4Roh/Z7J6024sGwCeA== X-Received: by 2002:aa7:8603:: with SMTP id p3-v6mr21688654pfn.247.1541416925686; Mon, 05 Nov 2018 03:22:05 -0800 (PST) Received: from localhost ([171.61.116.174]) by smtp.gmail.com with ESMTPSA id t78-v6sm13240101pfk.59.2018.11.05.03.22.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 03:22:04 -0800 (PST) From: Viresh Kumar To: Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , Vincent Guittot , Daniel Lezcano , linux-kernel@vger.kernel.org Subject: [PATCH] sched: Create task_has_idle_policy() helper Date: Mon, 5 Nov 2018 16:51:55 +0530 Message-Id: X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We already have task_has_rt_policy() and task_has_dl_policy() helpers, create task_has_idle_policy() as well and update sched core to start using it. While at it, use task_has_dl_policy() at one more place. Signed-off-by: Viresh Kumar --- kernel/sched/core.c | 4 ++-- kernel/sched/debug.c | 2 +- kernel/sched/fair.c | 10 +++++----- kernel/sched/sched.h | 5 +++++ 4 files changed, 13 insertions(+), 8 deletions(-) -- 2.19.1.568.g152ad8e3369a Acked-by: Daniel Lezcano diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f12225f26b70..841f4e16c157 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -697,7 +697,7 @@ static void set_load_weight(struct task_struct *p, bool update_load) /* * SCHED_IDLE tasks get minimal weight: */ - if (idle_policy(p->policy)) { + if (task_has_idle_policy(p)) { load->weight = scale_load(WEIGHT_IDLEPRIO); load->inv_weight = WMULT_IDLEPRIO; p->se.runnable_weight = load->weight; @@ -4191,7 +4191,7 @@ static int __sched_setscheduler(struct task_struct *p, * Treat SCHED_IDLE as nice 20. Only allow a switch to * SCHED_NORMAL if the RLIMIT_NICE would normally permit it. */ - if (idle_policy(p->policy) && !idle_policy(policy)) { + if (task_has_idle_policy(p) && !idle_policy(policy)) { if (!can_nice(p, task_nice(p))) return -EPERM; } diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 6383aa6a60ca..02bd5f969b21 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -974,7 +974,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, #endif P(policy); P(prio); - if (p->policy == SCHED_DEADLINE) { + if (task_has_dl_policy(p)) { P(dl.runtime); P(dl.deadline); } diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ee271bb661cc..1c8776175235 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6486,7 +6486,7 @@ wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se) static void set_last_buddy(struct sched_entity *se) { - if (entity_is_task(se) && unlikely(task_of(se)->policy == SCHED_IDLE)) + if (entity_is_task(se) && unlikely(task_has_idle_policy(task_of(se)))) return; for_each_sched_entity(se) { @@ -6498,7 +6498,7 @@ static void set_last_buddy(struct sched_entity *se) static void set_next_buddy(struct sched_entity *se) { - if (entity_is_task(se) && unlikely(task_of(se)->policy == SCHED_IDLE)) + if (entity_is_task(se) && unlikely(task_has_idle_policy(task_of(se)))) return; for_each_sched_entity(se) { @@ -6556,8 +6556,8 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ return; /* Idle tasks are by definition preempted by non-idle tasks. */ - if (unlikely(curr->policy == SCHED_IDLE) && - likely(p->policy != SCHED_IDLE)) + if (unlikely(task_has_idle_policy(curr)) && + likely(!task_has_idle_policy(p))) goto preempt; /* @@ -6978,7 +6978,7 @@ static int task_hot(struct task_struct *p, struct lb_env *env) if (p->sched_class != &fair_sched_class) return 0; - if (unlikely(p->policy == SCHED_IDLE)) + if (unlikely(task_has_idle_policy(p))) return 0; /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 618577fc9aa8..b7a3147874e3 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -176,6 +176,11 @@ static inline bool valid_policy(int policy) rt_policy(policy) || dl_policy(policy); } +static inline int task_has_idle_policy(struct task_struct *p) +{ + return idle_policy(p->policy); +} + static inline int task_has_rt_policy(struct task_struct *p) { return rt_policy(p->policy);