Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11165859ybi; Thu, 25 Jul 2019 11:07:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiI7YYD9VXl3r8k4xTnyo+4HAfJZdCie4RZry8aOeSPj/hSy8Oz9hx8GeEOj5LRslizLPR X-Received: by 2002:a17:90a:220a:: with SMTP id c10mr95612345pje.33.1564078049907; Thu, 25 Jul 2019 11:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564078049; cv=none; d=google.com; s=arc-20160816; b=j6r0wSEJpeaNNKrypKt65qP6opEnPfhI9MIAWLhr4Ax+6C4PjwruIhNzWDWKZGTO+2 CIz5to0vjo/0CFmzxfqcY1fMWogB9JQ9RLGk/L7F4EPXlUTEt3U1FcO/df/CdojZJ2nl DwIUpt0arnDYeJ0d0tLLIrIOLzot5CAMr/wc3+Xlr+F3FBvVfV/dNS/adLjWWG/MaVdb LZ/+Ij1gar6fVPcU6V87TniYLReBm7jbGqtlE7TCvvKhrhNykJXoj5jH2xzb4Dpvw9n7 a/5AW8HsKyHrQVA5Ho+CNQ9RQ2xxmf5aCNxd8jUsNwXZ1KVuBrnui//mp537wlmUzqWm 4ieA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=PCGBS68QWBzGeNkONybLIbURoOoUu0zUOLvVOWcxqYE=; b=meiJRPcltyFqI5xjGBAnutqldXFAkn+F+vb8mJ6vgXaUrbQEUV73HLclEt7J6GCk8D 6x3XcyxQoNhWdizmHlZC4IYI2xTfz3B2I8iEbyZaS4eyzrPZtPqIiOyOOfg6ojO5TWlQ EQsnuFTwoUSFHo12Q2vmisAtRaSqUsp8U8StAdg2bmOfGyvcdBDmlXmAIJG0OX8NX1Z1 KDw0AOsqwZgNk4k2vAyPXGASIKyvusMUn9UVCRTcZu4C72YhkkI6LVg2dKsu9B7ASiEP l9RSt8VFDc9ciBUUrX7NniMv1YvHyvXoIDuc+jEEY2PqXPJ/fb0aucDMJnwXOcwuG770 RVGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019071901 header.b=jC+t14ua; 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=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si15482845pjp.101.2019.07.25.11.07.14; Thu, 25 Jul 2019 11:07:29 -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=@zytor.com header.s=2019071901 header.b=jC+t14ua; 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=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389901AbfGYQTO (ORCPT + 99 others); Thu, 25 Jul 2019 12:19:14 -0400 Received: from terminus.zytor.com ([198.137.202.136]:36555 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387564AbfGYQTN (ORCPT ); Thu, 25 Jul 2019 12:19:13 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6PGJ2ZM1075755 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 25 Jul 2019 09:19:02 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6PGJ2ZM1075755 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019071901; t=1564071543; bh=PCGBS68QWBzGeNkONybLIbURoOoUu0zUOLvVOWcxqYE=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=jC+t14uaWgKVOY/MzPU/p7OIsCoAT+r2Ofw/OkEWdoSYY9+2n3ECn2lY+nV9IEwyX 85yI6BcBjIL6TYEJ7jdw7VA5mc48CXSp7QsIPbDrU8/a1kHMq+SmDfc1xFSkhz/lR0 XRFdN0iUBrYzd+dJnQlIpvb/20CFI2QMFD9SnIsjAVzd0C9k6tPik56nQxjjL4z6rf Z5nDfcBKUuuo555UOFWcjuEu5mPK/pY6IvvKiNYakqHUeRIsxlFaSmdwPTHFI0nGoF Bf2lj/V5BGFOgkITJNPONAmDRQoHKNGz9oYFNjM4sxL5Ibt4OBL3rOhFmB9skEJKL6 4FAXOGYeKzfYw== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6PGJ0o51075750; Thu, 25 Jul 2019 09:19:00 -0700 Date: Thu, 25 Jul 2019 09:19:00 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Viresh Kumar Message-ID: Cc: mingo@kernel.org, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, hpa@zytor.com, vincent.guittot@linaro.org, tglx@linutronix.de, viresh.kumar@linaro.org, peterz@infradead.org Reply-To: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, mingo@kernel.org, vincent.guittot@linaro.org, hpa@zytor.com, viresh.kumar@linaro.org, tglx@linutronix.de, peterz@infradead.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/fair: Introduce fits_capacity() Git-Commit-ID: 60e17f5cef838e9ca7946ced208ceddcec6c315d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.3 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 60e17f5cef838e9ca7946ced208ceddcec6c315d Gitweb: https://git.kernel.org/tip/60e17f5cef838e9ca7946ced208ceddcec6c315d Author: Viresh Kumar AuthorDate: Tue, 4 Jun 2019 12:31:52 +0530 Committer: Ingo Molnar CommitDate: Thu, 25 Jul 2019 15:51:56 +0200 sched/fair: Introduce fits_capacity() The same formula to check utilization against capacity (after considering capacity_margin) is already used at 5 different locations. This patch creates a new macro, fits_capacity(), which can be used from all these locations without exposing the details of it and hence simplify code. All the 5 code locations are updated as well to use it.. Signed-off-by: Viresh Kumar Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Vincent Guittot Link: https://lkml.kernel.org/r/b477ac75a2b163048bdaeb37f57b4c3f04f75a31.1559631700.git.viresh.kumar@linaro.org Signed-off-by: Ingo Molnar --- kernel/sched/fair.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 52564e050062..fb75c0bea80f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -96,12 +96,12 @@ int __weak arch_asym_cpu_priority(int cpu) } /* - * The margin used when comparing utilization with CPU capacity: - * util * margin < capacity * 1024 + * The margin used when comparing utilization with CPU capacity. * * (default: ~20%) */ -static unsigned int capacity_margin = 1280; +#define fits_capacity(cap, max) ((cap) * 1280 < (max) * 1024) + #endif #ifdef CONFIG_CFS_BANDWIDTH @@ -3808,7 +3808,7 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep) static inline int task_fits_capacity(struct task_struct *p, long capacity) { - return capacity * 1024 > task_util_est(p) * capacity_margin; + return fits_capacity(task_util_est(p), capacity); } static inline void update_misfit_status(struct task_struct *p, struct rq *rq) @@ -5235,7 +5235,7 @@ static inline unsigned long cpu_util(int cpu); static inline bool cpu_overutilized(int cpu) { - return (capacity_of(cpu) * 1024) < (cpu_util(cpu) * capacity_margin); + return !fits_capacity(cpu_util(cpu), capacity_of(cpu)); } static inline void update_overutilized_status(struct rq *rq) @@ -6456,7 +6456,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) /* Skip CPUs that will be overutilized. */ util = cpu_util_next(cpu, p, cpu); cpu_cap = capacity_of(cpu); - if (cpu_cap * 1024 < util * capacity_margin) + if (!fits_capacity(util, cpu_cap)) continue; /* Always use prev_cpu as a candidate. */ @@ -8011,8 +8011,7 @@ group_is_overloaded(struct lb_env *env, struct sg_lb_stats *sgs) static inline bool group_smaller_min_cpu_capacity(struct sched_group *sg, struct sched_group *ref) { - return sg->sgc->min_capacity * capacity_margin < - ref->sgc->min_capacity * 1024; + return fits_capacity(sg->sgc->min_capacity, ref->sgc->min_capacity); } /* @@ -8022,8 +8021,7 @@ group_smaller_min_cpu_capacity(struct sched_group *sg, struct sched_group *ref) static inline bool group_smaller_max_cpu_capacity(struct sched_group *sg, struct sched_group *ref) { - return sg->sgc->max_capacity * capacity_margin < - ref->sgc->max_capacity * 1024; + return fits_capacity(sg->sgc->max_capacity, ref->sgc->max_capacity); } static inline enum